This revision was automatically updated to reflect the committed changes.
Closed by commit rG8faca2ed6ade: [lldb] Fix platform selection on Apple Silicon 
(authored by JDevlieghere).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117340

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h

Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
@@ -42,6 +42,8 @@
   std::vector<lldb_private::ArchSpec> GetSupportedArchitectures() override;
 
 protected:
+  bool CheckLocalSharedCache() const override;
+
   llvm::StringRef GetDeviceSupportDirectoryName() override;
   llvm::StringRef GetPlatformName() override;
 };
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
@@ -135,10 +135,17 @@
 
 std::vector<ArchSpec> PlatformRemoteiOS::GetSupportedArchitectures() {
   std::vector<ArchSpec> result;
-  ARMGetSupportedArchitectures(result);
+  ARMGetSupportedArchitectures(result, llvm::Triple::IOS);
   return result;
 }
 
+bool PlatformRemoteiOS::CheckLocalSharedCache() const {
+  // You can run iPhone and iPad apps on Mac with Apple Silicon. At the
+  // platform level there's no way to distinguish them from remote iOS
+  // applications. Make sure we still read from our own shared cache.
+  return true;
+}
+
 llvm::StringRef PlatformRemoteiOS::GetDeviceSupportDirectoryName() {
   return "iOS DeviceSupport";
 }
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
@@ -127,7 +127,7 @@
 std::vector<ArchSpec> PlatformRemoteMacOSX::GetSupportedArchitectures() {
   // macOS for ARM64 support both native and translated x86_64 processes
   std::vector<ArchSpec> result;
-  ARMGetSupportedArchitectures(result);
+  ARMGetSupportedArchitectures(result, llvm::Triple::MacOSX);
 
   // We can't use x86GetSupportedArchitectures() because it uses
   // the system architecture for some of its return values and also
Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -137,15 +137,13 @@
   std::vector<ArchSpec> result;
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
   // macOS for ARM64 support both native and translated x86_64 processes
-  ARMGetSupportedArchitectures(result);
+  ARMGetSupportedArchitectures(result, llvm::Triple::MacOSX);
 
   // We can't use x86GetSupportedArchitectures() because it uses
   // the system architecture for some of its return values and also
   // has a 32bits variant.
   result.push_back(ArchSpec("x86_64-apple-macosx"));
   result.push_back(ArchSpec("x86_64-apple-ios-macabi"));
-  result.push_back(ArchSpec("arm64-apple-ios"));
-  result.push_back(ArchSpec("arm64e-apple-ios"));
 #else
   x86GetSupportedArchitectures(result);
 #endif
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -60,7 +60,9 @@
   bool ModuleIsExcludedForUnconstrainedSearches(
       lldb_private::Target &target, const lldb::ModuleSP &module_sp) override;
 
-  void ARMGetSupportedArchitectures(std::vector<lldb_private::ArchSpec> &archs);
+  void
+  ARMGetSupportedArchitectures(std::vector<lldb_private::ArchSpec> &archs,
+                               llvm::Optional<llvm::Triple::OSType> os = {});
 
   void x86GetSupportedArchitectures(std::vector<lldb_private::ArchSpec> &archs);
 
@@ -141,6 +143,8 @@
       const lldb_private::FileSpecList *module_search_paths_ptr,
       llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr);
 
+  virtual bool CheckLocalSharedCache() const { return IsHost(); }
+
   struct SDKEnumeratorInfo {
     lldb_private::FileSpec found_path;
     lldb_private::XcodeSDK::Type sdk_type;
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -237,7 +237,7 @@
 
   Status err;
 
-  if (IsHost()) {
+  if (CheckLocalSharedCache()) {
     // When debugging on the host, we are most likely using the same shared
     // cache as our inferior. The dylibs from the shared cache might not
     // exist on the filesystem, so let's use the images in our own memory
@@ -644,7 +644,7 @@
 /// distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f
 /// processor.
 void PlatformDarwin::ARMGetSupportedArchitectures(
-    std::vector<ArchSpec> &archs) {
+    std::vector<ArchSpec> &archs, llvm::Optional<llvm::Triple::OSType> os) {
   const ArchSpec system_arch = GetSystemArchitecture();
   const ArchSpec::Core system_core = system_arch.GetCore();
 
@@ -654,6 +654,8 @@
     llvm::Triple triple;
     triple.setArchName(compatible_arch);
     triple.setVendor(llvm::Triple::VendorType::Apple);
+    if (os)
+      triple.setOS(*os);
     archs.push_back(ArchSpec(triple));
   }
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to