macos - gdb 不适用于 macos High Sierra 10.13.3

标签 macos gdb

我已经用brew安装了gdb 8.1。

我也有 codesign gdb 和 .gdbinit,如下所示:

关闭 shell 启动

我已禁用 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 上工作的正确步骤是什么?

最佳答案

这是由最新的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
  • 可选:避免使用 brew pin gdb 升级 gdb

关于macos - gdb 不适用于 macos High Sierra 10.13.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49001329/

相关文章:

c - 如何通过 dockerfile 禁用 linux 空间随机化?

gdb - D2和gdb问题

macos - 在 Visual Studio for Mac (Xamarin) 中签署 Mac 应用程序

ios - 为什么 Google 日历没有显示在 SwiftUI macOS 上的 EKCalendarChooser 中

html - 不同屏幕尺寸的网站显示不同

c - GDB:重新运行程序直到出现故障,一路上回答提示

c - 使用 Netbeans/gdb 调试 C 会立即终止并出现 SIGSEGV?

c++ - gdb 核心转储打开失败

objective-c - 无法在 macOS 应用程序上运行 xctest - 无法加载,因为它已损坏或缺少必要的资源

linux - 从 osx 守护进程运行 selenium bash 脚本