[Lldb-commits] [lldb] r245625 - Understand absolute base addresses in ProcessGDBRemote::GetLoadedModuleList.
Stephane Sezer via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 20 15:07:48 PDT 2015
Author: sas
Date: Thu Aug 20 17:07:48 2015
New Revision: 245625
URL: http://llvm.org/viewvc/llvm-project?rev=245625&view=rev
Log:
Understand absolute base addresses in ProcessGDBRemote::GetLoadedModuleList.
Summary:
This is useful when dealing with Windows remote that use only the
qXfer:libraries command which returns absolute base addresses, as
opposed to qXfer:libraries-svr4 which returns relative offsets for
module bases.
Reviewers: clayborg, zturner, ADodds
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D12204
Modified:
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=245625&r1=245624&r2=245625&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Aug 20 17:07:48 2015
@@ -216,6 +216,16 @@ public:
return m_has[e_has_base];
}
+ void set_base_is_offset (bool is_offset)
+ {
+ m_base_is_offset = is_offset;
+ }
+ bool get_base_is_offset(bool & out) const
+ {
+ out = m_base_is_offset;
+ return m_has[e_has_base];
+ }
+
void set_link_map (const lldb::addr_t addr)
{
m_link_map = addr;
@@ -250,6 +260,7 @@ public:
std::string m_name;
lldb::addr_t m_link_map;
lldb::addr_t m_base;
+ bool m_base_is_offset;
lldb::addr_t m_dynamic;
};
@@ -4594,7 +4605,8 @@ ProcessGDBRemote::GetLoadedModuleList (G
{
// the displacement as read from the field 'l_addr' of the link_map struct.
module.set_base(StringConvert::ToUInt64(value.data(), LLDB_INVALID_ADDRESS, 0));
-
+ // base address is always a displacement, not an absolute value.
+ module.set_base_is_offset(true);
}
else if (name == "l_ld")
{
@@ -4609,13 +4621,15 @@ ProcessGDBRemote::GetLoadedModuleList (G
{
std::string name;
lldb::addr_t lm=0, base=0, ld=0;
+ bool base_is_offset;
module.get_name (name);
module.get_link_map (lm);
module.get_base (base);
+ module.get_base_is_offset (base_is_offset);
module.get_dynamic (ld);
- log->Printf ("found (link_map:0x%08" PRIx64 ", base:0x%08" PRIx64 ", ld:0x%08" PRIx64 ", name:'%s')", lm, base, ld, name.c_str());
+ log->Printf ("found (link_map:0x%08" PRIx64 ", base:0x%08" PRIx64 "[%s], ld:0x%08" PRIx64 ", name:'%s')", lm, base, (base_is_offset ? "offset" : "absolute"), ld, name.c_str());
}
list.add (module);
@@ -4657,15 +4671,19 @@ ProcessGDBRemote::GetLoadedModuleList (G
const XMLNode §ion = library.FindFirstChildElementWithName("section");
llvm::StringRef address = section.GetAttributeValue("address");
module.set_base(StringConvert::ToUInt64(address.data(), LLDB_INVALID_ADDRESS, 0));
+ // These addresses are absolute values.
+ module.set_base_is_offset(false);
if (log)
{
std::string name;
lldb::addr_t base = 0;
+ bool base_is_offset;
module.get_name (name);
module.get_base (base);
+ module.get_base_is_offset (base_is_offset);
- log->Printf ("found (base:0x%08" PRIx64 ", name:'%s')", base, name.c_str());
+ log->Printf ("found (base:0x%08" PRIx64 "[%s], name:'%s')", base, (base_is_offset ? "offset" : "absolute"), name.c_str());
}
list.add (module);
@@ -4682,7 +4700,7 @@ ProcessGDBRemote::GetLoadedModuleList (G
}
lldb::ModuleSP
-ProcessGDBRemote::LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr)
+ProcessGDBRemote::LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr, bool value_is_offset)
{
Target &target = m_process->GetTarget();
ModuleList &modules = target.GetImages();
@@ -4693,11 +4711,11 @@ ProcessGDBRemote::LoadModuleAtAddress (c
ModuleSpec module_spec (file, target.GetArchitecture());
if ((module_sp = modules.FindFirstModule (module_spec)))
{
- module_sp->SetLoadAddress (target, base_addr, true, changed);
+ module_sp->SetLoadAddress (target, base_addr, value_is_offset, changed);
}
else if ((module_sp = target.GetSharedModule (module_spec)))
{
- module_sp->SetLoadAddress (target, base_addr, true, changed);
+ module_sp->SetLoadAddress (target, base_addr, value_is_offset, changed);
}
return module_sp;
@@ -4720,10 +4738,12 @@ ProcessGDBRemote::LoadModules ()
{
std::string mod_name;
lldb::addr_t mod_base;
+ bool mod_base_is_offset;
bool valid = true;
valid &= modInfo.get_name (mod_name);
valid &= modInfo.get_base (mod_base);
+ valid &= modInfo.get_base_is_offset (mod_base_is_offset);
if (!valid)
continue;
@@ -4735,7 +4755,7 @@ ProcessGDBRemote::LoadModules ()
marker += 1;
FileSpec file (mod_name.c_str()+marker, true);
- lldb::ModuleSP module_sp = LoadModuleAtAddress (file, mod_base);
+ lldb::ModuleSP module_sp = LoadModuleAtAddress (file, mod_base, mod_base_is_offset);
if (module_sp.get())
new_modules.Append (module_sp);
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=245625&r1=245624&r2=245625&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Thu Aug 20 17:07:48 2015
@@ -452,7 +452,7 @@ protected:
GetLoadedModuleList (GDBLoadedModuleInfoList &);
lldb::ModuleSP
- LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr);
+ LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr, bool value_is_offset);
private:
//------------------------------------------------------------------
More information about the lldb-commits
mailing list