21#include "llvm/Support/Path.h"
30 m_executable_interpreter(false), m_current(), m_previous(),
31 m_loaded_modules(), m_soentries(), m_added_soentries(),
32 m_removed_soentries() {
38 Log *log =
GetLog(LLDBLog::DynamicLoader);
44 LLDB_LOGF(log,
"%s null process provided", __FUNCTION__);
51 LLDB_LOGF(log,
"%s info_location = 0x%" PRIx64, __FUNCTION__, info_location);
64 "%s resolved via direct object file approach to 0x%" PRIx64,
65 __FUNCTION__, info_location);
74 "%s resolved by finding symbol '_r_debug' whose value is "
76 __FUNCTION__, info_addr);
82 "%s FAILED - direct object file approach did not yield a "
90 LLDB_LOGF(log,
"%s FAILED - invalid info address", __FUNCTION__);
94 LLDB_LOGF(log,
"%s reading pointer (%" PRIu32
" bytes) from 0x%" PRIx64,
99 LLDB_LOGF(log,
"%s FAILED - could not read from the info location: %s",
100 __FUNCTION__,
error.AsCString());
104 if (info_addr == 0) {
106 "%s FAILED - the rendezvous address contained at 0x%" PRIx64
107 " returned a null value",
108 __FUNCTION__, info_location);
117 Log *log =
GetLog(LLDBLog::DynamicLoader);
121 LLDB_LOGF(log,
"DYLDRendezvous::%s exe module executable path set: '%s'",
125 "DYLDRendezvous::%s cannot cache exe module path: null "
126 "executable module pointer",
133 Log *log =
GetLog(LLDBLog::DynamicLoader);
145 "DYLDRendezvous::%s address size: %" PRIu64
", padding %" PRIu64,
146 __FUNCTION__, uint64_t(address_size), uint64_t(padding));
153 LLDB_LOGF(log,
"DYLDRendezvous::%s cursor = 0x%" PRIx64, __FUNCTION__,
242 llvm::Expected<LoadedModuleInfoList> module_list =
245 llvm::consumeError(module_list.takeError());
260 llvm_unreachable(
"Fully covered switch above!");
277 llvm_unreachable(
"Fully covered switch above!");
309 for (
auto const &modInfo : module_list.
m_list) {
327 for (
auto const &modInfo : module_list.
m_list) {
330 if (modInfo == existing) {
359 for (
auto const &modInfo : module_list.
m_list) {
360 if (modInfo == existing) {
426 if (!llvm::is_contained(entry_list, *I))
439 switch (triple.getOS()) {
440 case llvm::Triple::FreeBSD:
441 case llvm::Triple::NetBSD:
443 case llvm::Triple::Linux:
444 if (triple.isAndroid())
475 entry_list.push_back(entry);
506 return std::string();
519 unsigned os_major = target.
GetPlatform()->GetOSVersion().getMajor();
521 (os_major == 21 || os_major == 22) &&
522 (file_path ==
"/system/bin/linker" ||
523 file_path ==
"/system/bin/linker64");
527 std::string
const &file_path) {
532 bool is_loaded =
false;
535 if (
error.Success() && is_loaded)
549 FileSpec::Style::native);
565 if ((arch.
GetTriple().getOS() == llvm::Triple::FreeBSD ||
566 arch.
GetTriple().getOS() == llvm::Triple::NetBSD) &&
571 if (mips_l_offs != 0 && mips_l_offs != entry.
base_addr)
605 Address address = list[0].symbol->GetAddress();
657 : (state ==
eAdd) ?
"add"
658 : (state ==
eDelete) ?
"delete" :
"unknown");
666 for (
int i = 1; I != E; ++I, ++i) {
667 LLDB_LOGF(log,
"\n SOEntry [%d] %s", i, I->file_spec.GetPath().c_str());
668 LLDB_LOGF(log,
" Base : %" PRIx64, I->base_addr);
669 LLDB_LOGF(log,
" Path : %" PRIx64, I->path_addr);
670 LLDB_LOGF(log,
" Dyn : %" PRIx64, I->dyn_addr);
671 LLDB_LOGF(log,
" Next : %" PRIx64, I->next);
672 LLDB_LOGF(log,
" Prev : %" PRIx64, I->prev);
static const size_t word_size
static llvm::raw_ostream & error(Stream &strm)
static bool isLoadBiasIncorrect(Target &target, const std::string &file_path)
#define LLDB_LOGF(log,...)
bool FindMetadata(const char *name, PThreadField field, uint32_t &value)
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.
std::list< SOEntry > SOEntryList
bool ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
Reads an SOEntry starting at addr.
lldb::addr_t GetBreakAddress() const
A breakpoint should be set at this address and Resolve called on each hit.
lldb_private::Process * m_process
void UpdateExecutablePath()
Update the cached executable path.
bool UpdateSOEntries()
Updates the current set of SOEntries, the set of added entries, and the set of removed entries.
bool m_executable_interpreter
uint64_t GetState() const
Returns the current state of the rendezvous structure.
lldb::addr_t GetLinkMapAddress() const
DYLDRendezvous(lldb_private::Process *process)
LoadedModuleInfoList m_loaded_modules
List of currently loaded SO modules.
bool UpdateSOEntriesFromRemote()
Same as UpdateSOEntries but it gets the list of loaded modules from the remote debug server (faster w...
bool Resolve()
Update the internal snapshot of runtime linker rendezvous and recompute the currently loaded modules.
RendezvousAction GetAction() const
Returns the current action to be taken given the current and previous state.
bool AddSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
SOEntryList m_added_soentries
List of SOEntry's added to the link map since the last call to Resolve().
lldb::addr_t ResolveRendezvousAddress()
Locates the address of the rendezvous structure.
bool FillSOEntryFromModuleInfo(LoadedModuleInfoList::LoadedModuleInfo const &modInfo, SOEntry &entry)
lldb::addr_t m_rendezvous_addr
Location of the r_debug structure in the inferiors address space.
iterator begin() const
Iterators over all currently loaded modules.
SOEntryList m_soentries
List of SOEntry objects corresponding to the current link map state.
void DumpToLog(lldb_private::Log *log) const
uint64_t GetVersion() const
lldb_private::FileSpec m_exe_file_spec
const ThreadInfo & GetThreadInfo()
void UpdateBaseAddrIfNecessary(SOEntry &entry, std::string const &file_path)
lldb::addr_t GetLDBase() const
bool TakeSnapshot(SOEntryList &entry_list)
Reads the current list of shared objects according to the link map supplied by the runtime linker.
void UpdateFileSpecIfNecessary(SOEntry &entry)
bool SOEntryIsMainExecutable(const SOEntry &entry)
lldb::addr_t GetRendezvousAddress() const
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.
Rendezvous m_current
Current and previous snapshots of the rendezvous structure.
bool RemoveSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
SOEntryList m_removed_soentries
List of SOEntry's removed from the link map since the last call to Resolve().
bool SaveSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
SOEntryList::const_iterator iterator
ThreadInfo m_thread_info
Threading metadata read from the inferior.
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
bool IsValid() const
Check if the object state is valid.
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsMIPS() const
if MIPS architecture return true.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
bool IsEmpty() const
Test for empty string.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
bool get_name(std::string &out) const
bool get_link_map(lldb::addr_t &out) const
bool get_base(lldb::addr_t &out) const
bool get_dynamic(lldb::addr_t &out) const
std::vector< LoadedModuleInfo > m_list
void PutCString(const char *cstr)
ConstString GetName() const
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
A class that describes an executable image and its associated object and symbol files.
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
A plug-in interface definition class for object file parsers.
virtual lldb_private::Address GetImageInfoAddress(Target *target)
Similar to Process::GetImageInfoAddress().
A plug-in interface definition class for debugging a process.
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
virtual llvm::Expected< LoadedModuleInfoList > GetLoadedModuleList()
Query remote GDBServer for a detailed loaded library list.
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
virtual lldb::addr_t GetImageInfoAddress()
Get the image information address for the current process.
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
virtual Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, lldb::addr_t &load_addr)
Try to find the load address of a file.
uint32_t GetAddressByteSize() const
virtual bool IsLiveDebugSession() const
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Locate the memory region that contains load_addr.
Target & GetTarget()
Get the target object pointer for this module.
Defines a list of symbol context objects.
Address GetAddress() const
Module * GetExecutableModulePointer()
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
lldb::PlatformSP GetPlatform()
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Structure representing the shared objects currently loaded into the inferior process.
lldb::addr_t path_addr
String naming the shared object.
lldb::addr_t base_addr
Base address of the loaded object.
lldb::addr_t link_addr
Address of this link_map.
lldb_private::FileSpec file_spec
File spec of shared object.
lldb::addr_t prev
Address of previous so_entry.
lldb::addr_t next
Address of next so_entry.
lldb::addr_t dyn_addr
Dynamic section of shared object.