gdbはmacOS High Sierra 10.13.3では動作しません。質問する

gdbはmacOS High Sierra 10.13.3では動作しません。質問する

brewでgdb 8.1をインストールしました。

以下のように、codesign 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 で動作させるための正しい手順は何ですか?

ベストアンサー1

これは最新の 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

おすすめ記事