[Lldb-commits] [lldb] 58370ee - Revert "Change the dyld notification function that lldb puts a breakpoint in"

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 5 12:53:19 PDT 2023


Author: Jason Molenda
Date: 2023-07-05T12:52:21-07:00
New Revision: 58370eef673e80f3aea1bb431a291d1564e0f9f4

URL: https://github.com/llvm/llvm-project/commit/58370eef673e80f3aea1bb431a291d1564e0f9f4
DIFF: https://github.com/llvm/llvm-project/commit/58370eef673e80f3aea1bb431a291d1564e0f9f4.diff

LOG: Revert "Change the dyld notification function that lldb puts a breakpoint in"

We're seeing a lot of test failures on the lldb incremental x86 CI bot
since I landed https://reviews.llvm.org/D139453 - revert it while I
investigate.

This reverts commit 624813a4f41c5945dc8f8d998173960ad75db731.

Added: 
    

Modified: 
    lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index f439fa88fc7345..67e79fdcec8f56 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -235,15 +235,10 @@ bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton,
                                              lldb::user_id_t break_loc_id) {
   // Let the event know that the images have changed
   // DYLD passes three arguments to the notification breakpoint.
-  //
-  // Arg1: enum dyld_notify_mode mode
-  // 0 = adding, 1 = removing, 2 = remove all, 3 = dyld moved
-  //
-  // Arg2: unsigned long count
-  // Number of shared libraries added/removed
-  //
-  // Arg3: struct dyld_image_info mach_headers[]
-  // Array of load addresses of binaries added/removed
+  // Arg1: enum dyld_notify_mode mode - 0 = adding, 1 = removing, 2 = remove
+  // all Arg2: unsigned long icount        - Number of shared libraries
+  // added/removed Arg3: uint64_t mach_headers[]     - Array of load addresses
+  // of binaries added/removed
 
   DynamicLoaderMacOS *dyld_instance = (DynamicLoaderMacOS *)baton;
 
@@ -273,10 +268,9 @@ bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton,
     ValueList argument_values;
 
     Value mode_value;    // enum dyld_notify_mode { dyld_notify_adding=0,
-                         // dyld_notify_removing=1, dyld_notify_remove_all=2,
-                         // dyld_notify_dyld_moved=3 };
+                         // dyld_notify_removing=1, dyld_notify_remove_all=2 };
     Value count_value;   // unsigned long count
-    Value headers_value; // struct dyld_image_info machHeaders[]
+    Value headers_value; // uint64_t machHeaders[] (aka void*)
 
     CompilerType clang_void_ptr_type =
         scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
@@ -305,9 +299,6 @@ bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton,
     argument_values.PushValue(count_value);
     argument_values.PushValue(headers_value);
 
-    // void lldb_image_notifier(enum dyld_image_mode mode, uint32_t infoCount,
-    // const dyld_image_info info[])
-
     if (abi->GetArgumentValues(exe_ctx.GetThreadRef(), argument_values)) {
       uint32_t dyld_mode =
           argument_values.GetValueAtIndex(0)->GetScalar().UInt(-1);
@@ -321,32 +312,12 @@ bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton,
               argument_values.GetValueAtIndex(2)->GetScalar().ULongLong(-1);
           if (header_array != static_cast<uint64_t>(-1)) {
             std::vector<addr_t> image_load_addresses;
-
-            // struct dyld_image_info_32 {
-            //     uint32_t                    imageLoadAddress;
-            //     uint32_t                    imageFilePath;
-            //     uint32_t                    imageFileModDate;
-            // };
-            // struct dyld_image_info_64 {
-            //     uint64_t                    imageLoadAddress;
-            //     uint64_t                    imageFilePath;
-            //     uint64_t                    imageFileModDate;
-            // };
-
-            uint32_t addr_size =
-                process->GetTarget().GetArchitecture().GetAddressByteSize();
             for (uint64_t i = 0; i < image_infos_count; i++) {
               Status error;
-              addr_t dyld_image_info = header_array + (3 * addr_size * i);
-              addr_t addr =
-                  process->ReadPointerFromMemory(dyld_image_info, error);
-              if (error.Success()) {
+              addr_t addr = process->ReadUnsignedIntegerFromMemory(
+                  header_array + (8 * i), 8, LLDB_INVALID_ADDRESS, error);
+              if (addr != LLDB_INVALID_ADDRESS) {
                 image_load_addresses.push_back(addr);
-              } else {
-                Debugger::ReportWarning(
-                    "DynamicLoaderMacOS::NotifyBreakpointHit unable "
-                    "to read binary mach-o load address at 0x%" PRIx64,
-                    addr);
               }
             }
             if (dyld_mode == 0) {
@@ -391,18 +362,10 @@ bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton,
               Status error;
               addr_t notification_addr =
                   process->ReadPointerFromMemory(notification_location, error);
-              if (!error.Success()) {
-                Debugger::ReportWarning(
-                    "DynamicLoaderMacOS::NotifyBreakpointHit unable "
-                    "to read address of dyld-handover notification function at "
-                    "0x%" PRIx64,
-                    notification_location);
-              } else {
-                if (ABISP abi_sp = process->GetABI())
-                  notification_addr = abi_sp->FixCodeAddress(notification_addr);
+              if (ABISP abi_sp = process->GetABI())
+                notification_addr = abi_sp->FixCodeAddress(notification_addr);
 
-                dyld_instance->SetDYLDHandoverBreakpoint(notification_addr);
-              }
+              dyld_instance->SetDYLDHandoverBreakpoint(notification_addr);
             }
           }
         }
@@ -468,9 +431,9 @@ bool DynamicLoaderMacOS::SetNotificationBreakpoint() {
       Breakpoint *breakpoint =
           m_process->GetTarget()
               .CreateBreakpoint(&dyld_filelist, source_files,
-                                "lldb_image_notifier", eFunctionNameTypeFull,
-                                eLanguageTypeC, 0, skip_prologue, internal,
-                                hardware)
+                                "_dyld_debugger_notification",
+                                eFunctionNameTypeFull, eLanguageTypeC, 0,
+                                skip_prologue, internal, hardware)
               .get();
       breakpoint->SetCallback(DynamicLoaderMacOS::NotifyBreakpointHit, this,
                               true);


        


More information about the lldb-commits mailing list