LLDB  mainline
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
DynamicLoaderPOSIXDYLD Class Reference

#include <DynamicLoaderPOSIXDYLD.h>

Inheritance diagram for DynamicLoaderPOSIXDYLD:
Inheritance graph
[legend]
Collaboration diagram for DynamicLoaderPOSIXDYLD:
Collaboration graph
[legend]

Public Member Functions

 DynamicLoaderPOSIXDYLD (lldb_private::Process *process)
 
 ~DynamicLoaderPOSIXDYLD () override
 
void DidAttach () override
 Called after attaching a process. More...
 
void DidLaunch () override
 Called after launching a process. More...
 
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. More...
 
lldb_private::Status CanLoadImage () override
 Ask if it is ok to try and load or unload an shared library (image). More...
 
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. More...
 
llvm::StringRef GetPluginName () override
 
- Public Member Functions inherited from lldb_private::DynamicLoader
 DynamicLoader (Process *process)
 Construct with 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 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 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...
 
- Public Member Functions inherited from lldb_private::PluginInterface
 PluginInterface ()=default
 
virtual ~PluginInterface ()=default
 
 PluginInterface (const PluginInterface &)=delete
 
PluginInterfaceoperator= (const PluginInterface &)=delete
 

Static Public Member Functions

static void Initialize ()
 
static void Terminate ()
 
static llvm::StringRef GetPluginNameStatic ()
 
static llvm::StringRef GetPluginDescriptionStatic ()
 
static lldb_private::DynamicLoaderCreateInstance (lldb_private::Process *process, bool force)
 
- Static Public Member Functions inherited from lldb_private::DynamicLoader
static DynamicLoaderFindPlugin (Process *process, llvm::StringRef plugin_name)
 Find a dynamic loader plugin for a given process. More...
 

Protected Member Functions

bool SetRendezvousBreakpoint ()
 If possible sets a breakpoint on a function called by the runtime linker each time a module is loaded or unloaded. More...
 
void RefreshModules ()
 Helper method for RendezvousBreakpointHit. More...
 
void UpdateLoadedSections (lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset) override
 Updates the load address of every allocatable section in module. More...
 
void UnloadSections (const lldb::ModuleSP module) override
 Removes the loaded sections from the target in module. More...
 
void ProbeEntry ()
 Resolves the entry point for the current inferior process and sets a breakpoint at that address. More...
 
virtual void LoadAllCurrentModules ()
 Helper for the entry breakpoint callback. More...
 
void LoadVDSO ()
 
lldb::ModuleSP LoadInterpreterModule ()
 
lldb::addr_t ComputeLoadOffset ()
 Computes a value for m_load_offset returning the computed address on success and LLDB_INVALID_ADDRESS on failure. More...
 
lldb::addr_t GetEntryPoint ()
 Computes a value for m_entry_point returning the computed address on success and LLDB_INVALID_ADDRESS on failure. More...
 
void EvalSpecialModulesStatus ()
 Evaluate if Aux vectors contain vDSO and LD information in case they do, read and assign the address to m_vdso_base and m_interpreter_base. More...
 
void ResolveExecutableModule (lldb::ModuleSP &module_sp)
 Loads Module from inferior process. More...
 
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. More...
 
- Protected Member Functions inherited from lldb_private::DynamicLoader
lldb::ModuleSP GetTargetExecutable ()
 Checks to see if the target module has changed, updates the target accordingly and returns the target executable module. More...
 
void UpdateLoadedSectionsCommon (lldb::ModuleSP module, lldb::addr_t base_addr, bool base_addr_is_offset)
 
void UnloadSectionsCommon (const lldb::ModuleSP module)
 
