Commit fd19ddb8 authored by Davide Italiano's avatar Davide Italiano
Browse files

[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:
parent 35bb9bfb
......@@ -17,6 +17,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <time.h>
......@@ -3432,6 +3433,23 @@ Status ProcessGDBRemote::LaunchAndConnectToDebugserver(
std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
#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.
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) {
FileSpec rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
int communication_fd = -1;
// Use a socketpair on non-Windows systems for security and performance
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment