LoginSignup
0
0

More than 5 years have passed since last update.

emacs+gdbの注意点

Last updated at Posted at 2013-06-19

Emacs+GDBで標準入力から受け取るプログラムのデバッグをする際のポイントです。

Unix

EOFの入力

適当なファイルに標準入力の項目を記入し、 run する際にリダイレクトする。
gdb> run < input.txt

Cygwin

EOFの入力

適当なファイルに標準入力の項目を記入する。

main関数にbreakを設定する。
gdb> b main

起動する。
gdb> run

起動直後に止まるので、標準入力を置き換える。
gdb> call dup2(open("input.txt", 0), 0)

継続する
gdb> c

Cygwinのやり方についてはStackOverflowにありました。
http://stackoverflow.com/questions/9031554/gdb-input-redirection-using-cygwin

おまけ

mintty+CygwinだとEOFが入力できないことがあります。Windowsはもともと ^Z が EOF 扱いですが、Cygwinだと ^Z は susp に設定されています。stty で susp を別なキーに割り当てることで、 ^Z で EOF を入力することができます。

> stty susp ^]

※ ^] の入力方法は Ctrl+V を押したのちに Ctrl+] を押します。

0
0
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
0
0