中止陷阱6:在Mac OS上运行gdb时

Her*_*BSC 11 c macos homebrew gdb osx-mavericks

我已经通过自制软件在我的Mac(使用Mac OS 10.9/Mavericks)上安装了gdb并成功对其进行了编码.

在使用gdb启动调试会话之前,我编译了我的C文件,如下例所示:

gcc -g test.c -o test
Run Code Online (Sandbox Code Playgroud)

之后我打电话给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.
Run Code Online (Sandbox Code Playgroud)

调用像r或sta这样的gdb命令总会导致以下错误:

(gdb) r 
Abort trap: 6
Run Code Online (Sandbox Code Playgroud)

问题是什么?任何想法如何解决它?

Oo.*_*.oO 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
Run Code Online (Sandbox Code Playgroud)

请记住在使用之前对其进行签名:https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html

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