c - 中止陷阱 6 : when running gdb on Mac OS

标签 c macos gdb homebrew osx-mavericks

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

在使用 gdb 开始调试 session 之前,我像这个例子一样编译了我的 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

问题是什么?有什么解决办法吗?

最佳答案

我建议从头开始重建 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

这样,您就可以轻松地调试代码。安装详情请看这里:Running GDB in macOS sierra

关于c - 中止陷阱 6 : when running gdb on Mac OS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48241639/

相关文章:

c++ - OSX 上的 libxml2 和 libxml2-dev

c++ - 在 C 或 C++ 代码中以编程方式为 Linux 上的 gdb 设置断点

c++ - 如何在 gdb 中的内存位置添加断点

c - 程序每次从文件中扫描矩阵时都会跳过一行!

c - 是否可以将整个数组保存在 cpu 寄存器中

c - 使用命令行参数声明结构

r - 在 CRAN 上传递 R 包,并在 MACOS 上有问题 + OpenMP

python - tensorflow : "trying to mutate a frozen object",巴泽尔

c - 如何修复 x86_64 内存偏移量 (GAS)?

C 链表传递列表作为函数的参数