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

时间:2018-01-13 16:07:38

标签: c macos gdb homebrew osx-mavericks

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

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

Data

之后我打电话给gdb:

gcc -g test.c -o test

调用像r或sta这样的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.

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

1 个答案:

答案 0 :(得分: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

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