6
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mac OS 10.13(High Sierra) で Eclipse のデバッグに gdb を使う

Last updated at Posted at 2018-01-04

こちら の投稿で、mac OS 10.13(High Sierra) で gdb を使ったデバッグ環境を作成した。

今回はその続きで、Eclipse のデバッグに gdb を使おうとしてハマったのでメモ。

Eclipse のバージョン

Eclipse -> Eclipse について メニューで確認。

Eclipse IDE for C/C++ Developers

Version: Oxygen.2 Release (4.7.2)
Build id: 20171218-0600

gdb のバージョンとパス

ターミナルから確認。

$ gdb -v
GNU gdb (GDB) 8.0.1
...

$ which gdb
/usr/local/bin/gdb

.gdbinit の作成

Eclipse から gdb でデバッグを実行させる際に設定が必要になるため、/Users/(username)/.gdbinit ファイルを作成する。

$ ls ~/.gdbinit
ls: /Users/(username)/.gdbinit: No such file or directory
.gdbinit
set startup-with-shell off

Eclipse の設定

Eclipse の 環境設定 メニュー の GDB 項目を編集する。

  • Eclipse -> 環境設定
    • C/C++ -> デバッグ -> GDB
      gdb デバッガー: /usr/local/bin/gdb
      GDB コマンド・ファイル: /Users/(username)/.gdbinit Eclipse_setting_001.png

「適用して閉じる」を選択する。

上記の設定で、これから作成するプロジェクトについては gdb のパス・コマンドが設定されているが、すでに開いているプロジェクトについては適用されていないことがあるので、手動で書き換える。

  • プロジェクトを右クリック -> デバッグ -> デバッグ の構成...
    • C/C++ アプリケーション -> デバッガー
      gdb デバッガー、GDB コマンド・ファイル の設定を確認する。 Eclipse_setting_002.png

「デバッグ」を選択すると、デバッグが開始される。

gdb の設定をしていない場合に発生するエラー

gdb の設定が正しく行われていない場合は、以下のようなエラーが発生していた。

gdb デバッガーのパスが正しくない場合

gdb デバッガー のパスが正しくない場合は、"Error with command: gdb --version" が発生する。

Eclipse_setting_003.png

GDB コマンド・ファイル の設定が正しくない場合

GDB コマンド・ファイルの設定が正しくない場合は、"Error in final launch sequence" が発生する。

Eclipse_setting_004.png

6
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?