りんけーじ - 日記 - 2007年12月6日の日記



< 2007年12月 >
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345
前の日: 2007年11月26日
次の日: 2007年12月12日

2007/12/06 18:47 [gdb でデバッグできない?]

サーバで開発をしていて、デバッグをしたい。けど、起動してあるプロセスに attach しようとすると

[silky:~] root# gdb attach 24784
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...attach: No such file or directory.
Attaching to process 24784
/usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/solib-svr4.c:1443: internal-error: legacy_fetch_link_map_offsets called without legacy link_map support enabled.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y
/usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/solib-svr4.c:1443: internal-error: legacy_fetch_link_map_offsets called without legacy link_map support enabled.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n

正しくは gdb 24784 であって、attach がいらないとかはとりあえず置いておいて。

なぜか、gdb が internal error で落ちます。困ります。attach しようとした先のプロセスは detach されないので、巻き込まれて死にます。すごーく困ります。

gdb-6.7 をソースからインストールしたら symbol のフォーマットが分からんと言われて諦め、ports から入れ直しても結果は変わらず。

よく分からないから Google で検索してみたら、OpenBSD 関連のメーリングリストが引っかかりました。

これによれば、gdb の引数に実行ファイルを指定しなければならないとのこと。(というか、--pid なんてオプションがあったのに気付きました)

指定すれば確かに動くんだけど…、ほかの古い FreeBSD だと大丈夫だった気がするし、MacOS X でも問題ないし……。一々実行ファイルを指定しなきゃいけないのは面倒だし、そもそも実行開始後にファイルを書き換えたらデバッグできないということになるし。

とりあえずは間違ってファイルを書き換えないようにしたり、今までの方法でデバッグしようとして殺したりしないようにしないと…。

コメント(0) トラックバック(0)