我已经通过 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/