LLDB mainline
|
#include <DynamicLoaderMacOS.h>
Public Member Functions | |
DynamicLoaderMacOS (lldb_private::Process *process) | |
~DynamicLoaderMacOS () override | |
bool | ProcessDidExec () override |
Called after attaching a process. | |
lldb_private::Status | CanLoadImage () override |
Ask if it is ok to try and load or unload an shared library (image). | |
bool | GetSharedCacheInformation (lldb::addr_t &base_address, lldb_private::UUID &uuid, lldb_private::LazyBool &using_shared_cache, lldb_private::LazyBool &private_shared_cache) override |
Get information about the shared cache for a process, if possible. | |
llvm::StringRef | GetPluginName () override |
![]() | |
DynamicLoaderDarwin (lldb_private::Process *process) | |
~DynamicLoaderDarwin () 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. | |
void | FindEquivalentSymbols (lldb_private::Symbol *original_symbol, lldb_private::ModuleList &module_list, lldb_private::SymbolContextList &equivalent_symbols) override |
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. | |
lldb::addr_t | GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr) override |
Retrieves the per-module TLS block for a given thread. | |
bool | AlwaysRelyOnEHUnwindInfo (lldb_private::SymbolContext &sym_ctx) override |
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 void | DoInitialImageFetch ()=0 |
virtual bool | NeedToDoInitialImageFetch ()=0 |
![]() | |
DynamicLoader (Process *process) | |
Construct with a process. | |
virtual void | DidAttach ()=0 |
Called after attaching a process. | |
virtual void | DidLaunch ()=0 |
Called after launching 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 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. | |
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 Status | CanLoadImage ()=0 |
Ask if it is ok to try and load or unload an shared library (image). | |
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. | |
![]() | |
PluginInterface ()=default | |
virtual | ~PluginInterface ()=default |
virtual llvm::StringRef | GetPluginName ()=0 |
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 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) |
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 Member Functions | |
void | PutToLog (lldb_private::Log *log) const |
void | DoInitialImageFetch () override |
bool | NeedToDoInitialImageFetch () override |
bool | DidSetNotificationBreakpoint () override |
bool | SetDYLDHandoverBreakpoint (lldb::addr_t notification_address) |
void | ClearDYLDHandoverBreakpoint () |
void | AddBinaries (const std::vector< lldb::addr_t > &load_addresses) |
void | DoClear () override |
bool | IsFullyInitialized () override |
Return whether the dynamic loader is fully initialized and it's safe to call its APIs. | |
bool | SetNotificationBreakpoint () override |
void | ClearNotificationBreakpoint () override |
void | UpdateImageInfosHeaderAndLoadCommands (ImageInfo::collection &image_infos, uint32_t infos_count, bool update_executable) |
lldb::addr_t | GetDyldLockVariableAddressFromModule (lldb_private::Module *module) |
![]() | |
void | PrivateInitialize (lldb_private::Process *process) |
void | PrivateProcessStateChanged (lldb_private::Process *process, lldb::StateType state) |
void | Clear (bool clear_process) |
virtual void | DoClear ()=0 |
void | SetDYLDModule (lldb::ModuleSP &dyld_module_sp) |
lldb::ModuleSP | GetDYLDModule () |
void | ClearDYLDModule () |
bool | UpdateImageLoadAddress (lldb_private::Module *module, ImageInfo &info) |
bool | UnloadModuleSections (lldb_private::Module *module, ImageInfo &info) |
lldb::ModuleSP | FindTargetModuleForImageInfo (ImageInfo &image_info, bool can_create, bool *did_create_ptr) |
void | UnloadImages (const std::vector< lldb::addr_t > &solib_addresses) |
void | UnloadAllImages () |
virtual bool | SetNotificationBreakpoint ()=0 |
virtual void | ClearNotificationBreakpoint ()=0 |
virtual bool | DidSetNotificationBreakpoint ()=0 |
std::recursive_mutex & | GetMutex () const |
lldb::ModuleSP | GetPThreadLibraryModule () |
lldb_private::Address | GetPthreadSetSpecificAddress () |
bool | JSONImageInformationIntoImageInfo (lldb_private::StructuredData::ObjectSP image_details, ImageInfo::collection &image_infos) |
void | UpdateSpecialBinariesFromNewImageInfos (ImageInfo::collection &image_infos) |
void | UpdateDYLDImageInfoFromNewImageInfo (ImageInfo &image_info) |
void | AddExecutableModuleIfInImageInfos (ImageInfo::collection &image_infos) |
bool | AddModulesUsingImageInfos (ImageInfo::collection &image_infos) |
![]() | |
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. | |
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 . | |
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 . | |
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) |
Static Protected Member Functions | |
static bool | NotifyBreakpointHit (void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id) |
![]() | |
static bool | UseDYLDSPI (lldb_private::Process *process) |
Protected Attributes | |
uint32_t | m_image_infos_stop_id |
lldb::user_id_t | m_break_id |
lldb::user_id_t | m_dyld_handover_break_id |
std::recursive_mutex | m_mutex |
lldb::addr_t | m_maybe_image_infos_address |
bool | m_libsystem_fully_initalized |
![]() | |
lldb::ModuleWP | m_dyld_module_wp |
lldb::ModuleWP | m_libpthread_module_wp |
lldb_private::Address | m_pthread_getspecific_addr |
ThreadIDToTLSMap | m_tid_to_tls_map |
ImageInfo::collection | m_dyld_image_infos |
uint32_t | m_dyld_image_infos_stop_id |
ImageInfo | m_dyld |
std::recursive_mutex | m_mutex |
![]() | |
Process * | m_process |
The process that this dynamic loader plug-in is tracking. | |
Additional Inherited Members | |
![]() | |
typedef std::map< uint64_t, lldb::addr_t > | PthreadKeyToTLSMap |
typedef std::map< lldb::user_id_t, PthreadKeyToTLSMap > | ThreadIDToTLSMap |
Definition at line 31 of file DynamicLoaderMacOS.h.
DynamicLoaderMacOS::DynamicLoaderMacOS | ( | lldb_private::Process * | process | ) |
Definition at line 78 of file DynamicLoaderMacOS.cpp.
|
override |
Definition at line 86 of file DynamicLoaderMacOS.cpp.
References lldb_private::Process::GetTarget(), LLDB_BREAK_ID_IS_VALID, m_break_id, m_dyld_handover_break_id, lldb_private::DynamicLoader::m_process, and lldb_private::Target::RemoveBreakpointByID().
|
protected |
Definition at line 387 of file DynamicLoaderMacOS.cpp.
References lldb_private::DynamicLoaderDarwin::AddModulesUsingImageInfos(), lldb_private::Process::GetLoadedDynamicLibrariesInfos(), lldb_private::GetLog(), lldb_private::Process::GetStopID(), lldb_private::DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(), LLDB_LOGF, lldb_private::DynamicLoaderDarwin::m_dyld_image_infos_stop_id, lldb_private::DynamicLoader::m_process, and lldb_private::DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos().
Referenced by NotifyBreakpointHit().
|
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 494 of file DynamicLoaderMacOS.cpp.
References error(), GetDyldLockVariableAddressFromModule(), lldb_private::Target::GetImages(), lldb_private::ModuleList::GetMutex(), lldb_private::ModuleList::GetSize(), lldb_private::Process::GetTarget(), LLDB_INVALID_ADDRESS, lldb_private::DynamicLoader::m_process, lldb_private::ModuleList::Modules(), lldb_private::ModuleList::ModulesNoLocking(), and lldb_private::Process::ReadUnsignedIntegerFromMemory().
|
protected |
Definition at line 461 of file DynamicLoaderMacOS.cpp.
References lldb_private::Process::GetTarget(), LLDB_BREAK_ID_IS_VALID, LLDB_INVALID_BREAK_ID, m_dyld_handover_break_id, lldb_private::DynamicLoader::m_process, and lldb_private::Target::RemoveBreakpointByID().
Referenced by NotifyBreakpointHit().
|
overrideprotectedvirtual |
Implements lldb_private::DynamicLoaderDarwin.
Definition at line 183 of file DynamicLoaderMacOS.cpp.
References lldb_private::Process::GetTarget(), LLDB_BREAK_ID_IS_VALID, LLDB_INVALID_BREAK_ID, m_break_id, lldb_private::DynamicLoader::m_process, and lldb_private::Target::RemoveBreakpointByID().
Referenced by NotifyBreakpointHit().
|
static |
Definition at line 36 of file DynamicLoaderMacOS.cpp.
References lldb_private::ObjectFile::eStrataUser, lldb_private::Target::GetArchitecture(), lldb_private::Target::GetExecutableModulePointer(), lldb_private::Module::GetObjectFile(), lldb_private::ObjectFile::GetStrata(), lldb_private::Process::GetTarget(), lldb_private::ArchSpec::GetTriple(), and lldb_private::DynamicLoaderDarwin::UseDYLDSPI().
Referenced by Initialize(), and Terminate().
|
overrideprotectedvirtual |
Implements lldb_private::DynamicLoaderDarwin.
Definition at line 179 of file DynamicLoaderMacOS.cpp.
References LLDB_BREAK_ID_IS_VALID, and m_break_id.
|
overrideprotectedvirtual |
Implements lldb_private::DynamicLoaderDarwin.
Definition at line 139 of file DynamicLoaderMacOS.cpp.
References lldb_private::Process::GetTarget(), LLDB_BREAK_ID_IS_VALID, LLDB_INVALID_BREAK_ID, m_break_id, m_dyld_handover_break_id, m_libsystem_fully_initalized, m_mutex, lldb_private::DynamicLoader::m_process, and lldb_private::Target::RemoveBreakpointByID().
|
overrideprotectedvirtual |
Implements lldb_private::DynamicLoaderDarwin.
Definition at line 194 of file DynamicLoaderMacOS.cpp.
References lldb_private::DynamicLoaderDarwin::AddModulesUsingImageInfos(), lldb_private::Process::GetImageInfoAddress(), lldb_private::Process::GetLoadedDynamicLibrariesInfos(), lldb_private::GetLog(), lldb_private::Process::GetStopID(), lldb_private::DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(), LLDB_LOGF, lldb_private::DynamicLoaderDarwin::m_dyld_image_infos_stop_id, m_maybe_image_infos_address, lldb_private::DynamicLoader::m_process, lldb_private::DynamicLoaderDarwin::UnloadAllImages(), and lldb_private::DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos().
Referenced by NotifyBreakpointHit().
|
protected |
Definition at line 468 of file DynamicLoaderMacOS.cpp.
References lldb_private::Symbol::GetAddressRef(), lldb_private::Address::GetOpcodeLoadAddress(), lldb_private::Module::GetSymtab(), lldb_private::Process::GetTarget(), lldb_private::Address::IsValid(), LLDB_INVALID_ADDRESS, lldb_private::DynamicLoader::m_process, and lldb_private::Symbol::ValueIsAddress().
Referenced by CanLoadImage().
|
static |
Definition at line 603 of file DynamicLoaderMacOS.cpp.
Referenced by Initialize().
|
inlineoverridevirtual |
Implements lldb_private::PluginInterface.
Definition at line 63 of file DynamicLoaderMacOS.h.
References GetPluginNameStatic().
|
inlinestatic |
Definition at line 42 of file DynamicLoaderMacOS.h.
Referenced by GetPluginName(), and Initialize().
|
overridevirtual |
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 from lldb_private::DynamicLoader.
Definition at line 550 of file DynamicLoaderMacOS.cpp.
References lldb_private::UUID::Clear(), lldb_private::eLazyBoolCalculate, lldb_private::eLazyBoolNo, lldb_private::eLazyBoolYes, lldb_private::StructuredData::Object::GetAsDictionary(), lldb_private::Process::GetSharedCacheInfo(), lldb_private::StructuredData::Dictionary::GetValueForKey(), lldb_private::StructuredData::Dictionary::HasKey(), LLDB_INVALID_ADDRESS, lldb_private::DynamicLoader::m_process, and lldb_private::UUID::SetFromStringRef().
|
static |
Definition at line 594 of file DynamicLoaderMacOS.cpp.
References CreateInstance(), GetPluginDescriptionStatic(), GetPluginNameStatic(), and lldb_private::PluginManager::RegisterPlugin().
Referenced by DynamicLoaderMacOSXDYLD::Initialize().
|
overrideprotectedvirtual |
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 from lldb_private::DynamicLoader.
Definition at line 152 of file DynamicLoaderMacOS.cpp.
References lldb_private::Process::GetDynamicLoaderProcessState(), m_libsystem_fully_initalized, and lldb_private::DynamicLoader::m_process.
|
overrideprotectedvirtual |
Implements lldb_private::DynamicLoaderDarwin.
Definition at line 226 of file DynamicLoaderMacOS.cpp.
|
staticprotected |
Definition at line 232 of file DynamicLoaderMacOS.cpp.
References AddBinaries(), lldb_private::ModuleList::Clear(), lldb_private::SectionLoadList::Clear(), ClearDYLDHandoverBreakpoint(), lldb_private::DynamicLoaderDarwin::ClearDYLDModule(), ClearNotificationBreakpoint(), DoInitialImageFetch(), lldb::eBasicTypeVoid, lldb::eEncodingUint, error(), lldb_private::StoppointCallbackContext::exe_ctx_ref, lldb_private::Process::GetABI(), lldb_private::ArchSpec::GetAddressByteSize(), lldb_private::Target::GetArchitecture(), lldb_private::Target::GetDebugger(), lldb_private::ScratchTypeSystemClang::GetForTarget(), lldb_private::UserID::GetID(), lldb_private::Process::GetImageInfoAddress(), lldb_private::Target::GetImages(), lldb_private::CompilerType::GetPointerType(), lldb_private::ExecutionContext::GetProcessPtr(), lldb_private::Value::GetScalar(), lldb_private::Target::GetSectionLoadList(), lldb_private::ModuleList::GetSize(), lldb_private::Process::GetStopID(), lldb_private::DynamicLoader::GetStopWhenImagesChange(), lldb_private::Process::GetTarget(), lldb_private::ExecutionContext::GetThreadRef(), lldb_private::ArchSpec::GetTriple(), lldb_private::ValueList::GetValueAtIndex(), LLDB_INVALID_ADDRESS, m_image_infos_stop_id, lldb_private::DynamicLoader::m_process, lldb_private::ValueList::PushValue(), lldb_private::Process::ReadPointerFromMemory(), lldb_private::Process::ReadUnsignedIntegerFromMemory(), lldb_private::Debugger::ReportWarning(), lldb_private::Value::SetCompilerType(), SetDYLDHandoverBreakpoint(), SetNotificationBreakpoint(), lldb_private::Value::SetValueType(), lldb_private::Scalar::UInt(), UINT32_MAX, lldb_private::Scalar::ULongLong(), lldb_private::DynamicLoaderDarwin::UnloadAllImages(), and lldb_private::DynamicLoaderDarwin::UnloadImages().
Referenced by SetDYLDHandoverBreakpoint(), and SetNotificationBreakpoint().
|
overridevirtual |
Called after attaching a process.
Allow DynamicLoader plug-ins to execute some code after attaching to a process.
Reimplemented from lldb_private::DynamicLoader.
Definition at line 93 of file DynamicLoaderMacOS.cpp.
References lldb_private::Address::Clear(), lldb_private::Process::GetImageInfoAddress(), lldb_private::DynamicLoaderDarwin::GetMutex(), lldb_private::Symbol::GetName(), lldb_private::ThreadList::GetSize(), lldb_private::ThreadList::GetThreadAtIndex(), lldb_private::Process::GetThreadList(), LLDB_INVALID_ADDRESS, lldb_private::DynamicLoaderDarwin::m_libpthread_module_wp, m_libsystem_fully_initalized, m_maybe_image_infos_address, lldb_private::DynamicLoader::m_process, and lldb_private::DynamicLoaderDarwin::m_pthread_getspecific_addr.
|
protected |
Definition at line 415 of file DynamicLoaderMacOS.cpp.
|
protected |
Definition at line 447 of file DynamicLoaderMacOS.cpp.
References lldb_private::Target::CreateBreakpoint(), lldb_private::Process::GetTarget(), LLDB_INVALID_BREAK_ID, m_dyld_handover_break_id, lldb_private::DynamicLoader::m_process, and NotifyBreakpointHit().
Referenced by NotifyBreakpointHit().
|
overrideprotectedvirtual |
Implements lldb_private::DynamicLoaderDarwin.
Definition at line 420 of file DynamicLoaderMacOS.cpp.
References lldb_private::Target::CreateBreakpoint(), lldb::eLanguageTypeC, lldb_private::eLazyBoolNo, lldb_private::DynamicLoaderDarwin::GetDYLDModule(), lldb_private::Stoppoint::GetID(), lldb_private::Process::GetTarget(), LLDB_INVALID_BREAK_ID, m_break_id, lldb_private::DynamicLoader::m_process, NotifyBreakpointHit(), lldb_private::Breakpoint::SetBreakpointKind(), and lldb_private::Breakpoint::SetCallback().
Referenced by NotifyBreakpointHit().
|
static |
Definition at line 599 of file DynamicLoaderMacOS.cpp.
References CreateInstance(), and lldb_private::PluginManager::UnregisterPlugin().
Referenced by DynamicLoaderMacOSXDYLD::Terminate().
|
protected |
|
protected |
Definition at line 102 of file DynamicLoaderMacOS.h.
Referenced by ClearNotificationBreakpoint(), DidSetNotificationBreakpoint(), DoClear(), SetNotificationBreakpoint(), and ~DynamicLoaderMacOS().
|
protected |
Definition at line 103 of file DynamicLoaderMacOS.h.
Referenced by ClearDYLDHandoverBreakpoint(), DoClear(), SetDYLDHandoverBreakpoint(), and ~DynamicLoaderMacOS().
|
protected |
Definition at line 100 of file DynamicLoaderMacOS.h.
Referenced by NotifyBreakpointHit().
|
protected |
Definition at line 111 of file DynamicLoaderMacOS.h.
Referenced by DoClear(), IsFullyInitialized(), and ProcessDidExec().
|
protected |
Definition at line 105 of file DynamicLoaderMacOS.h.
Referenced by DoInitialImageFetch(), and ProcessDidExec().
|
mutableprotected |
Definition at line 104 of file DynamicLoaderMacOS.h.
Referenced by DoClear().