Go to the documentation of this file.
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__,
234 llvm::Expected<LoadedModuleInfoList> module_list =
237 llvm::consumeError(module_list.takeError());
252 llvm_unreachable(
"Fully covered switch above!");
269 llvm_unreachable(
"Fully covered switch above!");
301 for (
auto const &modInfo : module_list.
m_list) {
319 for (
auto const &modInfo : module_list.
m_list) {
322 if (modInfo == existing) {
351 for (
auto const &modInfo : module_list.
m_list) {
352 if (modInfo == existing) {
419 pos = std::find(entry_list.begin(), entry_list.end(), *I);
420 if (pos == entry_list.end())
433 switch (triple.getOS()) {
434 case llvm::Triple::FreeBSD:
435 case llvm::Triple::NetBSD:
437 case llvm::Triple::Linux:
438 if (triple.isAndroid())
469 entry_list.push_back(entry);
513 unsigned os_major = target.
GetPlatform()->GetOSVersion().getMajor();
515 (os_major == 21 || os_major == 22) &&
516 (file_path ==
"/system/bin/linker" ||
517 file_path ==
"/system/bin/linker64");
526 bool is_loaded =
false;
529 if (
error.Success() && is_loaded)
543 FileSpec::Style::native);
559 if ((arch.
GetTriple().getOS() == llvm::Triple::FreeBSD ||
560 arch.
GetTriple().getOS() == llvm::Triple::NetBSD) &&
565 if (mips_l_offs != 0 && mips_l_offs != entry.
base_addr)
651 : (state ==
eAdd) ?
"add"
652 : (state ==
eDelete) ?
"delete" :
"unknown");
660 for (
int i = 1; I != E; ++I, ++i) {
661 LLDB_LOGF(log,
"\n SOEntry [%d] %s", i, I->file_spec.GetCString());
662 LLDB_LOGF(log,
" Base : %" PRIx64, I->base_addr);
663 LLDB_LOGF(log,
" Path : %" PRIx64, I->path_addr);
664 LLDB_LOGF(log,
" Dyn : %" PRIx64, I->dyn_addr);
665 LLDB_LOGF(log,
" Next : %" PRIx64, I->next);
666 LLDB_LOGF(log,
" Prev : %" PRIx64, I->prev);
SOEntryList m_added_soentries
List of SOEntry's added to the link map since the last call to Resolve().
bool SaveSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
MATCHES FreeBSD list(APPEND FBSDKERNEL_LIBS kvm) endif() if(NOT FBSDKERNEL_LIBS) message(STATUS "Skipping FreeBSDKernel plugin due to missing libfbsdvmcore") return() endif() add_lldb_library(lldbPluginProcessFreeBSDKernel PLUGIN ProcessFreeBSDKernel.cpp RegisterContextFreeBSDKernel_arm64.cpp RegisterContextFreeBSDKernel_i386.cpp RegisterContextFreeBSDKernel_x86_64.cpp ThreadFreeBSDKernel.cpp LINK_LIBS lldbCore lldbTarget $
static bool isLoadBiasIncorrect(Target &target, const std::string &file_path)
void UpdateExecutablePath()
Update the cached executable path.
lldb::addr_t GetLDBase() const
bool IsMIPS() const
if MIPS architecture return true.
bool IsValid() const
Check if the object state is valid.
lldb_private::Process * m_process
DYLDRendezvous(lldb_private::Process *process)
void UpdateFileSpecIfNecessary(SOEntry &entry)
bool SOEntryIsMainExecutable(const SOEntry &entry)
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Locate the memory region that contains load_addr.
SOEntryList::const_iterator iterator
#define LLDB_LOGF(log,...)
Module * GetExecutableModulePointer()
iterator begin() const
Iterators over all currently loaded modules.
virtual llvm::Expected< LoadedModuleInfoList > GetLoadedModuleList()
Query remote GDBServer for a detailed loaded library list.
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Target & GetTarget()
Get the target object pointer for this module.
static const size_t word_size
lldb::addr_t prev
Address of previous so_entry.
bool get_name(std::string &out) const
bool AddSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
lldb_private::FileSpec m_exe_file_spec
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
lldb::addr_t next
Address of next so_entry.
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.
llvm::Triple & GetTriple()
Architecture triple accessor.
lldb::addr_t ReadPointer(lldb::addr_t addr, lldb::addr_t *dst)
Reads an address from the inferior's address space starting at addr.
void DumpToLog(lldb_private::Log *log) const
std::string ReadStringFromMemory(lldb::addr_t addr)
Reads a null-terminated C string from the memory location starting at addr.
const ModuleList & GetImages() const
Get accessor for the images for this process.
lldb::addr_t base_addr
Base address of the loaded object.
const char * GetCString(bool denormalize=true) const
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
bool FindMetadata(const char *name, PThreadField field, uint32_t &value)
lldb::PlatformSP GetPlatform()
static llvm::raw_ostream & error(Stream &strm)
const ThreadInfo & GetThreadInfo()
void UpdateBaseAddrIfNecessary(SOEntry &entry, std::string const &file_path)
bool IsEmpty() const
Test for empty string.
lldb::addr_t GetBreakAddress() const
A breakpoint should be set at this address and Resolve called on each hit.
virtual lldb_private::Address GetImageInfoAddress(Target *target)
Similar to Process::GetImageInfoAddress().
uint32_t GetAddressByteSize() const
bool TakeSnapshot(SOEntryList &entry_list)
Reads the current list of shared objects according to the link map supplied by the runtime linker.
ConstString GetName() const
bool RemoveSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
bool get_link_map(lldb::addr_t &out) const
string(SUBSTRING ${p} 10 -1 pStripped) if($
bool get_base(lldb::addr_t &out) const
bool get_dynamic(lldb::addr_t &out) const
bool FillSOEntryFromModuleInfo(LoadedModuleInfoList::LoadedModuleInfo const &modInfo, SOEntry &entry)
ThreadInfo m_thread_info
Threading metadata read from the inferior.
const ArchSpec & GetArchitecture() const
bool UpdateSOEntriesFromRemote()
Same as UpdateSOEntries but it gets the list of loaded modules from the remote debug server (faster w...
bool ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
Reads an SOEntry starting at addr.
lldb::addr_t GetLinkMapAddress() const
lldb::addr_t GetRendezvousAddress() const
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
uint64_t GetVersion() const
lldb::addr_t ResolveRendezvousAddress()
Locates the address of the rendezvous structure.
#define LLDB_INVALID_ADDRESS
std::list< SOEntry > SOEntryList
std::vector< LoadedModuleInfo > m_list
LoadedModuleInfoList m_loaded_modules
List of currently loaded SO modules.
Rendezvous m_current
Current and previous snapshots of the rendezvous structure.
uint64_t GetState() const
Returns the current state of the rendezvous structure.
virtual lldb::addr_t GetImageInfoAddress()
Get the image information address for the current process.
A class that represents a running process on the host machine.
bool Resolve()
Update the internal snapshot of runtime linker rendezvous and recompute the currently loaded modules.
lldb::addr_t path_addr
String naming the shared object.
lldb_private::FileSpec file_spec
File spec of shared object.
lldb::addr_t link_addr
Address of this link_map.
lldb::addr_t dyn_addr
Dynamic section of shared object.
SOEntryList m_removed_soentries
List of SOEntry's removed from the link map since the last call to Resolve().
bool UpdateSOEntries()
Updates the current set of SOEntries, the set of added entries, and the set of removed entries.
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.
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.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
bool m_executable_interpreter
virtual Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, lldb::addr_t &load_addr)
Try to find the load address of a file.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
lldb::addr_t m_rendezvous_addr
Location of the r_debug structure in the inferiors address space.
SOEntryList m_soentries
List of SOEntry objects corresponding to the current link map state.
Structure representing the shared objects currently loaded into the inferior process.
RendezvousAction GetAction() const
Returns the current action to be taken given the current and previous state.
void PutCString(const char *cstr)
Address GetAddress() const