Abort trap 6: 在 Mac OS 上运行 gdb 时的错误

11

我已经通过Homebrew在我的Mac上(运行Mac OS 10.9/Mavericks)安装了gdb,并且成功地对其进行了代码签名。

在使用gdb开始调试会话之前,我像这个例子中一样编译了我的C文件:

gcc -g test.c -o test

之后我调用了gdb:

Users-MacBook-Pro:Test User$ gdb ./test
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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-darwin13.4.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 ./test...Reading symbols from /Users/User/Test/test.dSYM/Contents/Resources/DWARF/test...done.
done.
调用gdb命令如r或sta总是导致以下错误:
(gdb) r 
Abort trap: 6

有什么问题?有什么想法可以解决吗?


数字6(可能)代表着SIGABRT,通常只有在调用abort()时才会被调用。 - cdarke
我在Mac上使用gdb时遇到了一个不同的问题,但可能与此相关:https://dev59.com/dmgu5IYBdhLWcg3wMkUm - cdarke
1
相同的问题,在OSX 10.11.6(El Capitan)上。我的测试程序只是将2个整数相加并返回0-绝对没有调用'abort',并且在没有gdb的情况下运行良好。有任何解决方案吗? - Phildo
1
我尝试了其他帖子中提出的几种方法,包括重新安装gdb和更新证书。但是到目前为止,我还无法让gdb正常工作... - HerthaBSC
1
@HerthaBSC 我也遇到了同样的问题。你这边有解决方案了吗?我使用的是OSX El Capitan 10.11.6,编译器是g++-7 (Homebrew GCC 7.3.0) 7.3.0,调试工具是GNU gdb (GDB) 8.1 - Hakan Baba
你是否用简单的C程序进行测试,例如 printf("Hello\n");printf("%d\n",a + b); - Scorta
1个回答

1

我建议从头开始重新构建gdb。与使用预先构建的安装包不同,您可以尝试自己安装:

mkdir src
cd src
curl "http://ftp.gnu.org/gnu/gdb/gdb-8.0.tar.gz" -o gdb-8.0.tar.gz
tar zxf gdb-8.0.tar.gz
cd gdb-8.0
./configure --prefix=$HOME/opt/usr/local
make
make install

在使用前记得签名:https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html

这样你就可以轻松地调试你的代码了。有关安装的详细信息,请查看此处:在macOS Sierra上运行GDB


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