summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Target/Platform.h12
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp55
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h6
-rw-r--r--lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp4
-rw-r--r--lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp4
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp4
-rw-r--r--lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp4
-rw-r--r--lldb/source/Target/Platform.cpp37
8 files changed, 93 insertions, 33 deletions
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 31c8202129c..ab4b03d0c23 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -1123,6 +1123,12 @@ class ModuleCache;
m_gid_map.clear();
}
+ Error
+ GetCachedExecutable (ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ Platform &remote_platform);
+
bool
GetCachedSharedModule (const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp);
@@ -1140,6 +1146,12 @@ class ModuleCache;
FileSpec GetModuleCacheRoot ();
private:
+ Error
+ LoadCachedExecutable (const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ Platform &remote_platform);
+
DISALLOW_COPY_AND_ASSIGN (Platform);
};
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 1cebdca8cc3..061e8e92ec7 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -121,16 +121,7 @@ DynamicLoaderPOSIXDYLD::DidAttach()
log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " reloaded auxv data", __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID);
ModuleSP executable_sp = GetTargetExecutable();
- ModuleSpec process_module_spec;
- if (GetProcessModuleSpec(process_module_spec))
- {
- if (executable_sp == nullptr || !executable_sp->MatchesModuleSpec(process_module_spec))
- {
- executable_sp.reset(new Module(process_module_spec));
- assert(m_process != nullptr);
- m_process->GetTarget().SetExecutableModule(executable_sp, false);
- }
- }
+ ResolveExecutableModule(executable_sp);
addr_t load_offset = ComputeLoadOffset();
if (log)
@@ -626,17 +617,45 @@ DynamicLoaderPOSIXDYLD::GetThreadLocalData (const lldb::ModuleSP module, const l
return tls_block;
}
-bool
-DynamicLoaderPOSIXDYLD::GetProcessModuleSpec (ModuleSpec& module_spec)
+void
+DynamicLoaderPOSIXDYLD::ResolveExecutableModule (lldb::ModuleSP &module_sp)
{
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+
if (m_process == nullptr)
- return false;
+ return;
+
+ auto &target = m_process->GetTarget ();
+ const auto platform_sp = target.GetPlatform ();
- auto& target = m_process->GetTarget ();
ProcessInstanceInfo process_info;
- if (!target.GetPlatform ()->GetProcessInfo (m_process->GetID (), process_info))
- return false;
+ if (!platform_sp->GetProcessInfo (m_process->GetID (), process_info))
+ {
+ if (log)
+ log->Printf ("DynamicLoaderPOSIXDYLD::%s - failed to get process info for pid %" PRIu64,
+ __FUNCTION__, m_process->GetID ());
+ return;
+ }
+
+ if (log)
+ log->Printf ("DynamicLoaderPOSIXDYLD::%s - got executable by pid %" PRIu64 ": %s",
+ __FUNCTION__, m_process->GetID (), process_info.GetExecutableFile ().GetPath ().c_str ());
+
+ ModuleSpec module_spec (process_info.GetExecutableFile (), process_info.GetArchitecture ());
+ if (module_sp && module_sp->MatchesModuleSpec (module_spec))
+ return;
+
+ auto error = platform_sp->ResolveExecutable (module_spec, module_sp, nullptr);
+ if (error.Fail ())
+ {
+ StreamString stream;
+ module_spec.Dump (stream);
+
+ if (log)
+ log->Printf ("DynamicLoaderPOSIXDYLD::%s - failed to resolve executable with module spec \"%s\": %s",
+ __FUNCTION__, stream.GetString ().c_str (), error.AsCString ());
+ return;
+ }
- module_spec = ModuleSpec (process_info.GetExecutableFile (), process_info.GetArchitecture ());
- return true;
+ target.SetExecutableModule (module_sp, false);
}
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index 747ff3f2be3..68d3059cb4b 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -168,9 +168,9 @@ protected:
lldb::addr_t
GetEntryPoint();
- /// Loads ModuleSpec data from inferior process.
- bool
- GetProcessModuleSpec(lldb_private::ModuleSpec& module_spec);
+ /// Loads Module from inferior process.
+ void
+ ResolveExecutableModule(lldb::ModuleSP &module_sp);
private:
DISALLOW_COPY_AND_ASSIGN(DynamicLoaderPOSIXDYLD);
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index 2fdebe127b8..cd52f057dd4 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -232,9 +232,7 @@ PlatformFreeBSD::ResolveExecutable (const ModuleSpec &module_spec,
{
if (m_remote_platform_sp)
{
- error = m_remote_platform_sp->ResolveExecutable (module_spec,
- exe_module_sp,
- module_search_paths_ptr);
+ error = GetCachedExecutable (resolved_module_spec, exe_module_sp, module_search_paths_ptr, *m_remote_platform_sp);
}
else
{
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 2672b326f74..62f58d49738 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -307,9 +307,7 @@ PlatformLinux::ResolveExecutable (const ModuleSpec &ms,
{
if (m_remote_platform_sp)
{
- error = m_remote_platform_sp->ResolveExecutable (ms,
- exe_module_sp,
- NULL);
+ error = GetCachedExecutable (resolved_module_spec, exe_module_sp, nullptr, *m_remote_platform_sp);
}
else
{
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index d7b6cd421a4..02ff14f7611 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -212,9 +212,7 @@ PlatformDarwin::ResolveExecutable (const ModuleSpec &module_spec,
{
if (m_remote_platform_sp)
{
- error = m_remote_platform_sp->ResolveExecutable (module_spec,
- exe_module_sp,
- module_search_paths_ptr);
+ error = GetCachedExecutable (resolved_module_spec, exe_module_sp, module_search_paths_ptr, *m_remote_platform_sp);
}
else
{
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 9f59adb1713..c08feeff7e3 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -247,9 +247,7 @@ PlatformWindows::ResolveExecutable (const ModuleSpec &ms,
{
if (m_remote_platform_sp)
{
- error = m_remote_platform_sp->ResolveExecutable (ms,
- exe_module_sp,
- NULL);
+ error = GetCachedExecutable (resolved_module_spec, exe_module_sp, nullptr, *m_remote_platform_sp);
}
else
{
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index f5941706377..d8ad8c7b719 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1752,6 +1752,43 @@ Platform::GetTrapHandlerSymbolNames ()
return m_trap_handlers;
}
+Error
+Platform::GetCachedExecutable (ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ Platform &remote_platform)
+{
+ const auto platform_spec = module_spec.GetFileSpec ();
+ const auto error = LoadCachedExecutable (module_spec,
+ module_sp,
+ module_search_paths_ptr,
+ remote_platform);
+ if (error.Success ())
+ {
+ module_spec.GetFileSpec () = module_sp->GetFileSpec ();
+ module_spec.GetPlatformFileSpec () = platform_spec;
+ }
+
+ return error;
+}
+
+Error
+Platform::LoadCachedExecutable (const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ Platform &remote_platform)
+{
+ if (GetGlobalPlatformProperties ()->GetUseModuleCache ())
+ {
+ if (GetCachedSharedModule (module_spec, module_sp))
+ return Error ();
+ }
+
+ return remote_platform.ResolveExecutable (module_spec,
+ module_sp,
+ module_search_paths_ptr);
+}
+
bool
Platform::GetCachedSharedModule (const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp)
OpenPOWER on IntegriCloud