LLDB mainline
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
DYLDRendezvous Class Reference

Interface to the runtime linker. More...

#include <DYLDRendezvous.h>

Classes

struct  Rendezvous
 
struct  SOEntry
 Structure representing the shared objects currently loaded into the inferior process. More...
 
struct  ThreadInfo
 

Public Types

enum  RendezvousState { eConsistent , eAdd , eDelete }
 Constants describing the state of the rendezvous. More...
 
typedef SOEntryList::const_iterator iterator
 

Public Member Functions

 DYLDRendezvous (lldb_private::Process *process)
 
void UpdateExecutablePath ()
 Update the cached executable path.
 
bool Resolve ()
 Update the internal snapshot of runtime linker rendezvous and recompute the currently loaded modules.
 
bool IsValid ()
 
lldb::addr_t GetRendezvousAddress () const
 
uint64_t GetVersion () const
 
lldb::addr_t GetLinkMapAddress () const
 
lldb::addr_t GetBreakAddress () const
 A breakpoint should be set at this address and Resolve called on each hit.
 
uint64_t GetState () const
 Returns the current state of the rendezvous structure.
 
lldb::addr_t GetLDBase () const
 
const ThreadInfoGetThreadInfo ()
 
bool ModulesDidLoad () const
 
bool ModulesDidUnload () const
 
void DumpToLog (lldb_private::Log *log) const
 
iterator begin () const
 Iterators over all currently loaded modules.
 
iterator end () const
 
iterator loaded_begin () const
 Iterators over all modules loaded into the inferior since the last call to Resolve().
 
iterator loaded_end () const
 
iterator unloaded_begin () const
 Iterators over all modules unloaded from the inferior since the last call to Resolve().
 
iterator unloaded_end () const
 

Protected Types

enum  PThreadField { eSize , eNElem , eOffset }
 
enum  RendezvousAction { eNoAction , eTakeSnapshot , eAddModules , eRemoveModules }
 
typedef std::list< SOEntrySOEntryList
 

Protected Member Functions

lldb::addr_t ReadWord (lldb::addr_t addr, uint64_t *dst, size_t size)
 Reads an unsigned integer of size bytes from the inferior's address space starting at addr.
 
lldb::addr_t ReadPointer (lldb::addr_t addr, lldb::addr_t *dst)
 Reads an address from the inferior's address space starting at addr.
 
std::string ReadStringFromMemory (lldb::addr_t addr)
 Reads a null-terminated C string from the memory location starting at addr.
 
bool ReadSOEntryFromMemory (lldb::addr_t addr, SOEntry &entry)
 Reads an SOEntry starting at addr.
 
bool UpdateSOEntries ()
 Updates the current set of SOEntries, the set of added entries, and the set of removed entries.
 
bool UpdateSOEntriesFromRemote ()
 Same as UpdateSOEntries but it gets the list of loaded modules from the remote debug server (faster when supported).
 
bool FillSOEntryFromModuleInfo (LoadedModuleInfoList::LoadedModuleInfo const &modInfo, SOEntry &entry)
 
bool SaveSOEntriesFromRemote (const LoadedModuleInfoList &module_list)
 
bool AddSOEntriesFromRemote (const LoadedModuleInfoList &module_list)
 
bool RemoveSOEntriesFromRemote (const LoadedModuleInfoList &module_list)
 
bool AddSOEntries ()
 
bool RemoveSOEntries ()
 
void UpdateBaseAddrIfNecessary (SOEntry &entry, std::string const &file_path)
 
void UpdateFileSpecIfNecessary (SOEntry &entry)
 
bool SOEntryIsMainExecutable (const SOEntry &entry)
 
bool TakeSnapshot (SOEntryList &entry_list)
 Reads the current list of shared objects according to the link map supplied by the runtime linker.
 
bool FindMetadata (const char *name, PThreadField field, uint32_t &value)
 
bool IsCoreFile () const
 
RendezvousAction GetAction () const
 Returns the current action to be taken given the current and previous state.
 

Protected Attributes

lldb_private::Processm_process
 
lldb_private::FileSpec m_exe_file_spec
 
lldb::addr_t m_rendezvous_addr
 Location of the r_debug structure in the inferiors address space.
 
bool m_executable_interpreter
 
Rendezvous m_current
 Current and previous snapshots of the rendezvous structure.
 
