summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Sezer <sas@cd80.net>2016-04-05 17:25:32 +0000
committerStephane Sezer <sas@cd80.net>2016-04-05 17:25:32 +0000
commit3553c0e5e7b2a2936469c2a93c09e10af914875f (patch)
tree5226089f487241bb3a33426061b1854a4bb70d7b
parent6ecf1b6760f0650de1cca08ca5af551db085565f (diff)
downloadbcm5719-llvm-3553c0e5e7b2a2936469c2a93c09e10af914875f.tar.gz
bcm5719-llvm-3553c0e5e7b2a2936469c2a93c09e10af914875f.zip
Allow gdbremote process to read modules from memory
Summary: The logic to read modules from memory was added to LoadModuleAtAddress in the dynamic loader, but not in process gdb remote. This means that when the remote uses svr4 packets to give library info, libraries only present on the remote will not be loaded. This patch therefore involves some code duplication from LoadModuleAtAddress in the dynamic loader, but removing this would require some amount of code refactoring. Reviewers: ADodds, tberghammer, tfiala, deepak2427, ted Subscribers: tfiala, lldb-commits, sas Differential Revision: http://reviews.llvm.org/D18531 Change by Francis Ricci <fjricci@fb.com> llvm-svn: 265418
-rw-r--r--lldb/include/lldb/Target/DynamicLoader.h16
-rw-r--r--lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp28
-rw-r--r--lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h8
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp30
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h3
5 files changed, 22 insertions, 63 deletions
diff --git a/lldb/include/lldb/Target/DynamicLoader.h b/lldb/include/lldb/Target/DynamicLoader.h
index 5eada0342a2..6aeafd0c337 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -243,6 +243,14 @@ public:
return LLDB_INVALID_ADDRESS;
}
+ /// Locates or creates a module given by @p file and updates/loads the
+ /// resulting module at the virtual base address @p base_addr.
+ virtual lldb::ModuleSP
+ LoadModuleAtAddress(const lldb_private::FileSpec &file,
+ lldb::addr_t link_map_addr,
+ lldb::addr_t base_addr,
+ bool base_addr_is_offset);
+
protected:
//------------------------------------------------------------------
// Utility methods for derived classes
@@ -282,14 +290,6 @@ protected:
void
UnloadSectionsCommon(const lldb::ModuleSP module);
- /// Locates or creates a module given by @p file and updates/loads the
- /// resulting module at the virtual base address @p base_addr.
- virtual lldb::ModuleSP
- LoadModuleAtAddress(const lldb_private::FileSpec &file,
- lldb::addr_t link_map_addr,
- lldb::addr_t base_addr,
- bool base_addr_is_offset);
-
const lldb_private::SectionList *
GetSectionListFromModule(const lldb::ModuleSP module) const;
diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
index 28493170ac3..da14d9b10ae 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
@@ -574,34 +574,6 @@ DynamicLoaderHexagonDYLD::LoadAllCurrentModules()
m_process->GetTarget().ModulesDidLoad(module_list);
}
-/// Helper for the entry breakpoint callback. Resolves the load addresses
-/// of all dependent modules.
-ModuleSP
-DynamicLoaderHexagonDYLD::LoadModuleAtAddress(const FileSpec &file,
- addr_t link_map_addr,
- addr_t base_addr,
- bool base_addr_is_offset)
-{
- Target &target = m_process->GetTarget();
- ModuleList &modules = target.GetImages();
- ModuleSP module_sp;
-
- ModuleSpec module_spec (file, target.GetArchitecture());
-
- // check if module is currently loaded
- if ((module_sp = modules.FindFirstModule (module_spec)))
- {
- UpdateLoadedSections(module_sp, link_map_addr, base_addr, true);
- }
- // try to load this module from disk
- else if ((module_sp = target.GetSharedModule(module_spec)))
- {
- UpdateLoadedSections(module_sp, link_map_addr, base_addr, true);
- }
-
- return module_sp;
-}
-
/// Computes a value for m_load_offset returning the computed address on
/// success and LLDB_INVALID_ADDRESS on failure.
addr_t
diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
index e10d4ee6420..1cc1e29a4a3 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
@@ -123,14 +123,6 @@ protected:
void
UnloadSections(const lldb::ModuleSP module) override;
- /// Locates or creates a module given by @p file and updates/loads the
- /// resulting module at the virtual base address @p base_addr.
- lldb::ModuleSP
- LoadModuleAtAddress(const lldb_private::FileSpec &file,
- lldb::addr_t link_map_addr,
- lldb::addr_t base_addr,
- bool base_addr_is_offset) override;
-
/// Callback routine invoked when we hit the breakpoint on process entry.
///
/// This routine is responsible for resolving the load addresses of all
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index c0db8ebc9de..d430c2baf2b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4806,25 +4806,14 @@ ProcessGDBRemote::GetLoadedModuleList (LoadedModuleInfoList & list)
}
lldb::ModuleSP
-ProcessGDBRemote::LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr, bool value_is_offset)
+ProcessGDBRemote::LoadModuleAtAddress (const FileSpec &file, lldb::addr_t link_map,
+ lldb::addr_t base_addr, bool value_is_offset)
{
- Target &target = m_process->GetTarget();
- ModuleList &modules = target.GetImages();
- ModuleSP module_sp;
+ DynamicLoader *loader = GetDynamicLoader();
+ if (!loader)
+ return nullptr;
- bool changed = false;
-
- ModuleSpec module_spec (file, target.GetArchitecture());
- if ((module_sp = modules.FindFirstModule (module_spec)))
- {
- module_sp->SetLoadAddress (target, base_addr, value_is_offset, changed);
- }
- else if ((module_sp = target.GetSharedModule (module_spec)))
- {
- module_sp->SetLoadAddress (target, base_addr, value_is_offset, changed);
- }
-
- return module_sp;
+ return loader->LoadModuleAtAddress(file, link_map, base_addr, value_is_offset);
}
size_t
@@ -4843,6 +4832,7 @@ ProcessGDBRemote::LoadModules (LoadedModuleInfoList &module_list)
{
std::string mod_name;
lldb::addr_t mod_base;
+ lldb::addr_t link_map;
bool mod_base_is_offset;
bool valid = true;
@@ -4852,6 +4842,9 @@ ProcessGDBRemote::LoadModules (LoadedModuleInfoList &module_list)
if (!valid)
continue;
+ if (!modInfo.get_link_map (link_map))
+ link_map = LLDB_INVALID_ADDRESS;
+
// hack (cleaner way to get file name only?) (win/unix compat?)
size_t marker = mod_name.rfind ('/');
if (marker == std::string::npos)
@@ -4860,7 +4853,8 @@ ProcessGDBRemote::LoadModules (LoadedModuleInfoList &module_list)
marker += 1;
FileSpec file (mod_name.c_str()+marker, true);
- lldb::ModuleSP module_sp = LoadModuleAtAddress (file, mod_base, mod_base_is_offset);
+ lldb::ModuleSP module_sp = LoadModuleAtAddress (file, link_map, mod_base,
+ mod_base_is_offset);
if (module_sp.get())
new_modules.Append (module_sp);
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 5f028229eed..b67eb49e5e6 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -468,7 +468,8 @@ protected:
GetLoadedModuleList (LoadedModuleInfoList &);
lldb::ModuleSP
- LoadModuleAtAddress (const FileSpec &file, lldb::addr_t base_addr, bool value_is_offset);
+ LoadModuleAtAddress (const FileSpec &file, lldb::addr_t link_map, lldb::addr_t base_addr,
+ bool value_is_offset);
private:
//------------------------------------------------------------------
OpenPOWER on IntegriCloud