const lldb_private::SectionListGetSectionListFromModule (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 RendezvousBreakpointHit (void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
 Callback routine which updates the current list of loaded modules based on the information supplied by the runtime linker. More...
 
static bool EntryBreakpointHit (void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
 Callback routine invoked when we hit the breakpoint on process entry. More...
 

Protected Attributes

DYLDRendezvous m_rendezvous
 Runtime linker rendezvous structure. More...
 
lldb::addr_t m_load_offset
 Virtual load address of the inferior process. More...
 
lldb::addr_t m_entry_point
 Virtual entry address of the inferior process. More...
 
std::unique_ptr< AuxVectorm_auxv
 Auxiliary vector of the inferior process. More...
 
lldb::break_id_t m_dyld_bid
 Rendezvous breakpoint. More...
 
lldb::addr_t m_vdso_base
 Contains AT_SYSINFO_EHDR, which means a vDSO has been mapped to the address space. More...
 
lldb::addr_t m_interpreter_base
 Contains AT_BASE, which means a dynamic loader has been mapped to the address space. More...
 
std::weak_ptr< lldb_private::Modulem_interpreter_module
 Contains the pointer to the interpret module, if loaded. More...
 
std::map< lldb::ModuleWP, lldb::addr_t, std::owner_less< lldb::ModuleWP > > m_loaded_modules
 Loaded module list. (link map for each module) More...
 
bool m_initial_modules_added
 Indicates whether the initial set of modules was reported added. More...
 
- Protected Attributes inherited from lldb_private::DynamicLoader
Processm_process
 The process that this dynamic loader plug-in is tracking. More...
 

Private Member Functions

 DynamicLoaderPOSIXDYLD (const DynamicLoaderPOSIXDYLD &)=delete
 
const DynamicLoaderPOSIXDYLDoperator= (const DynamicLoaderPOSIXDYLD &)=delete
 

Detailed Description

Definition at line 23 of file DynamicLoaderPOSIXDYLD.h.

Constructor & Destructor Documentation

◆ DynamicLoaderPOSIXDYLD() [1/2]

DynamicLoaderPOSIXDYLD::DynamicLoaderPOSIXDYLD ( lldb_private::Process process)

Definition at line 63 of file DynamicLoaderPOSIXDYLD.cpp.

◆ ~DynamicLoaderPOSIXDYLD()

DynamicLoaderPOSIXDYLD::~DynamicLoaderPOSIXDYLD ( )
override

◆ DynamicLoaderPOSIXDYLD() [2/2]

DynamicLoaderPOSIXDYLD::DynamicLoaderPOSIXDYLD ( const DynamicLoaderPOSIXDYLD )
privatedelete

Member Function Documentation

◆ AlwaysRelyOnEHUnwindInfo()

bool DynamicLoaderPOSIXDYLD::AlwaysRelyOnEHUnwindInfo ( lldb_private::SymbolContext sym_ctx)
overrideprotectedvirtual

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.

Returns
True if the symbol context should use eh_frame instructions unconditionally when unwinding from this frame. Else false, the normal lldb unwind behavior of only using eh_frame when the function appears in the middle of the stack.

Reimplemented from lldb_private::DynamicLoader.

Definition at line 786 of file DynamicLoaderPOSIXDYLD.cpp.

References lldb_private::SymbolContext::function, lldb_private::Function::GetAddressRange(), lldb_private::Symbol::GetAddressRef(), lldb_private::AddressRange::GetBaseAddress(), lldb_private::Address::GetModule(), and lldb_private::SymbolContext::symbol.

◆ CanLoadImage()

Status DynamicLoaderPOSIXDYLD::CanLoadImage ( )
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.

Returns
true if it is currently ok to try and load a shared library into the process, false otherwise.

Implements lldb_private::DynamicLoader.

Definition at line 200 of file DynamicLoaderPOSIXDYLD.cpp.

◆ ComputeLoadOffset()

addr_t DynamicLoaderPOSIXDYLD::ComputeLoadOffset ( )
protected

◆ CreateInstance()

DynamicLoader * DynamicLoaderPOSIXDYLD::CreateInstance ( lldb_private::Process process,
bool  force 
)
static

◆ DidAttach()

void DynamicLoaderPOSIXDYLD::DidAttach ( )
overridevirtual

◆ DidLaunch()

void DynamicLoaderPOSIXDYLD::DidLaunch ( )
overridevirtual

◆ EntryBreakpointHit()

bool DynamicLoaderPOSIXDYLD::EntryBreakpointHit ( void *  baton,
lldb_private::StoppointCallbackContext context,
lldb::user_id_t  break_id,
lldb::user_id_t  break_loc_id 
)
staticprotected

Callback routine invoked when we hit the breakpoint on process entry.

This routine is responsible for resolving the load addresses of all dependent modules required by the inferior and setting up the rendezvous breakpoint.

Definition at line 253 of file DynamicLoaderPOSIXDYLD.cpp.

References lldb_private::Target::GetBreakpointByID(), lldb_private::Process::GetID(), lldb_private::GetLogIfAnyCategoriesSet(), lldb_private::Process::GetTarget(), LIBLLDB_LOG_DYNAMIC_LOADER, LLDB_INVALID_PROCESS_ID, LLDB_LOGF, LoadAllCurrentModules(), lldb_private::DynamicLoader::m_process, and SetRendezvousBreakpoint().

Referenced by ProbeEntry().

◆ EvalSpecialModulesStatus()

void DynamicLoaderPOSIXDYLD::EvalSpecialModulesStatus ( )
protected

Evaluate if Aux vectors contain vDSO and LD information in case they do, read and assign the address to m_vdso_base and m_interpreter_base.

Definition at line 654 of file DynamicLoaderPOSIXDYLD.cpp.

References AuxVector::AUXV_AT_BASE, AuxVector::AUXV_AT_SYSINFO_EHDR, m_auxv, m_interpreter_base, and m_vdso_base.

Referenced by DidAttach(), and DidLaunch().

◆ GetEntryPoint()

addr_t DynamicLoaderPOSIXDYLD::GetEntryPoint ( )
protected

◆ GetPluginDescriptionStatic()

llvm::StringRef DynamicLoaderPOSIXDYLD::GetPluginDescriptionStatic ( )
static

Definition at line 41 of file DynamicLoaderPOSIXDYLD.cpp.

◆ GetPluginName()

llvm::StringRef DynamicLoaderPOSIXDYLD::GetPluginName ( )
inlineoverridevirtual

Implements lldb_private::PluginInterface.

Definition at line 56 of file DynamicLoaderPOSIXDYLD.h.

References GetPluginNameStatic().

◆ GetPluginNameStatic()

static llvm::StringRef DynamicLoaderPOSIXDYLD::GetPluginNameStatic ( )
inlinestatic

Definition at line 33 of file DynamicLoaderPOSIXDYLD.h.

Referenced by ProcessElfCore::GetDynamicLoader(), and GetPluginName().

◆ GetStepThroughTrampolinePlan()

ThreadPlanSP DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan ( lldb_private::Thread thread,
bool  stop_others 
)
overridevirtual

◆ GetThreadLocalData()

lldb::addr_t DynamicLoaderPOSIXDYLD::GetThreadLocalData ( const lldb::ModuleSP  module,
const lldb::ThreadSP  thread,
lldb::addr_t  tls_file_addr 
)
overridevirtual

Retrieves the per-module TLS block for a given thread.

Parameters
[in]moduleThe module to query TLS data for.
[in]threadThe specific thread to query TLS data for.
Returns
If the given thread has TLS data allocated for the module, the address of the TLS block. Otherwise LLDB_INVALID_ADDRESS is returned.

Reimplemented from lldb_private::DynamicLoader.

Definition at line 688 of file DynamicLoaderPOSIXDYLD.cpp.

References DYLDRendezvous::ThreadInfo::dtv_offset, DYLDRendezvous::ThreadInfo::dtv_slot_size, lldb_private::GetLogIfAnyCategoriesSet(), DYLDRendezvous::GetThreadInfo(), LIBLLDB_LOG_DYNAMIC_LOADER, LLDB_INVALID_ADDRESS, LLDB_LOGF, m_loaded_modules, m_rendezvous, DYLDRendezvous::ThreadInfo::modid_offset, lldb_private::DynamicLoader::ReadPointer(), lldb_private::DynamicLoader::ReadUnsignedIntWithSizeInBytes(), DYLDRendezvous::ThreadInfo::tls_offset, and DYLDRendezvous::ThreadInfo::valid.

◆ Initialize()

void DynamicLoaderPOSIXDYLD::Initialize ( )
static

Definition at line 34 of file DynamicLoaderPOSIXDYLD.cpp.

◆ LoadAllCurrentModules()

void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules ( )
protectedvirtual

◆ LoadInterpreterModule()

ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule ( )
protected

◆ LoadVDSO()

void DynamicLoaderPOSIXDYLD::LoadVDSO ( )
protected

◆ operator=()

const DynamicLoaderPOSIXDYLD& DynamicLoaderPOSIXDYLD::operator= ( const DynamicLoaderPOSIXDYLD )
privatedelete

◆ ProbeEntry()

void DynamicLoaderPOSIXDYLD::ProbeEntry ( )
protected

◆ RefreshModules()

void DynamicLoaderPOSIXDYLD::RefreshModules ( )
protected

◆ RendezvousBreakpointHit()

bool DynamicLoaderPOSIXDYLD::RendezvousBreakpointHit ( void *  baton,
lldb_private::StoppointCallbackContext context,
lldb::user_id_t  break_id,
lldb::user_id_t  break_loc_id 
)
staticprotected

Callback routine which updates the current list of loaded modules based on the information supplied by the runtime linker.

Definition at line 383 of file DynamicLoaderPOSIXDYLD.cpp.

References lldb_private::Process::GetID(), lldb_private::GetLogIfAnyCategoriesSet(), lldb_private::DynamicLoader::GetStopWhenImagesChange(), LIBLLDB_LOG_DYNAMIC_LOADER, LLDB_INVALID_PROCESS_ID, LLDB_LOGF, lldb_private::DynamicLoader::m_process, and RefreshModules().

Referenced by SetRendezvousBreakpoint().

◆ ResolveExecutableModule()

void DynamicLoaderPOSIXDYLD::ResolveExecutableModule ( lldb::ModuleSP &  module_sp)
protected

◆ SetRendezvousBreakpoint()

bool DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint ( )
protected

◆ Terminate()

void DynamicLoaderPOSIXDYLD::Terminate ( )
static

Definition at line 39 of file DynamicLoaderPOSIXDYLD.cpp.

◆ UnloadSections()

void DynamicLoaderPOSIXDYLD::UnloadSections ( const lldb::ModuleSP  module)
overrideprotectedvirtual

Removes the loaded sections from the target in module.

Parameters
moduleThe module to traverse.

Reimplemented from lldb_private::DynamicLoader.

Definition at line 210 of file DynamicLoaderPOSIXDYLD.cpp.

References m_loaded_modules, and lldb_private::DynamicLoader::UnloadSectionsCommon().

Referenced by RefreshModules().

◆ UpdateLoadedSections()

void DynamicLoaderPOSIXDYLD::UpdateLoadedSections ( lldb::ModuleSP  module,
lldb::addr_t  link_map_addr,
lldb::addr_t  base_addr,
bool  base_addr_is_offset 
)
overrideprotectedvirtual

Updates the load address of every allocatable section in module.

Parameters
moduleThe module to traverse.
link_map_addrThe virtual address of the link map for the module.
base_addrThe virtual base address module is loaded at.

Reimplemented from lldb_private::DynamicLoader.

Definition at line 202 of file DynamicLoaderPOSIXDYLD.cpp.

References m_loaded_modules, and lldb_private::DynamicLoader::UpdateLoadedSectionsCommon().

Referenced by DidAttach(), DidLaunch(), LoadInterpreterModule(), and LoadVDSO().

Member Data Documentation

◆ m_auxv

std::unique_ptr<AuxVector> DynamicLoaderPOSIXDYLD::m_auxv
protected

Auxiliary vector of the inferior process.

Definition at line 69 of file DynamicLoaderPOSIXDYLD.h.

Referenced by DidAttach(), DidLaunch(), EvalSpecialModulesStatus(), and GetEntryPoint().

◆ m_dyld_bid

lldb::break_id_t DynamicLoaderPOSIXDYLD::m_dyld_bid
protected

Rendezvous breakpoint.

Definition at line 72 of file DynamicLoaderPOSIXDYLD.h.

Referenced by SetRendezvousBreakpoint(), and ~DynamicLoaderPOSIXDYLD().

◆ m_entry_point

lldb::addr_t DynamicLoaderPOSIXDYLD::m_entry_point
protected

Virtual entry address of the inferior process.

Definition at line 66 of file DynamicLoaderPOSIXDYLD.h.

Referenced by GetEntryPoint().

◆ m_initial_modules_added

bool DynamicLoaderPOSIXDYLD::m_initial_modules_added
protected

Indicates whether the initial set of modules was reported added.

Definition at line 100 of file DynamicLoaderPOSIXDYLD.h.

Referenced by LoadAllCurrentModules(), and RefreshModules().

◆ m_interpreter_base

lldb::addr_t DynamicLoaderPOSIXDYLD::m_interpreter_base
protected

Contains AT_BASE, which means a dynamic loader has been mapped to the address space.

Definition at line 80 of file DynamicLoaderPOSIXDYLD.h.

Referenced by EvalSpecialModulesStatus(), LoadInterpreterModule(), and RefreshModules().

◆ m_interpreter_module

std::weak_ptr<lldb_private::Module> DynamicLoaderPOSIXDYLD::m_interpreter_module
protected

Contains the pointer to the interpret module, if loaded.

Definition at line 83 of file DynamicLoaderPOSIXDYLD.h.

Referenced by LoadInterpreterModule(), and RefreshModules().

◆ m_load_offset

lldb::addr_t DynamicLoaderPOSIXDYLD::m_load_offset
protected

Virtual load address of the inferior process.

Definition at line 63 of file DynamicLoaderPOSIXDYLD.h.

Referenced by ComputeLoadOffset().

◆ m_loaded_modules

std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP> > DynamicLoaderPOSIXDYLD::m_loaded_modules
protected

Loaded module list. (link map for each module)

Definition at line 87 of file DynamicLoaderPOSIXDYLD.h.

Referenced by GetThreadLocalData(), LoadAllCurrentModules(), UnloadSections(), and UpdateLoadedSections().

◆ m_rendezvous

DYLDRendezvous DynamicLoaderPOSIXDYLD::m_rendezvous
protected

Runtime linker rendezvous structure.

Definition at line 60 of file DynamicLoaderPOSIXDYLD.h.

Referenced by DidAttach(), GetThreadLocalData(), LoadAllCurrentModules(), RefreshModules(), and SetRendezvousBreakpoint().

◆ m_vdso_base

lldb::addr_t DynamicLoaderPOSIXDYLD::m_vdso_base
protected

Contains AT_SYSINFO_EHDR, which means a vDSO has been mapped to the address space.

Definition at line 76 of file DynamicLoaderPOSIXDYLD.h.

Referenced by EvalSpecialModulesStatus(), and LoadVDSO().


The documentation for this class was generated from the following files: