diff options
author | Stephane Sezer <sas@cd80.net> | 2015-08-20 22:07:48 +0000 |
---|---|---|
committer | Stephane Sezer <sas@cd80.net> | 2015-08-20 22:07:48 +0000 |
commit | c6845a0dddb8dc521cec48677d64ab820744602d (patch) | |
tree | d056c0d6e532cdaba41aaf4cfbf6889608892094 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | 4268d39436bf471bee6993efe9999f36cad4cf37 (diff) | |
download | bcm5719-llvm-c6845a0dddb8dc521cec48677d64ab820744602d.tar.gz bcm5719-llvm-c6845a0dddb8dc521cec48677d64ab820744602d.zip |
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
llvm-svn: 245625
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 4f4eef80a3c..92027bb2a3b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -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 (GDBLoadedModuleInfoList & list) { // 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 (GDBLoadedModuleInfoList & list) { 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 (GDBLoadedModuleInfoList & list) 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 (GDBLoadedModuleInfoList & list) } 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 (const FileSpec &file, lldb::addr_t base_a 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); |