LoginSignup
8
3

More than 5 years have passed since last update.

emacsの中からrust-gdbを起動する

Last updated at Posted at 2019-01-23

emacsの中からgdbを起動するとブレークさせた時に、現在の位置をソースコード上で確認できるので便利。rust-gdbでも同様のことができる。

emacsの中からrust-gdbを起動する

M-x gdb

を実行すると、以下のように表示される。

Run gdb (like this): gdb -i=mi

rust-gdbを使用する場合は、これを以下のように書き換える。
-i=mi のオプションはemacsとgdbの間の通信に関するものなので必ずつける。

Run gdb (like this): rust-gdb -i=mi 

実行ファイルがtarget/debug/execfile
実行時の引数が --debug --output=out1
ブレークさせたいところが scuInit の場合の例

*gud*のバッファで

(gdb) file target/debug/execfile
(gdb) set args --debug --output=out1
(gdb) b scuInit
(gdb) r

これで scuInitでブレークする。
何度も同じ設定を使用する場合は .gdbinit に書けばよいはず。

RustのプログラムにリンクしているC++のライブラリの関数にも区別なくブレークポイントを設定できる。

ソースコードバッファからブレークポイントを設定する

ソースコードを表示しているところで現在カーソルのある行にブレークポイントを設定するには

M-x gud-break

または

C-x C-a C-b
8
3
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
8
3