This is an archive of the discontinued LLVM Phabricator instance.

[Apple Silicon] Initial support for Rosetta
ClosedPublic

Authored by davide on Jun 24 2020, 12:10 PM.

Details

Summary

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.

Diff Detail

Event Timeline

davide created this revision.Jun 24 2020, 12:10 PM
jasonmolenda accepted this revision.Jun 24 2020, 12:16 PM

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.

This revision is now accepted and ready to land.Jun 24 2020, 12:16 PM

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 closed this revision.Jun 24 2020, 12:19 PM
commit fd19ddb8f2a2b082f492fc59f7f360adf3495701 (HEAD -> master, origin/master, origin/HEAD)
Author: Davide Italiano <ditaliano@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
JDevlieghere added inline comments.
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
3444

The sysctl call seems like something that would fit into host, we already have a bunch of those in Host.mm. Should we create a function there that returns whether a given pid runs under Rosetta?

echristo added inline comments.
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
20

This is problematic in that sys/sysctl is deprecated on linux (causing warnings/Werror failures).

echristo added inline comments.Jun 24 2020, 1:34 PM
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
20

I'm going to #ifdef this only in for apple at the moment matching the use below.

3444

Agreed. That seems much cleaner.

echristo added inline comments.Jun 24 2020, 1:37 PM
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
20

I see you've done that already :)

davide marked an inline comment as done.Jun 29 2020, 2:58 PM
davide added inline comments.
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
3444