桜、抹茶、白、日記

名古屋市在住のC++使いのcoderの日記だったもの。

gdk_x_error()

Linux上でGUI操作/描画に絡む不具合があった場合にこんな感じのエラーメッセージが出るんだけど、

  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

デバッガで、gdk_x_error()にブレークポイントを設定する方法をイマイチ理解していなかったので調べてみた。

$ gdb hoge
(gdb) break main
(gdb) run --sync
(gdb) break gdk_x_error
(gdb) continue

※補足で、GTKデバッグパッケージ*1が必要ですね。関数名が分からないとブレークポイント貼れませんから。

*1:RedHat系のディストリビューションならdebuginfoのパッケージ