环境:Mac / Mojave和GDB 8.2.1(通过自制软件)。
我通过https://forward-in-code.blogspot.com/2018/11/mojave-vs-gdb.html指令工作,即:
另外,我还修改了SIP以允许调试(在Recovery OS终端:csrutil enable --without debug
)。
但是,我还是无法让gdb工作:
(gdb) file main
Reading symbols from main...done.
(gdb) run
Starting program: /Users/joubertold/code/Rhodus/obj/debug/main
[New Thread 0x1a03 of process 5082]
[New Thread 0x2803 of process 5082]
During startup program terminated with signal ?, Unknown signal.
(gdb)
有趣的是,lldb对我使用相同的二进制文件:
(lldb) file main
Current executable set to 'main' (x86_64).
(lldb) run
Process 5086 launched: '/Users/joubertold/code/Rhodus/obj/debug/main' (x86_64)
Rhodus
1 is ONE
1 is between 1 and 10
1 is between 1 and 10
1 is between 1 and 10
1 is between 1 and 10
1 is between 1 and 10
1 is between 1 and 10
1 is between 1 and 10
1 is between 1 and 10
1 is beyond
1 is beyond
1 is beyond
Process 5086 exited with status = 0 (0x00000000)
(lldb)
有什么想法吗?
我让gdb在Mojave上工作:
a)获取最新的gdb源存档(在撰写本文时,ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-8.2.50.20190212.tar.xz) - 除其他外,它还增加了在Mac上识别可执行文件的处理。
b)构建gdb。我在darwin-nat.c中得到了变量阴影的错误,所以我编辑了文件并重建(diff https://gist.github.com/joubertnel/267ca0fff4eaad494cc19ec3ba7953ed)。
c)按照https://forward-in-code.blogspot.com/2018/11/mojave-vs-gdb.html中的步骤进行操作
瞧。