Lldb 无法调试本地的 macOS 程序

使用 lldb 无法调试本地的 macOS 程序是什么原因呢?提示如下错误
$ lldb HelloWorld
(lldb) target create “HelloWorld”
Current executable set to ‘HelloWorld’ (x86_64).
(lldb) c
error: invalid process
(lldb) dis
error: Cannot disassemble around the current function without a selected frame.

(lldb) n
error: invalid process

如下图:


不能单步执行,也不能看反汇编代码,但是 image list -o -f,可以看到信息,这是什么原因呢?
(lldb) image list -o -f
[ 0] 0x0000000100000000 ~/Test/HellWorld/HelloWorld
[ 1] 0x0000000000000000 /usr/lib/dyld
[ 2] 0x0000000000000000 /usr/lib/libSystem.B.dylib
[ 3] 0x0000000000000000 /usr/lib/system/libcache.dylib
[ 4] 0x0000000000000000 /usr/lib/system/libcommonCrypto.dylib
[ 5] 0x0000000000000000 /usr/lib/system/libcompiler_rt.dylib
[ 6] 0x0000000000000000 /usr/lib/system/libcopyfile.dylib
[ 7] 0x0000000000000000 /usr/lib/system/libcorecrypto.dylib
[ 8] 0x0000000000000000 /usr/lib/system/libdispatch.dylib
[ 9] 0x0000000000000000 /usr/lib/system/libdyld.dylib
[ 10] 0x0000000000000000 /usr/lib/system/libkeymgr.dylib
[ 11] 0x0000000000000000 /usr/lib/system/liblaunch.dylib
[ 12] 0x0000000000000000 /usr/lib/system/libmacho.dylib
[ 13] 0x0000000000000000 /usr/lib/system/libquarantine.dylib
[ 14] 0x0000000000000000 /usr/lib/system/libremovefile.dylib
[ 15] 0x0000000000000000 /usr/lib/system/libsystem_asl.dylib
[ 16] 0x0000000000000000 /usr/lib/system/libsystem_blocks.dylib
[ 17] 0x0000000000000000 /usr/lib/system/libsystem_c.dylib
[ 18] 0x0000000000000000 /usr/lib/system/libsystem_configuration.dylib
[ 19] 0x0000000000000000 /usr/lib/system/libsystem_coreservices.dylib
[ 20] 0x0000000000000000 /usr/lib/system/libsystem_coretls.dylib
[ 21] 0x0000000000000000 /usr/lib/system/libsystem_dnssd.dylib
[ 22] 0x0000000000000000 /usr/lib/system/libsystem_info.dylib
[ 23] 0x0000000000000000 /usr/lib/system/libsystem_kernel.dylib
[ 24] 0x0000000000000000 /usr/lib/system/libsystem_m.dylib
[ 25] 0x0000000000000000 /usr/lib/system/libsystem_malloc.dylib
[ 26] 0x0000000000000000 /usr/lib/system/libsystem_network.dylib
[ 27] 0x0000000000000000 /usr/lib/system/libsystem_networkextension.dylib
[ 28] 0x0000000000000000 /usr/lib/system/libsystem_notify.dylib
[ 29] 0x0000000000000000 /usr/lib/system/libsystem_platform.dylib
[ 30] 0x0000000000000000 /usr/lib/system/libsystem_pthread.dylib
[ 31] 0x0000000000000000 /usr/lib/system/libsystem_sandbox.dylib
[ 32] 0x0000000000000000 /usr/lib/system/libsystem_secinit.dylib
[ 33] 0x0000000000000000 /usr/lib/system/libsystem_symptoms.dylib
[ 34] 0x0000000000000000 /usr/lib/system/libsystem_trace.dylib
[ 35] 0x0000000000000000 /usr/lib/system/libunwind.dylib
[ 36] 0x0000000000000000 /usr/lib/system/libxpc.dylib
[ 37] 0x0000000000000000 /usr/lib/libobjc.A.dylib
[ 38] 0x0000000000000000 /usr/lib/libc++abi.dylib
[ 39] 0x0000000000000000 /usr/lib/libc++.1.dylib

先输入r跑起来……

1 个赞

好了,可以了,多谢。

输入r跑起来之后,怎么再敲命令进去呢?

先打断点, br set -n main,然后再输入 r。