Rendezvous m_previous
 
LoadedModuleInfoList m_loaded_modules
 List of currently loaded SO modules.
 
SOEntryList m_soentries
 List of SOEntry objects corresponding to the current link map state.
 
SOEntryList m_added_soentries
 List of SOEntry's added to the link map since the last call to Resolve().
 
SOEntryList m_removed_soentries
 List of SOEntry's removed from the link map since the last call to Resolve().
 
ThreadInfo m_thread_info
 Threading metadata read from the inferior.
 

Private Member Functions

lldb::addr_t ResolveRendezvousAddress ()
 Locates the address of the rendezvous structure.
 

Detailed Description

Interface to the runtime linker.

A structure is present in a processes memory space which is updated by the runtime liker each time a module is loaded or unloaded. This class provides an interface to this structure and maintains a consistent snapshot of the currently loaded modules.

Definition at line 34 of file DYLDRendezvous.h.

Member Typedef Documentation

◆ iterator

typedef SOEntryList::const_iterator DYLDRendezvous::iterator

Definition at line 167 of file DYLDRendezvous.h.

◆ SOEntryList

typedef std::list<SOEntry> DYLDRendezvous::SOEntryList
protected

Definition at line 164 of file DYLDRendezvous.h.

Member Enumeration Documentation

◆ PThreadField

Enumerator
eSize 
eNElem 
eOffset 

Definition at line 266 of file DYLDRendezvous.h.

◆ RendezvousAction

Enumerator
eNoAction 
eTakeSnapshot 
eAddModules 
eRemoveModules 

Definition at line 272 of file DYLDRendezvous.h.

◆ RendezvousState

Constants describing the state of the rendezvous.

See also
GetState().
Enumerator
eConsistent 
eAdd 
eDelete 

Definition at line 130 of file DYLDRendezvous.h.

Constructor & Destructor Documentation

◆ DYLDRendezvous()

DYLDRendezvous::DYLDRendezvous ( lldb_private::Process process)

Member Function Documentation

◆ AddSOEntries()

bool DYLDRendezvous::AddSOEntries ( )
protected

◆ AddSOEntriesFromRemote()

bool DYLDRendezvous::AddSOEntriesFromRemote ( const LoadedModuleInfoList module_list)
protected

◆ begin()

iterator DYLDRendezvous::begin ( ) const
inline

Iterators over all currently loaded modules.

Definition at line 170 of file DYLDRendezvous.h.

References m_soentries.

Referenced by DumpToLog(), DynamicLoaderPOSIXDYLD::LoadAllCurrentModules(), DynamicLoaderPOSIXDYLD::RefreshModules(), and RemoveSOEntries().

◆ DumpToLog()

void DYLDRendezvous::DumpToLog ( lldb_private::Log log) const

◆ end()

iterator DYLDRendezvous::end ( ) const
inline

◆ FillSOEntryFromModuleInfo()

bool DYLDRendezvous::FillSOEntryFromModuleInfo ( LoadedModuleInfoList::LoadedModuleInfo const &  modInfo,
SOEntry entry 
)
protected

◆ FindMetadata()

bool DYLDRendezvous::FindMetadata ( const char *  name,
PThreadField  field,
uint32_t value 
)
protected

◆ GetAction()

DYLDRendezvous::RendezvousAction DYLDRendezvous::GetAction ( ) const
protected

Returns the current action to be taken given the current and previous state.

Definition at line 192 of file DYLDRendezvous.cpp.

References eAdd, eAddModules, eConsistent, eDelete, eNoAction, eRemoveModules, eTakeSnapshot, IsCoreFile(), m_current, m_previous, and DYLDRendezvous::Rendezvous::state.

Referenced by UpdateSOEntries(), and UpdateSOEntriesFromRemote().

◆ GetBreakAddress()

lldb::addr_t DYLDRendezvous::GetBreakAddress ( ) const
inline

A breakpoint should be set at this address and Resolve called on each hit.

Returns
the address of a function called by the runtime linker each time a module is loaded/unloaded, or about to be loaded/unloaded.
See also
Resolve()

Definition at line 105 of file DYLDRendezvous.h.

References DYLDRendezvous::Rendezvous::brk, and m_current.

Referenced by DumpToLog(), and DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint().

◆ GetLDBase()

