我已经用brew安装了gdb 8.1。
我还有gdb和gdbinit的编码,如下所示:
set startup-with-shell off
。
我已禁用SIP功能:
$ csrutil status
System Integrity Protection status: disabled.
但是gdb仍然不起作用:
#include <iostream>
using namespace std;
int main() {
cout << "hello world!" << endl;
return 0;
}
编译命令:
g++ -g test.cpp
gdb输出:
GNU gdb (GDB) 8.1
Copyright (C) 2018 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-darwin17.3.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 a.out...Reading symbols from /Users/mypc/Downloads/a.out.dSYM/Contents/Resources/DWARF/a.out...done.
done.
(gdb) run
Starting program: /Users/mypc/Downloads/a.out
[New Thread 0x2503 of process 802]
[New Thread 0x2303 of process 802]
During startup program terminated with signal ?, Unknown signal.
(gdb)
使gdb在macos sierra上运行的正确步骤是什么?
答案 0 :(得分:59)
这是由最新的gdb 8.1引起的,将gdb降级到8.0.1可以解决这个问题。
brew unlink gdb
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/9ec9fb27a33698fc7636afce5c1c16787e9ce3f3/Formula/gdb.rb
brew pin gdb
答案 1 :(得分:2)
在我的情况下,降级到8.0.1并没有帮助 但是以下步骤有所帮助。
(我插入了步骤12,&#34;检查它是否有效&#34;因为,我没有重新启动我测试过的gdb而且工作正常。我没有按照步骤12+)
gdb-cert
)
killall taskgated
codesign -fs gdb-cert /usr/local/bin/gdb
command-R
直到出现Apple徽标)csrutil enable --without debug
信息来源:
塞拉之前:https://gist.github.com/hlissner/898b7dfc0a3b63824a70e15cd0180154
塞拉利昂:https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d
答案 2 :(得分:0)
我正在使用macOS 10.13.6,但遇到的问题是“((请检查gdb是否已进行代码签名-请参阅taskgated(8))” ...
当我将GDB从8.2.1降级到8.0.1,然后再次创建并签署了gdb-cert之后,它就可以正常工作了。
别忘了在eclipse调试器中将gdb的路径从8.2.1更改为8.0.1,重新启动即可使用。