gdb不适用于Mac版High Sierra 10.13.3

luc*_*928 43 macos gdb

我用brew安装了gdb 8.1.

我有codeign gdb和.gdbinit如下:

set startup-with-shell off.

我已禁用SIP功能:

$ csrutil status
System Integrity Protection status: disabled.
Run Code Online (Sandbox Code Playgroud)

但是gdb仍然不起作用:

#include <iostream>
using namespace std;

int main() {
  cout << "hello world!" << endl;
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译命令:

g++ -g test.cpp
Run Code Online (Sandbox Code Playgroud)

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) 
Run Code Online (Sandbox Code Playgroud)

使gdb在macos sierra上运行的正确步骤是什么?

Hon*_*Liu 60

这是由最新的gdb 8.1引起的,将gdb降级到8.0.1可以解决这个问题.

如何降级到gdb 8.0.1

  • 取消链接当前gdb: brew unlink gdb
  • 安装gdb 8.0.1: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/9ec9fb27a33698fc7636afce5c1c16787e9ce3f3/Formula/gdb.rb
  • 可选:避免使用升级gdb brew pin gdb

  • 谢谢,它在降级到8.0.1后起作用 (4认同)
  • 这很有效. (4认同)
  • 经过一系列的实验,我认为这是一个在提交f6ac5f3d63e03a81c4ff3749aba234961cc9090e中引入的错误.请参阅此漏洞的主题:https://sourceware.org/bugzilla/show_bug.cgi?id = 22960 (2认同)