[Lldb-commits] [lldb] e53019a - [lldb] Make GetSharedModuleWithLocalCache consider the device support directory

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon May 2 21:07:27 PDT 2022


Author: Jonas Devlieghere
Date: 2022-05-02T21:07:11-07:00
New Revision: e53019a8ff778048dd83aee29dd659af8b771920

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

LOG: [lldb] Make GetSharedModuleWithLocalCache consider the device support directory

Make GetSharedModuleWithLocalCache consider the device support
directory. In the past we only needed the device support directory to
debug remote processes. Since the introduction of Apple Silicon and
Rosetta this stopped being true.

When debugging a Rosetta process on macOS we need to consider the
Rosetta expanded shared cache. This patch and it dependencies move that
logic out of PlatfromRemoteDarwinDevice into a new abstract class called
PlatfromDarwinDevice. The new platform sit in between PlatformDarwin and
PlatformMacOSX and PlatformRemoteDarwinDevice and has all the necessary
logic to deal with the device support directory.

Technically I could have moved everything in PlatfromDarwinDevice into
PlatfromDarwin but decided that this logic is sufficiently self
contained that it warrants its own abstraction.

rdar://91966349

Differential revision: https://reviews.llvm.org/D124801

Added: 
    

Modified: 
    lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp
index d4173e4c812b9..7feaef95ea8c3 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp
@@ -328,6 +328,29 @@ lldb_private::Status PlatformDarwinDevice::GetSharedModuleWithLocalCache(
         return err;
       }
     }
+
+    // We failed to find the module in our shared cache. Let's see if we have a
+    // copy in our device support directory.
+    FileSpec device_support_spec(GetDeviceSupportDirectoryForOSVersion());
+    device_support_spec.AppendPathComponent("Symbols");
+    device_support_spec.AppendPathComponent(
+        module_spec.GetFileSpec().GetPath());
+    FileSystem::Instance().Resolve(device_support_spec);
+    if (FileSystem::Instance().Exists(device_support_spec)) {
+      ModuleSpec local_spec(device_support_spec, module_spec.GetUUID());
+      err = ModuleList::GetSharedModule(local_spec, module_sp,
+                                        module_search_paths_ptr, old_modules,
+                                        did_create_ptr);
+      if (module_sp) {
+        LLDB_LOGF(log,
+                  "[%s] module %s was found in Device Support "
+                  "directory: %s",
+                  (IsHost() ? "host" : "remote"),
+                  module_spec.GetFileSpec().GetPath().c_str(),
+                  local_spec.GetFileSpec().GetPath().c_str());
+        return err;
+      }
+    }
   }
 
   err = ModuleList::GetSharedModule(module_spec, module_sp,


        


More information about the lldb-commits mailing list