我只是尝试在 Mac OSX 版本 10.12 上使用 gdb 调试代码,但在 gdb 中启动程序时总是遇到此未知错误。
我在安装后对 gdb 进行了代码签名,并使用 -g 标志编译了我的代码。
这就是正在发生的事情:
computer:hello user$ gdb a.out
GNU gdb (GDB) 7.12
Copyright (C) 2016 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-darwin16.0.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/user/Documents/Programming/hello/a.out.dSYM/Contents/Resources/DWARF/a.out...done.
done.
(gdb) r
Starting program: /Users/user/Documents/Programming/hello/a.out
During startup program terminated with signal ?, Unknown signal.
我暂时收到了 SIGTRAP 信号,但我不明白为什么它现在再次抛出未知信号。
适用于 Mac OS X 10.12.5 及更高版本的解决方案
在您的主目录中创建一个 .gdbinit 文件,并在其中写入“setstartup-with-shell off”。
可以使用创建文件vi ~/.gdbinit
.
打开一个新终端,gdb 就会工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)