Skip to content

Commit 2e7109f

Browse files
artemmukhinintellij-monorepo-bot
authored andcommitted
PY-44191 PY-48163 Provide Attach to process binary for Linux AArch64 and universal binary for macOS
Now we use the following binaries for `Attach to process`: Windows: - `attach_amd64.dll` - `attach_x86.dll` (no changes in this commit, no ARM64 support) Linux: - `attach_linux_amd64.so` - `attach_linux_x86.so` - `attach_linux_aarch64.so` (the last one was added) macOS: - `attach.dylib` (universal binary containing both arm64 and x86_64 code) Note, `attach_x86.dylib` was removed and was not merged into the universal binary because Apple dropped support for 32-bit apps in macOS Catalina (10.15). However, there is still obsolete code for macOS i386 in the `pydev` module that should be dropped in the future GitOrigin-RevId: 51cdf976eaf5580218cf6026849e4da51c9370e6
1 parent 054f99c commit 2e7109f

File tree

11 files changed

+33
-35
lines changed

11 files changed

+33
-35
lines changed

python/helpers/pydev/_pydevd_bundle/pydevd_constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def dummy_excepthook(exctype, value, traceback):
7979
IS_WINDOWS = "windows" in System.Environment.OSVersion.VersionString.lower()
8080

8181
IS_64BIT_PROCESS = sys.maxsize > (2 ** 32)
82-
IS_ARM64 = platform.machine() == 'arm64'
82+
83+
# `aarch64` on Linux, `arm64` on macOS
84+
IS_AARCH64 = platform.machine().lower() in ['aarch64', 'arm64']
8385

8486
IS_LINUX = sys.platform.startswith('linux')
8587
IS_MACOS = sys.platform == 'darwin'

python/helpers/pydev/pydevd_attach_to_process/add_code_to_python_process.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,10 @@ def is_mac():
287287
return platform.system() == 'Darwin'
288288

289289

290-
def is_mac_arm64():
290+
def is_aarch64():
291291
import platform
292-
return platform.machine() == 'arm64'
292+
# `aarch64` on Linux, `arm64` on macOS
293+
return platform.machine().lower() in ['aarch64', 'arm64']
293294

294295

295296
def run_python_code_windows(pid, python_code, connect_debugger_tracing=False, show_debug_info=0):
@@ -452,11 +453,15 @@ def run_python_code_linux(pid, python_code, connect_debugger_tracing=False, show
452453

453454
# Valid arguments for arch are i386, i386:x86-64, i386:x64-32, i8086,
454455
# i386:intel, i386:x86-64:intel, i386:x64-32:intel, i386:nacl,
455-
# i386:x86-64:nacl, i386:x64-32:nacl, auto.
456+
# i386:x86-64:nacl, i386:x64-32:nacl, aarch64, auto.
456457

457458
if is_python_64bit():
458-
suffix = 'amd64'
459-
arch = 'i386:x86-64'
459+
if is_aarch64():
460+
suffix = 'aarch64'
461+
arch = 'aarch64'
462+
else:
463+
suffix = 'amd64'
464+
arch = 'i386:x86-64'
460465
else:
461466
suffix = 'x86'
462467
arch = 'i386'
@@ -539,19 +544,16 @@ def run_python_code_mac(pid, python_code, connect_debugger_tracing=False, show_d
539544
# i386:x86-64:nacl, i386:x64-32:nacl, auto, arm64
540545

541546
if is_python_64bit():
542-
if is_mac_arm64():
543-
suffix = 'arm64.dylib'
547+
if is_aarch64():
544548
arch = 'arm64'
545549
else:
546-
suffix = 'x86_64.dylib'
547550
arch = 'i386:x86-64'
548551
else:
549-
suffix = 'x86.dylib'
550552
arch = 'i386'
551553

552554
debug('Attaching with arch: %s'% (arch,))
553555

554-
target_dll = os.path.join(filedir, 'attach_%s' % suffix)
556+
target_dll = os.path.join(filedir, 'attach.dylib')
555557
target_dll = os.path.normpath(target_dll)
556558
if not os.path.exists(target_dll):
557559
raise RuntimeError('Could not find dll file to inject: %s' % target_dll)
100 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
-23.4 KB
Binary file not shown.
-19.6 KB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
g++ -march=armv8-a -shared -o attach_linux_aarch64.so -fPIC -nostartfiles attach.cpp
2+
mv attach_linux_aarch64.so ../attach_linux_aarch64.so
3+
echo Compiled aarch64
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
g++ -fPIC -D_REENTRANT -std=c++11 -arch x86_64 -c -o attach_x86_64.o attach.cpp
2-
g++ -dynamiclib -nostartfiles -arch x86_64 -o attach_x86_64.dylib attach_x86_64.o -lc
3-
rm attach_x86_64.o
4-
mv attach_x86_64.dylib ../attach_x86_64.dylib
5-
1+
clang++ -fPIC -D_REENTRANT -std=c++11 -arch arm64 -c -o attach_arm64.o attach.cpp
2+
clang++ -dynamiclib -nostartfiles -arch arm64 -o attach_arm64.dylib attach_arm64.o -lc
3+
rm attach_arm64.o
64

7-
g++ -fPIC -D_REENTRANT -std=c++11 -arch i386 -c -o attach_x86.o attach.cpp
8-
g++ -dynamiclib -nostartfiles -arch i386 -o attach_x86.dylib attach_x86.o -lc
9-
rm attach_x86.o
10-
mv attach_x86.dylib ../attach_x86.dylib
5+
clang++ -fPIC -D_REENTRANT -std=c++11 -arch x86_64 -c -o attach_x86_64.o attach.cpp
6+
clang++ -dynamiclib -nostartfiles -arch x86_64 -o attach_x86_64.dylib attach_x86_64.o -lc
7+
rm attach_x86_64.o
118

9+
lipo -create attach_arm64.dylib attach_x86_64.dylib -output attach.dylib
10+
rm attach_arm64.dylib attach_x86_64.dylib
11+
mv attach.dylib ../attach.dylib

python/helpers/pydev/pydevd_attach_to_process/linux_and_mac/compile_mac_arm64.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)