Mac M1上无法用lldb调试arm64二进制文件的求助
在Mac M1上调试arm64二进制文件的问题
系统信息
❯ uname -a Darwin APPLEs-MacBook-Air.local 23.6.0 Darwin Kernel Version 23.6.0: Wed Jul 31 20:49:46 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T8103 x86_64
问题详情
在Mac M1上无法使用lldb调试arm64二进制文件。编写简单C语言"Hello World"程序后,用clang -target arm64-apple-darwin hello.c -o hello-arm编译可正常运行,但file命令显示架构为i386。
尝试用lldb附加该二进制文件时,提示platform not connected。指定架构运行lldb时出现错误:
❯ arch -arm64 lldb ./hello-arm arch: posix_spawnp: lldb: Bad CPU type in executable
补充说明:同一程序用clang hello.c -o hello-x86编译为x86_64架构后,可正常用lldb附加:
~/sample-c ❯ clang hello.c -o hello-x86 ~/sample-c ❯ file hello-x86 hello-x86: Mach-O 64-bit executable x86_64
另外,即使关闭SIP,也无法用lldb附加到Finder:
❯ lldb -n Finder (lldb) process attach --name "Finder" error: attach failed: debugserver is x86_64 binary running in translation, attach failed.
请问如何用lldb调试arm64二进制文件?
内容的提问来源于stack exchange,提问作者Vinay
相关产品推荐
相关产品推荐

