我已经成功使用
进行了代码签名codesign --entitlements gdb-entitlement.xml -fs gdb-cert $(哪个gdb)
我有这样的简单代码:
int main(int argc,char * argv []) { std :: cout <<“ hello,world” << std :: endl; 返回0; }
gdb挂起
zhifandeMacBook-Pro:cpp-quick-start zhifan $ g ++ -g main.cpp
zhifandeMacBook-Pro:cpp-quick-start zhifan$ gdb ./a.out
GNU gdb (GDB) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin18.2.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...Reading symbols from /Users/zhifan/github/cpp-quick-start/a.out.dSYM/Contents/Resources/DWARF/a.out...done.
done.
(gdb) start
Temporary breakpoint 1 at 0x100000f54: file main.cpp, line 5.
Starting program: /Users/zhifan/github/cpp-quick-start/a.out
[New Thread 0x1903 of process 11780]
[New Thread 0x1a03 of process 11780]
During startup program terminated with signal ?, Unknown signal.
(gdb) set startup-with-shell off
(gdb) start
Temporary breakpoint 2 at 0x100000f54: file main.cpp, line 5.
Starting program: /Users/zhifan/github/cpp-quick-start/a.out
[New Thread 0x2707 of process 11806]
我的gdb一直挂在这里([进程11806的新线程0x2707])。
自unknown load command 0x32问题以来,我无法使用8.0.1
我还能做什么?
答案 0 :(得分:1)
我今天通过以下方式使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中遇到变量阴影错误,因此我编辑了文件并重新构建。
c)遵循https://forward-in-code.blogspot.com/2018/11/mojave-vs-gdb.html
中的步骤Voila!
(来源:GDB on Mac/Mojave: During startup program terminated with signal ?, Unknown signal)
答案 1 :(得分:0)
好吧,根据我过去两年使用MacBook Pro编码的经验。我从未成功使gdb正常工作。 macOS使用Xcode Developer工具进行编译。这些工具包括lldb,它与gdb非常相似。
这是一个可以帮助您做到这一点的网站。 https://lldb.llvm.org/lldb-gdb.html 这是一张直接显示gdb工具和lldb工具的地图。 希望这会有所帮助。
答案 2 :(得分:0)
我完全同意@Tanner Breckenridge。无论我如何尝试,gdb都无法在我的Mac上运行。只需使用其他东西即可。
lldb看起来不错,对于像我这样喜欢使用gui调试器的人,我建议改用Visual Studio Code或Xcode调试C程序。