lldb::addr_t DYLDRendezvous::GetLDBase ( ) const
inline
Returns
the base address of the runtime linker in the inferiors address space.

Definition at line 112 of file DYLDRendezvous.h.

References DYLDRendezvous::Rendezvous::ldbase, and m_current.

Referenced by DumpToLog().

◆ GetLinkMapAddress()

lldb::addr_t DYLDRendezvous::GetLinkMapAddress ( ) const
inline
Returns
address in the inferiors address space containing the linked list of shared object descriptors.

Definition at line 96 of file DYLDRendezvous.h.

References m_current, and DYLDRendezvous::Rendezvous::map_addr.

Referenced by DumpToLog(), and DynamicLoaderPOSIXDYLD::LoadAllCurrentModules().

◆ GetRendezvousAddress()

lldb::addr_t DYLDRendezvous::GetRendezvousAddress ( ) const
inline
Returns
the address of the rendezvous structure in the inferiors address space.

Definition at line 89 of file DYLDRendezvous.h.

References m_rendezvous_addr.

Referenced by DumpToLog().

◆ GetState()

uint64_t DYLDRendezvous::GetState ( ) const
inline

Returns the current state of the rendezvous structure.

Definition at line 108 of file DYLDRendezvous.h.

References m_current, and DYLDRendezvous::Rendezvous::state.

Referenced by DumpToLog().

◆ GetThreadInfo()

const DYLDRendezvous::ThreadInfo & DYLDRendezvous::GetThreadInfo ( )

◆ GetVersion()

uint64_t DYLDRendezvous::GetVersion ( ) const
inline
Returns
the version of the rendezvous protocol being used.

Definition at line 92 of file DYLDRendezvous.h.

References m_current, and DYLDRendezvous::Rendezvous::version.

Referenced by DumpToLog().

◆ IsCoreFile()

bool DYLDRendezvous::IsCoreFile ( ) const
protected

Definition at line 676 of file DYLDRendezvous.cpp.

References lldb_private::Process::IsLiveDebugSession(), and m_process.

Referenced by GetAction().

◆ IsValid()

bool DYLDRendezvous::IsValid ( )
Returns
true if this rendezvous has been located in the inferiors address space and false otherwise.

Definition at line 188 of file DYLDRendezvous.cpp.

References LLDB_INVALID_ADDRESS, and m_rendezvous_addr.

Referenced by DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint().

◆ loaded_begin()

iterator DYLDRendezvous::loaded_begin ( ) const
inline

Iterators over all modules loaded into the inferior since the last call to Resolve().

Definition at line 175 of file DYLDRendezvous.h.

References m_added_soentries.

Referenced by DynamicLoaderPOSIXDYLD::RefreshModules().

◆ loaded_end()

iterator DYLDRendezvous::loaded_end ( ) const
inline

Definition at line 176 of file DYLDRendezvous.h.

References m_added_soentries.

Referenced by DynamicLoaderPOSIXDYLD::RefreshModules().

◆ ModulesDidLoad()

bool DYLDRendezvous::ModulesDidLoad ( ) const
inline
Returns
true if modules have been loaded into the inferior since the last call to Resolve().

Definition at line 119 of file DYLDRendezvous.h.

References m_added_soentries.

Referenced by DynamicLoaderPOSIXDYLD::RefreshModules().

◆ ModulesDidUnload()

bool DYLDRendezvous::ModulesDidUnload ( ) const
inline
Returns
true if modules have been unloaded from the inferior since the last call to Resolve().

Definition at line 123 of file DYLDRendezvous.h.

References m_removed_soentries.

Referenced by DynamicLoaderPOSIXDYLD::RefreshModules().

◆ ReadPointer()

addr_t DYLDRendezvous::ReadPointer ( lldb::addr_t  addr,
lldb::addr_t dst 
)
protected

Reads an address from the inferior's address space starting at addr.

Returns
addr + target address size if the read was successful and 0 otherwise.

Definition at line 491 of file DYLDRendezvous.cpp.

References error(), lldb_private::Process::GetAddressByteSize(), m_process, and lldb_private::Process::ReadPointerFromMemory().

Referenced by ReadSOEntryFromMemory(), and Resolve().

◆ ReadSOEntryFromMemory()

bool DYLDRendezvous::ReadSOEntryFromMemory ( lldb::addr_t  addr,
SOEntry entry 
)
protected

