LLDB mainline
|
#include <DynamicLoaderDarwinKernel.h>
Classes | |
class | KextImageInfo |
struct | OSKextLoadedKextSummaryHeader |
Public Member Functions | |
DynamicLoaderDarwinKernel (lldb_private::Process *process, lldb::addr_t kernel_addr) | |
~DynamicLoaderDarwinKernel () override | |
void | DidAttach () override |
Called after attaching a process. | |
void | DidLaunch () override |
Called after attaching a process. | |
lldb::ThreadPlanSP | GetStepThroughTrampolinePlan (lldb_private::Thread &thread, bool stop_others) override |
Provides a plan to step through the dynamic loader trampoline for the current state of thread. | |
lldb_private::Status | CanLoadImage () override |
Ask if it is ok to try and load or unload an shared library (image). | |
llvm::StringRef | GetPluginName () override |
Public Member Functions inherited from lldb_private::DynamicLoader | |
DynamicLoader (Process *process) | |
Construct with a process. | |
virtual bool | ProcessDidExec () |
Helper function that can be used to detect when a process has called exec and is now a new and different process. | |
bool | GetStopWhenImagesChange () const |
Get whether the process should stop when images change. | |
void | SetStopWhenImagesChange (bool stop) |
Set whether the process should stop when images change. | |
virtual void | FindEquivalentSymbols (Symbol *original_symbol, ModuleList &module_list, SymbolContextList &equivalent_symbols) |
Some dynamic loaders provide features where there are a group of symbols "equivalent to" a given symbol one of which will be chosen when the symbol is bound. | |
virtual bool | AlwaysRelyOnEHUnwindInfo (SymbolContext &sym_ctx) |
Ask if the eh_frame information for the given SymbolContext should be relied on even when it's the first frame in a stack unwind. | |
virtual lldb::addr_t | GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr) |
Retrieves the per-module TLS block for a given thread. | |
virtual lldb::ModuleSP | LoadModuleAtAddress (const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset) |
Locates or creates a module given by file and updates/loads the resulting module at the virtual base address base_addr . | |
virtual bool | GetSharedCacheInformation (lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache, LazyBool &private_shared_cache) |
Get information about the shared cache for a process, if possible. | |
virtual bool | IsFullyInitialized () |
Return whether the dynamic loader is fully initialized and it's safe to call its APIs. | |
virtual std::optional< lldb_private::Address > | GetStartAddress () |
Return the start address in the dynamic loader module. | |
virtual void | CalculateDynamicSaveCoreRanges (lldb_private::Process &process, std::vector< lldb_private::MemoryRegionInfo > &ranges, llvm::function_ref< bool(const lldb_private::Thread &)> save_thread_predicate) |
Returns a list of memory ranges that should be saved in the core file, specific for this dynamic loader. | |
Public Member Functions inherited from lldb_private::PluginInterface | |
PluginInterface ()=default | |
virtual | ~PluginInterface ()=default |
PluginInterface (const PluginInterface &)=delete | |
PluginInterface & | operator= (const PluginInterface &)=delete |
Static Public Member Functions | |
static void | Initialize () |
static void | Terminate () |
static llvm::StringRef | GetPluginNameStatic () |
static llvm::StringRef | GetPluginDescriptionStatic () |
static lldb_private::DynamicLoader * | CreateInstance (lldb_private::Process *process, bool force) |
static void | DebuggerInitialize (lldb_private::Debugger &debugger) |
static lldb::addr_t | SearchForDarwinKernel (lldb_private::Process *process) |
Static Public Member Functions inherited from lldb_private::DynamicLoader | |
static DynamicLoader * | FindPlugin (Process *process, llvm::StringRef plugin_name) |
Find a dynamic loader plugin for a given process. | |
static lldb::ModuleSP | LoadBinaryWithUUIDAndAddress (Process *process, llvm::StringRef name, UUID uuid, lldb::addr_t value, bool value_is_offset, bool force_symbol_search, bool notify, bool set_address_in_target, bool allow_memory_image_last_resort) |
Find/load a binary into lldb given a UUID and the address where it is loaded in memory, or a slide to be applied to the file address. |
Protected Types | |
enum | { KERNEL_MODULE_MAX_NAME = 64u , KERNEL_MODULE_ENTRY_SIZE_VERSION_1 = 64u + 16u + 8u + 8u + 8u + 4u + 4u } |
Static Protected Member Functions | |
static bool | BreakpointHitCallback (void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id) |
static lldb::ByteOrder | GetByteOrderFromMagic (uint32_t magic) |
static lldb::addr_t | SearchForKernelAtSameLoadAddr (lldb_private::Process *process) |
static lldb::addr_t | SearchForKernelWithDebugHints (lldb_private::Process *process) |
static lldb::addr_t | SearchForKernelNearPC (lldb_private::Process *process) |
static lldb::addr_t | SearchForKernelViaExhaustiveSearch (lldb_private::Process *process) |
static bool | ReadMachHeader (lldb::addr_t addr, lldb_private::Process *process, llvm::MachO::mach_header &mh, bool *read_error=nullptr) |
static lldb_private::UUID | CheckForKernelImageAtAddress (lldb::addr_t addr, lldb_private::Process *process, bool *read_error=nullptr) |
Protected Attributes | |
lldb::addr_t | m_kernel_load_address |
KextImageInfo | m_kernel |
lldb_private::Address | m_kext_summary_header_ptr_addr |
lldb_private::Address | m_kext_summary_header_addr |
OSKextLoadedKextSummaryHeader | m_kext_summary_header |
KextImageInfo::collection | m_known_kexts |
std::recursive_mutex | m_mutex |
lldb::user_id_t | m_break_id |
Protected Attributes inherited from lldb_private::DynamicLoader | |
Process * | m_process |
The process that this dynamic loader plug-in is tracking. |
Private Member Functions | |
DynamicLoaderDarwinKernel (const DynamicLoaderDarwinKernel &)=delete | |
const DynamicLoaderDarwinKernel & | operator= (const DynamicLoaderDarwinKernel &)=delete |
Definition at line 25 of file DynamicLoaderDarwinKernel.h.
|
protected |
Enumerator | |
---|---|
KERNEL_MODULE_MAX_NAME | |
KERNEL_MODULE_ENTRY_SIZE_VERSION_1 |
Definition at line 89 of file DynamicLoaderDarwinKernel.h.
DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel | ( | lldb_private::Process * | process, |
lldb::addr_t | kernel_addr ) |
Definition at line 511 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::DynamicLoader::DynamicLoader(), error(), lldb_private::PlatformDarwinKernel::GetPluginNameStatic(), lldb_private::Process::GetTarget(), LLDB_INVALID_BREAK_ID, m_break_id, m_kernel, m_kernel_load_address, m_kext_summary_header, m_kext_summary_header_addr, m_kext_summary_header_ptr_addr, m_known_kexts, m_mutex, lldb_private::Process::SetCanRunCode(), and lldb_private::Target::SetPlatform().
Referenced by BreakpointHitCallback(), CreateInstance(), DynamicLoaderDarwinKernel(), and operator=().
|
override |
Definition at line 527 of file DynamicLoaderDarwinKernel.cpp.
References Clear().
|
privatedelete |
References DynamicLoaderDarwinKernel().
|
protected |
Definition at line 1155 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::DynamicLoader, lldb_private::GetLog(), lldb_private::DynamicLoader::GetStopWhenImagesChange(), LLDB_LOGF, PutToLog(), and ReadAllKextSummaries().
Referenced by BreakpointHitCallback().
|
staticprotected |
Definition at line 1148 of file DynamicLoaderDarwinKernel.cpp.
References BreakpointHit(), and DynamicLoaderDarwinKernel().
Referenced by SetNotificationBreakpointIfNeeded().
|
overridevirtual |
Ask if it is ok to try and load or unload an shared library (image).
The dynamic loader often knows when it would be ok to try and load or unload a shared library. This function call allows the dynamic loader plug-ins to check any current dyld state to make sure it is an ok time to load a shared library.
Implements lldb_private::DynamicLoader.
Definition at line 1611 of file DynamicLoaderDarwinKernel.cpp.
References error(), and lldb_private::Status::FromErrorString().
|
staticprotected |
Definition at line 440 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::DynamicLoader, lldb_private::eArchTypeMachO, lldb_private::Target::GetArchitecture(), lldb_private::GetLog(), lldb_private::Process::GetTarget(), lldb_private::ArchSpec::GetTriple(), is_kernel(), lldb_private::ArchSpec::IsCompatibleMatch(), LLDB_INVALID_ADDRESS, LLDB_LOGF, ReadMachHeader(), lldb_private::Process::ReadModuleFromMemory(), and lldb_private::Target::SetArchitecture().
Referenced by CreateInstance(), SearchForKernelAtSameLoadAddr(), SearchForKernelNearPC(), SearchForKernelViaExhaustiveSearch(), and SearchForKernelWithDebugHints().
|
protected |
Definition at line 552 of file DynamicLoaderDarwinKernel.cpp.
References LLDB_BREAK_ID_IS_VALID, LLDB_INVALID_BREAK_ID, m_break_id, m_kernel, m_kext_summary_header_addr, m_kext_summary_header_ptr_addr, m_known_kexts, m_mutex, and lldb_private::DynamicLoader::m_process.
Referenced by PrivateInitialize(), PrivateProcessStateChanged(), and ~DynamicLoaderDarwinKernel().
|
static |
Definition at line 152 of file DynamicLoaderDarwinKernel.cpp.
References CheckForKernelImageAtAddress(), lldb_private::DynamicLoader::DynamicLoader(), DynamicLoaderDarwinKernel(), lldb_private::Target::GetArchitecture(), lldb_private::Target::GetExecutableModulePointer(), lldb_private::Process::GetTarget(), lldb_private::ArchSpec::GetTriple(), is_kernel(), and SearchForDarwinKernel().
Referenced by Initialize(), and Terminate().
|
static |
Definition at line 1628 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::PluginManager::CreateSettingForDynamicLoaderPlugin(), GetGlobalProperties(), lldb_private::PluginManager::GetSettingForDynamicLoaderPlugin(), and DynamicLoaderDarwinKernelProperties::GetSettingName().
Referenced by Initialize().
|
overridevirtual |
Called after attaching a process.
We've attached to a remote connection, or read a corefile.
Allow DynamicLoader plug-ins to execute some code after attaching to a process.
Now load the kernel binary and potentially the kexts, add them to the Target.
Implements lldb_private::DynamicLoader.
Definition at line 537 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::DynamicLoader::m_process, PrivateInitialize(), and UpdateIfNeeded().
|
overridevirtual |
Called after attaching a process.
Allow DynamicLoader plug-ins to execute some code after attaching to a process.
Implements lldb_private::DynamicLoader.
Definition at line 546 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::DynamicLoader::m_process, PrivateInitialize(), and UpdateIfNeeded().
|
inlineprotected |
Definition at line 85 of file DynamicLoaderDarwinKernel.h.
References m_kernel.
|
staticprotected |
Definition at line 1646 of file DynamicLoaderDarwinKernel.cpp.
References lldb::eByteOrderBig, lldb::eByteOrderInvalid, lldb::eByteOrderLittle, and lldb_private::endian::InlHostByteOrder().
|
static |
Definition at line 1640 of file DynamicLoaderDarwinKernel.cpp.
Referenced by Initialize().
|
inlineoverridevirtual |
Implements lldb_private::PluginInterface.
Definition at line 62 of file DynamicLoaderDarwinKernel.h.
References GetPluginNameStatic().
|
inlinestatic |
Definition at line 37 of file DynamicLoaderDarwinKernel.h.
Referenced by ProcessKDP::DoConnectRemote(), GetPluginName(), Initialize(), ProcessMachCore::LoadBinariesAndSetDYLD(), and ProcessMachCore::LoadBinariesViaMetadata().
|
overridevirtual |
Provides a plan to step through the dynamic loader trampoline for the current state of thread.
[in] | stop_others | Whether the plan should be set to stop other threads. |
Implements lldb_private::DynamicLoader.
Definition at line 1603 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::GetLog(), LLDB_LOGF, and lldb_private::Step.
|
static |
Definition at line 1618 of file DynamicLoaderDarwinKernel.cpp.
References CreateInstance(), DebuggerInitialize(), GetPluginDescriptionStatic(), GetPluginNameStatic(), and lldb_private::PluginManager::RegisterPlugin().
|
protected |
Definition at line 1033 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::AddressableBits::AddressableBitToMask(), lldb_private::ConstString::AsCString(), error(), lldb::eSymbolTypeAny, lldb::eSymbolTypeData, lldb_private::Symbol::GetAddress(), lldb_private::ObjectFile::GetBaseAddress(), lldb_private::Address::GetFileAddress(), lldb_private::Address::GetLoadAddress(), is_kernel(), LLDB_INVALID_ADDRESS, lldb_private::DynamicLoader::LoadOperatingSystemPlugin(), m_kernel, m_kernel_load_address, m_kext_summary_header_ptr_addr, lldb_private::DynamicLoader::m_process, and ReadAllKextSummaries().
Referenced by UpdateIfNeeded().
|
privatedelete |
References DynamicLoaderDarwinKernel().
|
protected |
Definition at line 1253 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::ModuleList::AppendIfNeeded(), DynamicLoaderDarwinKernel::KextImageInfo::Clear(), lldb_private::DynamicLoader, GetGlobalProperties(), DynamicLoaderDarwinKernel::KextImageInfo::GetLoadAddress(), DynamicLoaderDarwinKernelProperties::GetLoadKexts(), lldb_private::GetLog(), DynamicLoaderDarwinKernel::KextImageInfo::GetModule(), GetName(), DynamicLoaderDarwinKernel::KextImageInfo::GetProcessStopId(), DynamicLoaderDarwinKernel::KextImageInfo::IsKernel(), LLDB_INVALID_ADDRESS, LLDB_LOGF, DynamicLoaderDarwinKernel::KextImageInfo::LoadImageAtFileAddress(), DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(), m_kernel, m_known_kexts, m_mutex, lldb_private::DynamicLoader::m_process, and ReadKextSummaries().
Referenced by ReadAllKextSummaries().
|
protected |
Definition at line 1542 of file DynamicLoaderDarwinKernel.cpp.
References Clear(), DEBUG_PRINTF, lldb_private::DynamicLoader::m_process, and lldb_private::StateAsCString().
Referenced by DidAttach(), and DidLaunch().
|
protected |
Definition at line 1575 of file DynamicLoaderDarwinKernel.cpp.
References Clear(), DEBUG_PRINTF, lldb::eStateAttaching, lldb::eStateConnected, lldb::eStateCrashed, lldb::eStateDetached, lldb::eStateExited, lldb::eStateInvalid, lldb::eStateLaunching, lldb::eStateRunning, lldb::eStateStepping, lldb::eStateStopped, lldb::eStateSuspended, lldb::eStateUnloaded, lldb_private::StateAsCString(), and UpdateIfNeeded().
|
protected |
Definition at line 1521 of file DynamicLoaderDarwinKernel.cpp.
References LLDB_LOGF, m_kext_summary_header, m_kext_summary_header_addr, m_known_kexts, m_mutex, lldb_private::Log::PutCString(), and PutToLog().
Referenced by BreakpointHit(), and PutToLog().
|
protected |
Definition at line 1490 of file DynamicLoaderDarwinKernel.cpp.
References m_kext_summary_header, m_kext_summary_header_addr, m_known_kexts, m_mutex, ParseKextSummaries(), ReadKextSummaryHeader(), and lldb_private::Address::Slide().
Referenced by BreakpointHit(), and LoadKernelModuleIfNeeded().
|
protected |
Definition at line 1447 of file DynamicLoaderDarwinKernel.cpp.
References error(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), lldb_private::DataExtractor::GetData(), lldb_private::DataExtractor::GetU64(), KERNEL_MODULE_MAX_NAME, m_kernel, m_kext_summary_header, lldb_private::DynamicLoader::m_process, and lldb_private::DataExtractor::ValidOffsetForDataOfSize().
Referenced by ParseKextSummaries().
|
protected |
Definition at line 1169 of file DynamicLoaderDarwinKernel.cpp.
References error(), lldb_private::DataExtractor::GetU32(), KERNEL_MODULE_ENTRY_SIZE_VERSION_1, m_kernel, m_kext_summary_header, m_kext_summary_header_addr, m_kext_summary_header_ptr_addr, m_mutex, and lldb_private::DynamicLoader::m_process.
Referenced by ReadAllKextSummaries().
|
staticprotected |
Definition at line 397 of file DynamicLoaderDarwinKernel.cpp.
References error(), and lldb_private::Process::ReadMemory().
Referenced by CheckForKernelImageAtAddress(), and DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule().
|
protected |
|
static |
Definition at line 199 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::Process::GetImageInfoAddress(), LLDB_INVALID_ADDRESS, SearchForKernelAtSameLoadAddr(), SearchForKernelNearPC(), SearchForKernelViaExhaustiveSearch(), and SearchForKernelWithDebugHints().
Referenced by CreateInstance(), and ProcessMachCore::LoadBinariesViaExhaustiveSearch().
|
staticprotected |
Definition at line 217 of file DynamicLoaderDarwinKernel.cpp.
References CheckForKernelImageAtAddress(), lldb_private::ObjectFile::GetBaseAddress(), lldb_private::Target::GetExecutableModulePointer(), lldb_private::Address::GetFileAddress(), lldb_private::Module::GetObjectFile(), lldb_private::Process::GetTarget(), lldb_private::Module::GetUUID(), is_kernel(), lldb_private::Address::IsValid(), and LLDB_INVALID_ADDRESS.
Referenced by SearchForDarwinKernel().
|
staticprotected |
Definition at line 295 of file DynamicLoaderDarwinKernel.cpp.
References CheckForKernelImageAtAddress(), eKASLRScanLowgloAddresses, eKASLRScanNone, lldb_private::ArchSpec::GetAddressByteSize(), lldb_private::Target::GetArchitecture(), GetGlobalProperties(), lldb_private::ThreadList::GetSelectedThread(), lldb_private::Process::GetTarget(), lldb_private::Process::GetThreadList(), LLDB_INVALID_ADDRESS, and pc.
Referenced by SearchForDarwinKernel().
|
staticprotected |
Definition at line 352 of file DynamicLoaderDarwinKernel.cpp.
References CheckForKernelImageAtAddress(), eKASLRScanExhaustiveScan, lldb_private::ArchSpec::GetAddressByteSize(), lldb_private::Target::GetArchitecture(), GetGlobalProperties(), lldb_private::Process::GetTarget(), LLDB_INVALID_ADDRESS, UINT32_MAX, and UINT64_MAX.
Referenced by SearchForDarwinKernel().
|
staticprotected |
Definition at line 240 of file DynamicLoaderDarwinKernel.cpp.
References CheckForKernelImageAtAddress(), eKASLRScanNone, lldb_private::Process::GetAddressByteSize(), lldb_private::Process::GetByteOrder(), GetGlobalProperties(), lldb_private::DataExtractor::GetU32(), lldb_private::DataExtractor::GetU64(), LLDB_INVALID_ADDRESS, and lldb_private::Process::ReadMemoryFromInferior().
Referenced by SearchForDarwinKernel().
|
protected |
Definition at line 1549 of file DynamicLoaderDarwinKernel.cpp.
References lldb_private::FileSpecList::Append(), BreakpointHitCallback(), DEBUG_PRINTF, lldb::eLanguageTypeUnknown, lldb_private::eLazyBoolNo, lldb_private::Stoppoint::GetID(), LLDB_INVALID_BREAK_ID, m_break_id, m_kernel, lldb_private::DynamicLoader::m_process, lldb_private::Breakpoint::SetCallback(), and lldb_private::StateAsCString().
Referenced by UpdateIfNeeded().
|
static |
Definition at line 1624 of file DynamicLoaderDarwinKernel.cpp.
References CreateInstance(), and lldb_private::PluginManager::UnregisterPlugin().
|
protected |
|
protected |
Definition at line 529 of file DynamicLoaderDarwinKernel.cpp.
References LoadKernelModuleIfNeeded(), and SetNotificationBreakpointIfNeeded().
Referenced by DidAttach(), DidLaunch(), and PrivateProcessStateChanged().
|
protected |
|
protected |
Definition at line 292 of file DynamicLoaderDarwinKernel.h.
Referenced by Clear(), DynamicLoaderDarwinKernel(), and SetNotificationBreakpointIfNeeded().
|
protected |
Definition at line 285 of file DynamicLoaderDarwinKernel.h.
Referenced by Clear(), DynamicLoaderDarwinKernel(), GetAddrByteSize(), LoadKernelModuleIfNeeded(), ParseKextSummaries(), ReadKextSummaries(), ReadKextSummaryHeader(), and SetNotificationBreakpointIfNeeded().
|
protected |
Definition at line 284 of file DynamicLoaderDarwinKernel.h.
Referenced by DynamicLoaderDarwinKernel(), and LoadKernelModuleIfNeeded().
|
protected |
Definition at line 289 of file DynamicLoaderDarwinKernel.h.
Referenced by DynamicLoaderDarwinKernel(), PutToLog(), ReadAllKextSummaries(), ReadKextSummaries(), and ReadKextSummaryHeader().
|
protected |
Definition at line 288 of file DynamicLoaderDarwinKernel.h.
Referenced by Clear(), DynamicLoaderDarwinKernel(), PutToLog(), ReadAllKextSummaries(), and ReadKextSummaryHeader().
|
protected |
Definition at line 287 of file DynamicLoaderDarwinKernel.h.
Referenced by Clear(), DynamicLoaderDarwinKernel(), LoadKernelModuleIfNeeded(), and ReadKextSummaryHeader().
|
protected |
Definition at line 290 of file DynamicLoaderDarwinKernel.h.
Referenced by Clear(), DynamicLoaderDarwinKernel(), ParseKextSummaries(), PutToLog(), and ReadAllKextSummaries().
|
mutableprotected |
Definition at line 291 of file DynamicLoaderDarwinKernel.h.
Referenced by Clear(), DynamicLoaderDarwinKernel(), ParseKextSummaries(), PutToLog(), ReadAllKextSummaries(), and ReadKextSummaryHeader().