[Linux] coreファイルをgdbで調べてみる

前の記事で採取したcoreファイル(ちょっとファイル名が違うけど)を、gdbを使って調べてみる。

gdbに実行ファイル(./test_core)をcoreファイル(./core.5857)を指定して、起動する(下記の下線部分)。
$ gdb ./test_core -c ./core.5857
GNU gdb Red Hat Linux (6.5-37.el5_2.2rh)
Copyright (C) 2006 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-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".


warning: Can't read pathname for load map: 入力/出力エラーです.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./test_core'.
Program terminated with signal 8, Arithmetic exception.
#0  0x08048376 in main () at test_core.c:3
3               int i = 10 / 0;
(gdb)
最後の赤い部分から、このプログラムがtest_core.cの3行目のint i = 10 / 0;の処理でシグナル8(浮動小数点例外)で異常終了したことが分かる。

コメント