[Lldb-commits] [PATCH] Make DynamicLoaderPOSIXDYLD::DidAttach to deduce a target executable by pid if no executable hasn't been assigned to a target so far.

Oleksiy Vyalov ovyalov at google.com
Fri Dec 19 13:45:09 PST 2014


Hi clayborg,

If user attaches to a local process by pid without executable assigned to a target we can deduce an executable path by pid, otherwise no symbols are loaded and not possible to set up breakpoints.

http://reviews.llvm.org/D6740

Files:
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

Index: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
===================================================================
--- source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -123,6 +123,18 @@
         log->Printf ("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " reloaded auxv data", __FUNCTION__, m_process ? m_process->GetID () : LLDB_INVALID_PROCESS_ID);
 
     executable_sp = GetTargetExecutable();
+    if (executable_sp == nullptr && m_process != nullptr)
+    {
+        auto& target = m_process->GetTarget();
+        ProcessInstanceInfo process_info;
+        if (target.GetPlatform()->GetProcessInfo(m_process->GetID(), process_info))
+        {
+            executable_sp.reset(new Module(ModuleSpec(process_info.GetExecutableFile(), target.GetArchitecture())));
+            target.SetExecutableModule(executable_sp, false);
+            if (log)
+                log->Printf ("DynamicLoaderPOSIXDYLD::%s set new target executable %s using pid %" PRIu64, __FUNCTION__, process_info.GetExecutableFile().GetPath().c_str(), m_process->GetID());
+        }
+    }
     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);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6740.17510.patch
Type: text/x-patch
Size: 1517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20141219/c5384d7d/attachment.bin>


More information about the lldb-commits mailing list