无法在 macOS M1 上使用 lldb 调试可执行文件:附加失败((os/kern)参数无效

Cannot debug executable with lldb on macOS M1: attach failed ((os/kern) invalid argument

我正在尝试在 Apple M1 MacBook Pro 运行ning macOS Monterey 上调试为 arm64 编译的 C 可执行文件。但是,当我尝试 运行 lldb 中的程序时,我收到以下错误:

(lldb) run
error: process exited with status -1 (attach failed ((os/kern) invalid argument))

要在 运行ning Rosetta 系统上调试 arm64 可执行文件,您需要在 arm64 架构中显式 运行 lldb。为此:

arch -arm64 lldb ./your-program