LLDB
mainline
|
#include "lldb/Target/DynamicLoader.h"
Public Member Functions | |
DynamicLoader (Process *process) | |
Construct with a process. More... | |
virtual void | DidAttach ()=0 |
Called after attaching a process. More... | |
virtual void | DidLaunch ()=0 |
Called after launching a process. More... | |
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. More... | |
bool | GetStopWhenImagesChange () const |
Get whether the process should stop when images change. More... | |
void | SetStopWhenImagesChange (bool stop) |
Set whether the process should stop when images change. More... | |
virtual lldb::ThreadPlanSP | GetStepThroughTrampolinePlan (Thread &thread, bool stop_others)=0 |
Provides a plan to step through the dynamic loader trampoline for the current state of thread. More... | |
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. More... | |
virtual Status | CanLoadImage ()=0 |
Ask if it is ok to try and load or unload an shared library (image). More... | |
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. More... | |
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. More... | |
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 . More... | |
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. More... | |
virtual bool | IsFullyInitialized () |
Return whether the dynamic loader is fully initialized and it's safe to call its APIs. More... | |
![]() | |
PluginInterface ()=default | |
virtual | ~PluginInterface ()=default |
virtual llvm::StringRef | GetPluginName ()=0 |
PluginInterface (const PluginInterface &)=delete | |
PluginInterface & | operator= (const PluginInterface &)=delete |
Static Public Member Functions | |
static DynamicLoader * | FindPlugin (Process *process, llvm::StringRef plugin_name) |
Find a dynamic loader plugin for a given process. More... | |
Protected Member Functions | |
lldb::ModuleSP | FindModuleViaTarget (const FileSpec &file) |
lldb::ModuleSP | GetTargetExecutable () |
Checks to see if the target module has changed, updates the target accordingly and returns the target executable module. More... | |
virtual void | UpdateLoadedSections (lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset) |
Updates the load address of every allocatable section in module . More... | |
void | UpdateLoadedSectionsCommon (lldb::ModuleSP module, lldb::addr_t base_addr, bool base_addr_is_offset) |
virtual void | UnloadSections (const lldb::ModuleSP module) |
Removes the loaded sections from the target in module . More... | |
void | UnloadSectionsCommon (const lldb::ModuleSP module) |
const lldb_private::SectionList * | GetSectionListFromModule (const lldb::ModuleSP module) const |
int64_t | ReadUnsignedIntWithSizeInBytes (lldb::addr_t addr, int size_in_bytes) |
lldb::addr_t | ReadPointer (lldb::addr_t addr) |
void | LoadOperatingSystemPlugin (bool flush) |
Protected Attributes | |
Process * | m_process |
The process that this dynamic loader plug-in is tracking. More... | |
A plug-in interface definition class for dynamic loaders.
Dynamic loader plug-ins track image (shared library) loading and unloading. The class is initialized given a live process that is halted at its entry point or just after attaching.
Dynamic loader plug-ins can track the process by registering callbacks using the: Process::RegisterNotificationCallbacks (const Notifications&) function.
Breakpoints can also be set in the process which can register functions that get called using: Process::BreakpointSetCallback (lldb::user_id_t, BreakpointHitCallback, void *). These breakpoint callbacks return a boolean value that indicates if the process should continue or halt and should return the global setting for this using: DynamicLoader::StopWhenImagesChange() const.
Definition at line 52 of file DynamicLoader.h.
DynamicLoader::DynamicLoader | ( | Process * | process | ) |
Construct with a process.
Definition at line 59 of file DynamicLoader.cpp.
|
inlinevirtual |
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.
The CFI instructions from the eh_frame section are normally only valid at call sites – places where a program could throw an exception and need to unwind out. But some Modules may be known to the system as having reliable eh_frame information at all call sites. This would be the case if the Module's contents are largely hand-written assembly with hand-written eh_frame information. Normally when unwinding from a function at the beginning of a stack unwind lldb will examine the assembly instructions to understand how the stack frame is set up and where saved registers are stored. But with hand-written assembly this is not reliable enough – we need to consult those function's hand-written eh_frame information.
Reimplemented in DynamicLoaderPOSIXDYLD, and lldb_private::DynamicLoaderDarwin.
Definition at line 182 of file DynamicLoader.h.
Referenced by lldb_private::RegisterContextUnwind::GetFullUnwindPlanForFrame().
|
pure virtual |
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.
Implemented in DynamicLoaderMacOSXDYLD, DynamicLoaderDarwinKernel, DynamicLoaderMacOS, DynamicLoaderPOSIXDYLD, DynamicLoaderStatic, DynamicLoaderHexagonDYLD, lldb_private::DynamicLoaderWindowsDYLD, and lldb_private::wasm::DynamicLoaderWasmDYLD.
Referenced by PlatformPOSIX::EvaluateLibdlExpression().
|
pure virtual |
Called after attaching a process.
Allow DynamicLoader plug-ins to execute some code after attaching to a process.
Implemented in DynamicLoaderDarwinKernel, DynamicLoaderPOSIXDYLD, lldb_private::DynamicLoaderDarwin, DynamicLoaderStatic, DynamicLoaderHexagonDYLD, lldb_private::DynamicLoaderWindowsDYLD, and lldb_private::wasm::DynamicLoaderWasmDYLD.
Referenced by lldb_private::Process::CompleteAttach(), and lldb_private::Process::LoadCore().
|
pure virtual |
Called after launching a process.
Allow DynamicLoader plug-ins to execute some code after the process has stopped for the first time on launch.
Implemented in DynamicLoaderDarwinKernel, DynamicLoaderPOSIXDYLD, lldb_private::DynamicLoaderDarwin, DynamicLoaderStatic, DynamicLoaderHexagonDYLD, lldb_private::DynamicLoaderWindowsDYLD, and lldb_private::wasm::DynamicLoaderWasmDYLD.
Referenced by lldb_private::Process::LaunchPrivate().
|
inlinevirtual |
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.
If you want to set a breakpoint on one of these symbols, you really need to set it on all the equivalent symbols.
[in] | original_symbol | The symbol for which we are finding equivalences. |
[in] | module_list | The set of modules in which to search. |
[out] | equivalent_symbols | The equivalent symbol list - any equivalent symbols found are appended to this list. |
Reimplemented in lldb_private::DynamicLoaderDarwin.
Definition at line 146 of file DynamicLoader.h.
|
protected |
Definition at line 148 of file DynamicLoader.cpp.
References lldb_private::ModuleList::FindFirstModule(), lldb_private::Target::GetArchitecture(), lldb_private::Target::GetImages(), lldb_private::Target::GetOrCreateModule(), lldb_private::Process::GetTarget(), and m_process.
Referenced by LoadModuleAtAddress().
|
static |
Find a dynamic loader plugin for a given process.
Scans the installed DynamicLoader plug-ins and tries to find an instance that can be used to track image changes in process.
[in] | process | The process for which to try and locate a dynamic loader plug-in instance. |
[in] | plugin_name | An optional name of a specific dynamic loader plug-in that should be used. If empty, pick the best plug-in. |
Definition at line 32 of file DynamicLoader.cpp.
Referenced by lldb_private::ProcessWindows::GetDynamicLoader(), lldb_private::process_gdb_remote::ProcessGDBRemote::GetDynamicLoader(), and lldb_private::Process::GetDynamicLoader().
|
protected |
Definition at line 137 of file DynamicLoader.cpp.
References lldb_private::ObjectFile::GetSectionList().
Referenced by UnloadSectionsCommon().
|
inlinevirtual |
Get information about the shared cache for a process, if possible.
On some systems (e.g. Darwin based systems), a set of libraries that are common to most processes may be put in a single region of memory and mapped into every process, this is called the shared cache, as a performance optimization.
Many targets will not have the concept of a shared cache.
Depending on how the DynamicLoader gathers information about the shared cache, it may be able to only return basic information - like the UUID of the cache - or it may be able to return additional information about the cache.
[out] | base_address | The base address (load address) of the shared cache. LLDB_INVALID_ADDRESS if it cannot be determined. |
[out] | uuid | The UUID of the shared cache, if it can be determined. If the UUID cannot be fetched, IsValid() will be false. |
[out] | using_shared_cache | If this process is using a shared cache. If unknown, eLazyBoolCalculate is returned. |
[out] | private_shared_cache | A LazyBool indicating whether this process is using a private shared cache. If this information cannot be fetched, eLazyBoolCalculate. |
Reimplemented in DynamicLoaderMacOSXDYLD, and DynamicLoaderMacOS.
Definition at line 247 of file DynamicLoader.h.
References lldb_private::UUID::Clear(), lldb_private::eLazyBoolCalculate, and LLDB_INVALID_ADDRESS.
Referenced by ObjectFileMachO::GetProcessSharedCacheUUID().
|
pure virtual |
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. |
Implemented in lldb_private::DynamicLoaderWindowsDYLD, lldb_private::wasm::DynamicLoaderWasmDYLD, DynamicLoaderDarwinKernel, DynamicLoaderPOSIXDYLD, lldb_private::DynamicLoaderDarwin, DynamicLoaderStatic, and DynamicLoaderHexagonDYLD.
Referenced by lldb_private::ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC().
bool DynamicLoader::GetStopWhenImagesChange | ( | ) | const |
Get whether the process should stop when images change.
When images (executables and shared libraries) get loaded or unloaded, often debug sessions will want to try and resolve or unresolve breakpoints that are set in these images. Any breakpoints set by DynamicLoader plug-in instances should return this value to ensure consistent debug session behaviour.
Definition at line 64 of file DynamicLoader.cpp.
References lldb_private::ProcessProperties::GetStopOnSharedLibraryEvents(), and m_process.
Referenced by DynamicLoaderDarwinKernel::BreakpointHit(), DynamicLoaderMacOS::NotifyBreakpointHit(), DynamicLoaderMacOSXDYLD::NotifyBreakpointHit(), DynamicLoaderHexagonDYLD::RendezvousBreakpointHit(), and DynamicLoaderPOSIXDYLD::RendezvousBreakpointHit().
|
protected |
Checks to see if the target module has changed, updates the target accordingly and returns the target executable module.
Definition at line 72 of file DynamicLoader.cpp.
References lldb_private::eLoadDependentsNo, lldb_private::Target::GetExecutableModule(), lldb_private::Target::GetExecutableModulePointer(), lldb_private::Target::GetOrCreateModule(), lldb_private::Process::GetTarget(), lldb_private::FileSystem::Instance(), m_process, and lldb_private::Target::SetExecutableModule().
Referenced by DynamicLoaderPOSIXDYLD::DidAttach(), DynamicLoaderPOSIXDYLD::DidLaunch(), and DynamicLoaderPOSIXDYLD::LoadAllCurrentModules().
|
inlinevirtual |
Retrieves the per-module TLS block for a given thread.
[in] | module | The module to query TLS data for. |
[in] | thread | The specific thread to query TLS data for. |
Reimplemented in DynamicLoaderPOSIXDYLD, lldb_private::DynamicLoaderDarwin, and DynamicLoaderHexagonDYLD.
Definition at line 198 of file DynamicLoader.h.
References LLDB_INVALID_ADDRESS.
Referenced by lldb_private::Thread::GetThreadLocalData().
|
inlinevirtual |
Return whether the dynamic loader is fully initialized and it's safe to call its APIs.
On some systems (e.g. Darwin based systems), lldb will get notified by the dynamic loader before it itself finished initializing and it's not safe to call certain APIs or SPIs.
Reimplemented in DynamicLoaderMacOSXDYLD.
Definition at line 263 of file DynamicLoader.h.
|
virtual |
Locates or creates a module given by file
and updates/loads the resulting module at the virtual base address base_addr
.
Note that this calls Target::GetOrCreateModule with notify being false, so it is necessary to call Target::ModulesDidLoad afterwards.
Reimplemented in DynamicLoaderPOSIXDYLD, and lldb_private::wasm::DynamicLoaderWasmDYLD.
Definition at line 161 of file DynamicLoader.cpp.
References FindModuleViaTarget(), and UpdateLoadedSections().
Referenced by DynamicLoaderHexagonDYLD::LoadAllCurrentModules(), lldb_private::process_gdb_remote::ProcessGDBRemote::LoadModuleAtAddress(), and DynamicLoaderHexagonDYLD::RefreshModules().
|
protected |
Definition at line 194 of file DynamicLoader.cpp.
References lldb_private::Process::LoadOperatingSystemPlugin(), and m_process.
Referenced by DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded().
|
inlinevirtual |
Helper function that can be used to detect when a process has called exec and is now a new and different process.
This can be called when necessary to try and detect the exec. The process might be able to answer this question, but sometimes it might not be able and the dynamic loader often knows what the program entry point is. So the process and the dynamic loader can work together to detect this.
Reimplemented in DynamicLoaderMacOSXDYLD, and DynamicLoaderMacOS.
Definition at line 90 of file DynamicLoader.h.
Referenced by lldb_private::StopInfoMachException::CreateStopReasonWithMachException().
|
protected |
Definition at line 185 of file DynamicLoader.cpp.
References error(), LLDB_INVALID_ADDRESS, m_process, and lldb_private::Process::ReadPointerFromMemory().
Referenced by DynamicLoaderHexagonDYLD::GetThreadLocalData(), and DynamicLoaderPOSIXDYLD::GetThreadLocalData().
|
protected |
Definition at line 174 of file DynamicLoader.cpp.
References error(), m_process, and lldb_private::Process::ReadUnsignedIntegerFromMemory().
Referenced by DynamicLoaderPOSIXDYLD::GetEntryPoint(), and DynamicLoaderPOSIXDYLD::GetThreadLocalData().
void DynamicLoader::SetStopWhenImagesChange | ( | bool | stop | ) |
Set whether the process should stop when images change.
When images (executables and shared libraries) get loaded or unloaded, often debug sessions will want to try and resolve or unresolve breakpoints that are set in these images. The default is set so that the process stops when images change, but this can be overridden using this function callback.
[in] | stop | Boolean value that indicates whether the process should stop when images change. |
Definition at line 68 of file DynamicLoader.cpp.
References m_process, and lldb_private::ProcessProperties::SetStopOnSharedLibraryEvents().
|
protectedvirtual |
Removes the loaded sections from the target in module
.
module | The module to traverse. |
Reimplemented in DynamicLoaderPOSIXDYLD, and DynamicLoaderHexagonDYLD.
Definition at line 119 of file DynamicLoader.cpp.
References UnloadSectionsCommon().
Referenced by lldb_private::DynamicLoaderDarwin::UnloadAllImages(), and lldb_private::DynamicLoaderDarwin::UnloadImages().
|
protected |
Definition at line 123 of file DynamicLoader.cpp.
References lldb_private::SectionList::GetSectionAtIndex(), GetSectionListFromModule(), lldb_private::SectionList::GetSize(), lldb_private::Process::GetTarget(), m_process, and lldb_private::Target::SetSectionUnloaded().
Referenced by DynamicLoaderPOSIXDYLD::UnloadSections(), and UnloadSections().
|
protectedvirtual |
Updates the load address of every allocatable section in module
.
module | The module to traverse. |
link_map_addr | The virtual address of the link map for the module . |
base_addr | The virtual base address module is loaded at. |
Reimplemented in DynamicLoaderPOSIXDYLD, and DynamicLoaderHexagonDYLD.
Definition at line 105 of file DynamicLoader.cpp.
References UpdateLoadedSectionsCommon().
Referenced by LoadModuleAtAddress().
|
protected |
Definition at line 111 of file DynamicLoader.cpp.
References lldb_private::Process::GetTarget(), and m_process.
Referenced by DynamicLoaderPOSIXDYLD::UpdateLoadedSections(), and UpdateLoadedSections().
|
protected |
The process that this dynamic loader plug-in is tracking.
Definition at line 317 of file DynamicLoader.h.
Referenced by DynamicLoaderMacOS::AddBinaries(), lldb_private::DynamicLoaderDarwin::AddModulesUsingImageInfos(), DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfosAddress(), lldb_private::DynamicLoaderDarwin::AlwaysRelyOnEHUnwindInfo(), DynamicLoaderMacOS::CanLoadImage(), lldb_private::DynamicLoaderDarwin::Clear(), DynamicLoaderDarwinKernel::Clear(), DynamicLoaderMacOS::ClearNotificationBreakpoint(), DynamicLoaderMacOSXDYLD::ClearNotificationBreakpoint(), DynamicLoaderPOSIXDYLD::ComputeLoadOffset(), DynamicLoaderHexagonDYLD::DidAttach(), lldb_private::DynamicLoaderDarwin::DidAttach(), DynamicLoaderPOSIXDYLD::DidAttach(), DynamicLoaderDarwinKernel::DidAttach(), lldb_private::DynamicLoaderDarwin::DidLaunch(), DynamicLoaderPOSIXDYLD::DidLaunch(), DynamicLoaderDarwinKernel::DidLaunch(), DynamicLoaderMacOS::DoClear(), DynamicLoaderMacOSXDYLD::DoClear(), DynamicLoaderMacOS::DoInitialImageFetch(), DynamicLoaderMacOSXDYLD::DoInitialImageFetch(), DynamicLoaderPOSIXDYLD::EntryBreakpointHit(), FindModuleViaTarget(), lldb_private::DynamicLoaderDarwin::FindTargetModuleForImageInfo(), DynamicLoaderMacOS::GetDyldLockVariableAddressFromModule(), DynamicLoaderHexagonDYLD::GetEntryPoint(), DynamicLoaderPOSIXDYLD::GetEntryPoint(), lldb_private::DynamicLoaderDarwin::GetPThreadLibraryModule(), DynamicLoaderMacOS::GetSharedCacheInformation(), DynamicLoaderMacOSXDYLD::GetSharedCacheInformation(), GetStopWhenImagesChange(), DynamicLoaderHexagonDYLD::GetTargetExecutable(), GetTargetExecutable(), DynamicLoaderHexagonDYLD::GetThreadLocalData(), lldb_private::DynamicLoaderDarwin::GetThreadLocalData(), DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos(), DynamicLoaderHexagonDYLD::LoadAllCurrentModules(), DynamicLoaderPOSIXDYLD::LoadAllCurrentModules(), DynamicLoaderStatic::LoadAllImagesAtFileAddresses(), DynamicLoaderPOSIXDYLD::LoadInterpreterModule(), DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded(), DynamicLoaderPOSIXDYLD::LoadModuleAtAddress(), LoadOperatingSystemPlugin(), DynamicLoaderPOSIXDYLD::LoadVDSO(), DynamicLoaderMacOS::NotifyBreakpointHit(), DynamicLoaderMacOSXDYLD::NotifyBreakpointHit(), DynamicLoaderDarwinKernel::ParseKextSummaries(), lldb_private::DynamicLoaderDarwin::PrivateInitialize(), DynamicLoaderDarwinKernel::PrivateInitialize(), lldb_private::DynamicLoaderDarwin::PrivateProcessStateChanged(), DynamicLoaderPOSIXDYLD::ProbeEntry(), DynamicLoaderMacOS::ProcessDidExec(), DynamicLoaderMacOSXDYLD::ProcessDidExec(), DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure(), DynamicLoaderMacOSXDYLD::ReadDYLDInfoFromMemoryAndSetNotificationCallback(), DynamicLoaderMacOSXDYLD::ReadImageInfos(), DynamicLoaderDarwinKernel::ReadKextSummaries(), DynamicLoaderDarwinKernel::ReadKextSummaryHeader(), DynamicLoaderMacOSXDYLD::ReadMachHeader(), ReadPointer(), ReadUnsignedIntWithSizeInBytes(), DynamicLoaderHexagonDYLD::RefreshModules(), DynamicLoaderPOSIXDYLD::RefreshModules(), DynamicLoaderMacOSXDYLD::RemoveModulesUsingImageInfosAddress(), DynamicLoaderHexagonDYLD::RendezvousBreakpointHit(), DynamicLoaderPOSIXDYLD::RendezvousBreakpointHit(), DynamicLoaderPOSIXDYLD::ResolveExecutableModule(), DynamicLoaderMacOS::SetNotificationBreakpoint(), DynamicLoaderMacOSXDYLD::SetNotificationBreakpoint(), DynamicLoaderDarwinKernel::SetNotificationBreakpointIfNeeded(), DynamicLoaderHexagonDYLD::SetRendezvousBreakpoint(), DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint(), SetStopWhenImagesChange(), lldb_private::DynamicLoaderDarwin::UnloadAllImages(), lldb_private::DynamicLoaderDarwin::UnloadImages(), lldb_private::DynamicLoaderDarwin::UnloadModuleSections(), DynamicLoaderHexagonDYLD::UnloadSections(), UnloadSectionsCommon(), lldb_private::DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(), DynamicLoaderMacOSXDYLD::UpdateImageInfosHeaderAndLoadCommands(), lldb_private::DynamicLoaderDarwin::UpdateImageLoadAddress(), DynamicLoaderHexagonDYLD::UpdateLoadedSections(), UpdateLoadedSectionsCommon(), lldb_private::DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(), DynamicLoaderHexagonDYLD::~DynamicLoaderHexagonDYLD(), DynamicLoaderMacOS::~DynamicLoaderMacOS(), DynamicLoaderMacOSXDYLD::~DynamicLoaderMacOSXDYLD(), and DynamicLoaderPOSIXDYLD::~DynamicLoaderPOSIXDYLD().