llvm-c166/lldb/packages/Python/lldbsuite/support/xcode.py
David Mentler 092ac9c0c7
[lldb][test] Allow dotest.py to call for Xcode to attach (#209628)
This speeds up the debugging of API tests a little on macOS.

(AppleScript written by Claude based on Xcode.sdef)
2026-07-16 22:19:22 +00:00

24 lines
749 B
Python

import subprocess
def attach(pid: int, suspended: bool = False) -> None:
script = """
on run argv
set targetPID to item 1 of argv as integer
set shouldSuspend to item 2 of argv as boolean
tell application "Xcode"
activate
if (count of workspace documents) is greater than 0 then
set debuggingWorkspace to workspace document 1
else
set debuggingWorkspace to create temporary debugging workspace
end if
attach debuggingWorkspace to process identifier targetPID suspended shouldSuspend
end tell
end run
"""
subprocess.run(["osascript", "-e", script, str(pid), str(suspended)], check=True)