#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Progress.h"
#include "lldb/Core/Section.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/OperatingSystem.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
#include "lldb/Utility/AddressableBits.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
#include "DynamicLoaderDarwinKernel.h"
#include <algorithm>
#include <memory>
#ifdef ENABLE_DEBUG_PRINTF
#include <cstdio>
#define DEBUG_PRINTF …
#else
#define DEBUG_PRINTF(fmt, ...) …
#endif
usingnamespacelldb;
usingnamespacelldb_private;
LLDB_PLUGIN_DEFINE(…)
enum KASLRScanType { … };
static constexpr OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = …;
#define LLDB_PROPERTIES_dynamicloaderdarwinkernel
#include "DynamicLoaderDarwinKernelProperties.inc"
enum { … };
class DynamicLoaderDarwinKernelProperties : public Properties { … };
static DynamicLoaderDarwinKernelProperties &GetGlobalProperties() { … }
static bool is_kernel(Module *module) { … }
DynamicLoader *DynamicLoaderDarwinKernel::CreateInstance(Process *process,
bool force) { … }
lldb::addr_t
DynamicLoaderDarwinKernel::SearchForDarwinKernel(Process *process) { … }
lldb::addr_t
DynamicLoaderDarwinKernel::SearchForKernelAtSameLoadAddr(Process *process) { … }
lldb::addr_t
DynamicLoaderDarwinKernel::SearchForKernelWithDebugHints(Process *process) { … }
lldb::addr_t
DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) { … }
lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelViaExhaustiveSearch(
Process *process) { … }
bool
DynamicLoaderDarwinKernel::ReadMachHeader(addr_t addr, Process *process, llvm::MachO::mach_header &header,
bool *read_error) { … }
lldb_private::UUID
DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr,
Process *process,
bool *read_error) { … }
DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel(Process *process,
lldb::addr_t kernel_addr)
: … { … }
DynamicLoaderDarwinKernel::~DynamicLoaderDarwinKernel() { … }
void DynamicLoaderDarwinKernel::UpdateIfNeeded() { … }
void DynamicLoaderDarwinKernel::DidAttach() { … }
void DynamicLoaderDarwinKernel::DidLaunch() { … }
void DynamicLoaderDarwinKernel::Clear(bool clear_process) { … }
bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageAtFileAddress(
Process *process) { … }
void DynamicLoaderDarwinKernel::KextImageInfo::SetModule(ModuleSP module_sp) { … }
ModuleSP DynamicLoaderDarwinKernel::KextImageInfo::GetModule() { … }
void DynamicLoaderDarwinKernel::KextImageInfo::SetLoadAddress(
addr_t load_addr) { … }
addr_t DynamicLoaderDarwinKernel::KextImageInfo::GetLoadAddress() const { … }
uint64_t DynamicLoaderDarwinKernel::KextImageInfo::GetSize() const { … }
void DynamicLoaderDarwinKernel::KextImageInfo::SetSize(uint64_t size) { … }
uint32_t DynamicLoaderDarwinKernel::KextImageInfo::GetProcessStopId() const { … }
void DynamicLoaderDarwinKernel::KextImageInfo::SetProcessStopId(
uint32_t stop_id) { … }
bool DynamicLoaderDarwinKernel::KextImageInfo::operator==(
const KextImageInfo &rhs) const { … }
void DynamicLoaderDarwinKernel::KextImageInfo::SetName(const char *name) { … }
std::string DynamicLoaderDarwinKernel::KextImageInfo::GetName() const { … }
void DynamicLoaderDarwinKernel::KextImageInfo::SetUUID(const UUID &uuid) { … }
UUID DynamicLoaderDarwinKernel::KextImageInfo::GetUUID() const { … }
bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule(
Process *process) { … }
bool DynamicLoaderDarwinKernel::KextImageInfo::IsKernel() const { … }
void DynamicLoaderDarwinKernel::KextImageInfo::SetIsKernel(bool is_kernel) { … }
bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
Process *process, Progress *progress) { … }
uint32_t DynamicLoaderDarwinKernel::KextImageInfo::GetAddressByteSize() { … }
lldb::ByteOrder DynamicLoaderDarwinKernel::KextImageInfo::GetByteOrder() { … }
lldb_private::ArchSpec
DynamicLoaderDarwinKernel::KextImageInfo::GetArchitecture() const { … }
void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() { … }
bool DynamicLoaderDarwinKernel::BreakpointHitCallback(
void *baton, StoppointCallbackContext *context, user_id_t break_id,
user_id_t break_loc_id) { … }
bool DynamicLoaderDarwinKernel::BreakpointHit(StoppointCallbackContext *context,
user_id_t break_id,
user_id_t break_loc_id) { … }
bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader() { … }
bool DynamicLoaderDarwinKernel::ParseKextSummaries(
const Address &kext_summary_addr, uint32_t count) { … }
uint32_t DynamicLoaderDarwinKernel::ReadKextSummaries(
const Address &kext_summary_addr, uint32_t image_infos_count,
KextImageInfo::collection &image_infos) { … }
bool DynamicLoaderDarwinKernel::ReadAllKextSummaries() { … }
void DynamicLoaderDarwinKernel::KextImageInfo::PutToLog(Log *log) const { … }
void DynamicLoaderDarwinKernel::PutToLog(Log *log) const { … }
void DynamicLoaderDarwinKernel::PrivateInitialize(Process *process) { … }
void DynamicLoaderDarwinKernel::SetNotificationBreakpointIfNeeded() { … }
void DynamicLoaderDarwinKernel::PrivateProcessStateChanged(Process *process,
StateType state) { … }
ThreadPlanSP
DynamicLoaderDarwinKernel::GetStepThroughTrampolinePlan(Thread &thread,
bool stop_others) { … }
Status DynamicLoaderDarwinKernel::CanLoadImage() { … }
void DynamicLoaderDarwinKernel::Initialize() { … }
void DynamicLoaderDarwinKernel::Terminate() { … }
void DynamicLoaderDarwinKernel::DebuggerInitialize(
lldb_private::Debugger &debugger) { … }
llvm::StringRef DynamicLoaderDarwinKernel::GetPluginDescriptionStatic() { … }
lldb::ByteOrder
DynamicLoaderDarwinKernel::GetByteOrderFromMagic(uint32_t magic) { … }