[Lldb-commits] [lldb] 001c8e1 - [PlatformDarwin] Add support for Apple Silicon.

Davide Italiano via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 20 14:11:26 PDT 2020


Author: Davide Italiano
Date: 2020-07-20T14:11:19-07:00
New Revision: 001c8e1fd9f09d3de9ff6e64bdac4b8ca681dfb4

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

LOG: [PlatformDarwin] Add support for Apple Silicon.

Gets another large chunk of the testsuite to pass.

Added: 
    

Modified: 
    lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
    lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index d31559bc9018..baa9d7b50ad6 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -570,12 +570,23 @@ bool PlatformDarwin::ARMGetSupportedArchitectureAtIndex(uint32_t idx,
 #define OSNAME "watchos"
 #elif defined(TARGET_OS_BRIDGE) && TARGET_OS_BRIDGE == 1
 #define OSNAME "bridgeos"
-#elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
-#define OSNAME "macosx"
 #else
 #define OSNAME "ios"
 #endif
 
+#if TARGET_OS_OSX
+  if (IsHost()) {
+    if (idx == 0) {
+      arch.SetTriple("arm64e-apple-macosx");
+      return true;
+    } else if (idx == 1) {
+      arch.SetTriple("arm64-apple-macosx");
+      return true;
+    }
+    return false;
+  }
+#endif
+
   const ArchSpec::Core system_core = system_arch.GetCore();
   switch (system_core) {
   default:

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index 0b7f898ee0d3..93860c257979 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -282,7 +282,33 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file,
 bool PlatformMacOSX::GetSupportedArchitectureAtIndex(uint32_t idx,
                                                      ArchSpec &arch) {
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
-  return ARMGetSupportedArchitectureAtIndex(idx, arch);
+  // macOS for ARM64 support both native and translated x86_64 processes
+  if (!m_num_arm_arches || idx < m_num_arm_arches) {
+    bool res = ARMGetSupportedArchitectureAtIndex(idx, arch);
+    if (res)
+      return true;
+    if (!m_num_arm_arches)
+      m_num_arm_arches = idx;
+  }
+
+  // We can't use x86GetSupportedArchitectureAtIndex() because it uses
+  // the system architecture for some of its return values and also
+  // has a 32bits variant.
+  if (idx == m_num_arm_arches) {
+    arch.SetTriple("x86_64-apple-macosx");
+    return true;
+  } else if (idx == m_num_arm_arches + 1) {
+    arch.SetTriple("x86_64-apple-ios-macabi");
+    return true;
+  } else if (idx == m_num_arm_arches + 2) {
+    arch.SetTriple("arm64-apple-ios");
+    return true;
+  } else if (idx == m_num_arm_arches + 3) {
+    arch.SetTriple("arm64e-apple-ios");
+    return true;
+  }
+
+  return false;
 #else
   return x86GetSupportedArchitectureAtIndex(idx, arch);
 #endif

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
index 30b11eb37684..c383dd97daf8 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
@@ -79,6 +79,8 @@ class PlatformMacOSX : public PlatformDarwin {
 private:
   PlatformMacOSX(const PlatformMacOSX &) = delete;
   const PlatformMacOSX &operator=(const PlatformMacOSX &) = delete;
+
+  int m_num_arches = 0;
 };
 
 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMMACOSX_H


        


More information about the lldb-commits mailing list