summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksiy Vyalov <ovyalov@google.com>2015-01-07 01:28:37 +0000
committerOleksiy Vyalov <ovyalov@google.com>2015-01-07 01:28:37 +0000
commit185f2bea8d0560c86091bafe780e0980b910fa56 (patch)
tree071ec3d4661220d96aa654da4da49d403b9190aa
parent772c2a762d49c0845af1f4193816b0ea226c6bb4 (diff)
Make DynamicLoaderPOSIXDYLD::DidAttach to deduce a target executable by pid if no executable hasn't been assigned to a target so far.
http://reviews.llvm.org/D6740 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@225332 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp33
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h4
2 files changed, 32 insertions, 5 deletions
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 632c01ae7..6b0b6f5cc 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -112,9 +112,6 @@ void
DynamicLoaderPOSIXDYLD::DidAttach()
{
Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
- ModuleSP executable_sp;
- addr_t load_offset;
-
if (log)
log->Printf ("DynamicLoaderPOSIXDYLD::%s() pid %" PRIu64, __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID);
@@ -122,8 +119,19 @@ DynamicLoaderPOSIXDYLD::DidAttach()
if (log)
log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " reloaded auxv data", __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID);
- executable_sp = GetTargetExecutable();
- load_offset = ComputeLoadOffset();
+ 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);
+ }
+ }
+
+ addr_t load_offset = ComputeLoadOffset();
if (log)
log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " executable '%s', load_offset 0x%" PRIx64, __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID, executable_sp ? executable_sp->GetFileSpec().GetPath().c_str () : "<null executable>", load_offset);
@@ -613,3 +621,18 @@ DynamicLoaderPOSIXDYLD::GetThreadLocalData (const lldb::ModuleSP module, const l
return tls_block;
}
+
+bool
+DynamicLoaderPOSIXDYLD::GetProcessModuleSpec (ModuleSpec& module_spec)
+{
+ if (m_process == nullptr)
+ return false;
+
+ auto& target = m_process->GetTarget ();
+ ProcessInstanceInfo process_info;
+ if (!target.GetPlatform ()->GetProcessInfo (m_process->GetID (), process_info))
+ return false;
+
+ module_spec = ModuleSpec (process_info.GetExecutableFile (), process_info.GetArchitecture ());
+ return true;
+}
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index 9ced5da8a..747ff3f2b 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -168,6 +168,10 @@ protected:
lldb::addr_t
GetEntryPoint();
+ /// Loads ModuleSpec data from inferior process.
+ bool
+ GetProcessModuleSpec(lldb_private::ModuleSpec& module_spec);
+
private:
DISALLOW_COPY_AND_ASSIGN(DynamicLoaderPOSIXDYLD);
};