[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta
Davide Italiano via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 24 12:28:35 PDT 2020
davide created this revision.
davide added reviewers: jasonmolenda, aprantl, friss.
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.
davide closed this revision.
LGTM. With p_flag, we only need to evaluate (processInfo.kp_proc.p_flag & P_TRANSLATED) as a boolean, but that's a style pref as much as anything.
davide added a comment.
In D82491#2112269 <https://reviews.llvm.org/D82491#2112269>, @jasonmolenda wrote:
> LGTM. With p_flag, we only need to evaluate (processInfo.kp_proc.p_flag & P_TRANSLATED) as a boolean, but that's a style pref as much as anything.
Fair, let me change that.
davide added a comment.
commit fd19ddb8f2a2b082f492fc59f7f360adf3495701 (HEAD -> master, origin/master, origin/HEAD)
Author: Davide Italiano <ditaliano at apple.com>
Date: Wed Jun 24 12:18:29 2020 -0700
[Apple Silicon] Initial support for Rosetta
Translated processes talk with a different debugserver, shipped with
macOS 11. This patch detects whether a process is translated and
attaches to the correct debugserver implementation.
It's the first patch of a series. Tested on the lldb test suite.
Differential Revision: https://reviews.llvm.org/D82491
Translated processes talk with a different debugserver, shipped with macOS 11.
This patch detects whether a process is translated and attaches to the correct debugserver implementation. It's the first patch of a series. Tested on the lldb test suite.
https://reviews.llvm.org/D82491
Files:
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,6 +17,7 @@
#include <unistd.h>
#endif
#include <sys/stat.h>
+#include <sys/sysctl.h>
#include <sys/types.h>
#include <time.h>
@@ -3432,6 +3433,23 @@
std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
debugserver_launch_info.SetUserID(process_info.GetUserID());
+#if defined(__APPLE__)
+ // On macOS 11, we need to support x86_64 applications translated to
+ // arm64. We check whether a binary is translated and spawn the correct
+ // debugserver accordingly.
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
+ static_cast<int>(process_info.GetProcessID()) };
+ struct kinfo_proc processInfo;
+ size_t bufsize = sizeof(processInfo);
+ if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
+ &bufsize, NULL, 0) == 0 && bufsize > 0) {
+ if ((processInfo.kp_proc.p_flag & P_TRANSLATED) == P_TRANSLATED) {
+ FileSpec rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
+ debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
+ }
+ }
+#endif
+
int communication_fd = -1;
#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
// Use a socketpair on non-Windows systems for security and performance
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82491.273122.patch
Type: text/x-patch
Size: 1532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200624/0b1237c0/attachment-0001.bin>
More information about the lldb-commits
mailing list