GDB因信号?终止,未知信号。

9
我正在尝试在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信号,但我无法弄清为什么现在又抛出了未知信号。

4个回答

9

Mac OS X 10.12.5及以上版本的解决方案

在您的主目录下创建 .gdbinit 文件,并将 "set startup-with-shell off" 写入其中。

可以使用 vi ~/.gdbinit 命令创建文件。

打开一个新的终端,gdb 将会工作。


2
这是在OSX 10.12.5中使用gdb的方法。 - lakeslove
打开新终端是必要的。 - Jack Wasey

2

1

这是因为您正在使用最新版本的OSX 10.12或10.12.1。降级或等待OSX/GDB修复似乎是最佳选择。我已经浪费了一整天的时间来解决这个问题。不要浪费时间尝试在Sierra上解决它!


0

使用新的gdb 8.3,它对我有效。(不适用于gdb 8.0.1或8.2)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接