◆ ReadStringFromMemory()

std::string DYLDRendezvous::ReadStringFromMemory ( lldb::addr_t  addr)
protected

Reads a null-terminated C string from the memory location starting at addr.

Definition at line 501 of file DYLDRendezvous.cpp.

References error(), LLDB_INVALID_ADDRESS, m_process, and lldb_private::Process::ReadCStringFromMemory().

Referenced by ReadSOEntryFromMemory().

◆ ReadWord()

addr_t DYLDRendezvous::ReadWord ( lldb::addr_t  addr,
uint64_t *  dst,
size_t  size 
)
protected

Reads an unsigned integer of size bytes from the inferior's address space starting at addr.

Returns
addr + size if the read was successful and false otherwise.

Definition at line 481 of file DYLDRendezvous.cpp.

References error(), m_process, and lldb_private::Process::ReadUnsignedIntegerFromMemory().

Referenced by Resolve().

◆ RemoveSOEntries()

bool DYLDRendezvous::RemoveSOEntries ( )
protected

◆ RemoveSOEntriesFromRemote()

bool DYLDRendezvous::RemoveSOEntriesFromRemote ( const LoadedModuleInfoList module_list)
protected

◆ Resolve()

bool DYLDRendezvous::Resolve ( )

Update the internal snapshot of runtime linker rendezvous and recompute the currently loaded modules.

This method should be called once one start up, then once each time the runtime linker enters the function given by GetBreakAddress().

Returns
true on success and false on failure.
See also
GetBreakAddress().

Definition at line 132 of file DYLDRendezvous.cpp.

References DYLDRendezvous::Rendezvous::brk, lldb_private::Process::GetAddressByteSize(), lldb_private::GetLog(), DYLDRendezvous::Rendezvous::ldbase, LLDB_INVALID_ADDRESS, LLDB_LOGF, m_current, m_previous, m_process, m_rendezvous_addr, DYLDRendezvous::Rendezvous::map_addr, ReadPointer(), ReadWord(), ResolveRendezvousAddress(), DYLDRendezvous::Rendezvous::state, UpdateSOEntries(), UpdateSOEntriesFromRemote(), DYLDRendezvous::Rendezvous::version, and word_size.

Referenced by DynamicLoaderPOSIXDYLD::LoadAllCurrentModules(), and DynamicLoaderPOSIXDYLD::RefreshModules().

◆ ResolveRendezvousAddress()

addr_t DYLDRendezvous::ResolveRendezvousAddress ( )
private

◆ SaveSOEntriesFromRemote()

bool DYLDRendezvous::SaveSOEntriesFromRemote ( const LoadedModuleInfoList module_list)
protected

◆ SOEntryIsMainExecutable()

bool DYLDRendezvous::SOEntryIsMainExecutable ( const SOEntry entry)
protected

◆ TakeSnapshot()

bool DYLDRendezvous::TakeSnapshot ( SOEntryList entry_list)
protected

Reads the current list of shared objects according to the link map supplied by the runtime linker.

Definition at line 456 of file DYLDRendezvous.cpp.

References DYLDRendezvous::SOEntry::clear(), m_current, DYLDRendezvous::Rendezvous::map_addr, DYLDRendezvous::SOEntry::next, ReadSOEntryFromMemory(), SOEntryIsMainExecutable(), and UpdateFileSpecIfNecessary().

Referenced by RemoveSOEntries(), and UpdateSOEntries().

◆ unloaded_begin()

iterator DYLDRendezvous::unloaded_begin ( ) const
inline

Iterators over all modules unloaded from the inferior since the last call to Resolve().

Definition at line 180 of file DYLDRendezvous.h.

References m_removed_soentries.

Referenced by DynamicLoaderPOSIXDYLD::RefreshModules().

◆ unloaded_end()

iterator DYLDRendezvous::unloaded_end ( ) const
inline

Definition at line 181 of file DYLDRendezvous.h.

References m_removed_soentries.

Referenced by DynamicLoaderPOSIXDYLD::RefreshModules().

◆ UpdateBaseAddrIfNecessary()

void DYLDRendezvous::UpdateBaseAddrIfNecessary ( SOEntry entry,
std::string const &  file_path 
)
protected

◆ UpdateExecutablePath()

void DYLDRendezvous::UpdateExecutablePath ( )

