macOS Mojave 上的 GDB 错误

GDB errors on macOS Mojave

环境: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

中的步骤操作

瞧。

很遗憾,已接受的答案对我不起作用。

对于和我情况相同的人,我建议使用 Visual Studio 代码或 Xcode 来调试您的 C 程序。