[Lldb-commits] [PATCH] D55399: If we still have all_image_infos use it in DynamicLoaderMacOSDYLD to detect exec's

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 6 16:39:52 PST 2018


jingham updated this revision to Diff 177085.
jingham marked an inline comment as done.
jingham added a comment.

Added a comment and removed an errant space.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55399/new/

https://reviews.llvm.org/D55399

Files:
  source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
  source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h


Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
===================================================================
--- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
+++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
@@ -104,6 +104,12 @@
                                   // loaded/unloaded images
   lldb::user_id_t m_break_id;
   mutable std::recursive_mutex m_mutex;
+  lldb::addr_t m_maybe_image_infos_address; // If dyld is still maintaining the
+                                            // all_image_infos address, store it
+                                            // here so we can use it to detect
+                                            // exec's when talking to
+                                            // debugservers that don't support
+                                            // the "reason:exec" annotation.
 
 private:
   DISALLOW_COPY_AND_ASSIGN(DynamicLoaderMacOS);
Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
===================================================================
--- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -79,7 +79,8 @@
 //----------------------------------------------------------------------
 DynamicLoaderMacOS::DynamicLoaderMacOS(Process *process)
     : DynamicLoaderDarwin(process), m_image_infos_stop_id(UINT32_MAX),
-      m_break_id(LLDB_INVALID_BREAK_ID), m_mutex() {}
+      m_break_id(LLDB_INVALID_BREAK_ID), m_mutex(),
+      m_maybe_image_infos_address(LLDB_INVALID_ADDRESS) {}
 
 //----------------------------------------------------------------------
 // Destructor
@@ -95,16 +96,26 @@
   if (m_process) {
     // If we are stopped after an exec, we will have only one thread...
     if (m_process->GetThreadList().GetSize() == 1) {
-      // See if we are stopped at '_dyld_start'
-      ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0));
-      if (thread_sp) {
-        lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
-        if (frame_sp) {
-          const Symbol *symbol =
-              frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
-          if (symbol) {
-            if (symbol->GetName() == ConstString("_dyld_start"))
-              did_exec = true;
+      // Maybe we still have an image infos address around?  If so see
+      // if that has changed, and if so we have exec'ed:
+      if (m_maybe_image_infos_address != LLDB_INVALID_ADDRESS) {
+        lldb::addr_t image_infos_address = m_process->GetImageInfoAddress();
+        if (image_infos_address != m_maybe_image_infos_address)
+          did_exec = true;
+      }
+
+      if (!did_exec) {
+        // See if we are stopped at '_dyld_start'
+        ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0));
+        if (thread_sp) {
+          lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
+          if (frame_sp) {
+            const Symbol *symbol =
+                frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
+            if (symbol) {
+              if (symbol->GetName() == ConstString("_dyld_start"))
+                did_exec = true;
+            }
           }
         }
       }
@@ -180,6 +191,7 @@
   }
 
   m_dyld_image_infos_stop_id = m_process->GetStopID();
+  m_maybe_image_infos_address = m_process->GetImageInfoAddress();
 }
 
 bool DynamicLoaderMacOS::NeedToDoInitialImageFetch() { return true; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55399.177085.patch
Type: text/x-patch
Size: 3527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20181207/c759206a/attachment.bin>


More information about the lldb-commits mailing list