◆ UpdateFileSpecIfNecessary()

void DYLDRendezvous::UpdateFileSpecIfNecessary ( SOEntry entry)
protected

◆ UpdateSOEntries()

bool DYLDRendezvous::UpdateSOEntries ( )
protected

Updates the current set of SOEntries, the set of added entries, and the set of removed entries.

Definition at line 263 of file DYLDRendezvous.cpp.

References AddSOEntries(), eAddModules, eNoAction, eRemoveModules, eTakeSnapshot, GetAction(), m_added_soentries, m_removed_soentries, m_soentries, RemoveSOEntries(), and TakeSnapshot().

Referenced by Resolve().

◆ UpdateSOEntriesFromRemote()

bool DYLDRendezvous::UpdateSOEntriesFromRemote ( )
protected

Member Data Documentation

◆ m_added_soentries

SOEntryList DYLDRendezvous::m_added_soentries
protected

List of SOEntry's added to the link map since the last call to Resolve().

Definition at line 207 of file DYLDRendezvous.h.

Referenced by AddSOEntries(), AddSOEntriesFromRemote(), loaded_begin(), loaded_end(), ModulesDidLoad(), UpdateSOEntries(), and UpdateSOEntriesFromRemote().

◆ m_current

Rendezvous DYLDRendezvous::m_current
protected

Current and previous snapshots of the rendezvous structure.

Definition at line 196 of file DYLDRendezvous.h.

Referenced by AddSOEntries(), GetAction(), GetBreakAddress(), GetLDBase(), GetLinkMapAddress(), GetState(), GetVersion(), Resolve(), and TakeSnapshot().

◆ m_exe_file_spec

lldb_private::FileSpec DYLDRendezvous::m_exe_file_spec
protected

Definition at line 187 of file DYLDRendezvous.h.

Referenced by SOEntryIsMainExecutable(), and UpdateExecutablePath().

◆ m_executable_interpreter

bool DYLDRendezvous::m_executable_interpreter
protected

Definition at line 193 of file DYLDRendezvous.h.

Referenced by ResolveRendezvousAddress(), and SOEntryIsMainExecutable().

◆ m_loaded_modules

LoadedModuleInfoList DYLDRendezvous::m_loaded_modules
protected

List of currently loaded SO modules.

Definition at line 200 of file DYLDRendezvous.h.

Referenced by AddSOEntriesFromRemote(), RemoveSOEntriesFromRemote(), SaveSOEntriesFromRemote(), and UpdateSOEntriesFromRemote().

◆ m_previous

Rendezvous DYLDRendezvous::m_previous
protected

Definition at line 197 of file DYLDRendezvous.h.

Referenced by AddSOEntries(), GetAction(), RemoveSOEntries(), and Resolve().

◆ m_process

lldb_private::Process* DYLDRendezvous::m_process
protected

◆ m_removed_soentries

SOEntryList DYLDRendezvous::m_removed_soentries
protected

List of SOEntry's removed from the link map since the last call to Resolve().

Definition at line 211 of file DYLDRendezvous.h.

Referenced by ModulesDidUnload(), RemoveSOEntries(), RemoveSOEntriesFromRemote(), unloaded_begin(), unloaded_end(), UpdateSOEntries(), and UpdateSOEntriesFromRemote().

◆ m_rendezvous_addr

lldb::addr_t DYLDRendezvous::m_rendezvous_addr
protected

Location of the r_debug structure in the inferiors address space.

Definition at line 190 of file DYLDRendezvous.h.

Referenced by GetRendezvousAddress(), IsValid(), and Resolve().

◆ m_soentries

SOEntryList DYLDRendezvous::m_soentries
protected

List of SOEntry objects corresponding to the current link map state.

Definition at line 203 of file DYLDRendezvous.h.

Referenced by AddSOEntries(), AddSOEntriesFromRemote(), begin(), end(), RemoveSOEntries(), RemoveSOEntriesFromRemote(), SaveSOEntriesFromRemote(), UpdateSOEntries(), and UpdateSOEntriesFromRemote().

◆ m_thread_info

ThreadInfo DYLDRendezvous::m_thread_info
protected

Threading metadata read from the inferior.

Definition at line 214 of file DYLDRendezvous.h.

Referenced by DYLDRendezvous(), and GetThreadInfo().


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