要确定程序发生崩溃的位置,可能需要检查信息转储文件,即程序崩溃时的程序内存映像。 可使用 where 命令确定程序在转储信息时的执行位置。请参见where 命令
$ dbx program-name core
或
$ dbx - core
在下面的示例中,程序因段故障和转储核心而崩溃。首先,dbx s 从装入的信息转储文件开始。然后,where 命令显示堆栈跟踪,其中显示在 foo.c 文件的第 9 行发生崩溃。
% dbx a.out core
Reading a.out
core file header read successfully
Reading ld.so.1
Reading libc.so.1
Reading libdl.so.1
Reading libc_psr.so.1
program terminated by signal SEGV (no mapping at the fault address)
Current function is main
9 printf("string ’%s’ is %d characters long\n", msg, strlen(msg));
(dbx) where
[1] strlen(0x0, 0x0, 0xff337d24, 0x7efefeff, 0x81010100, 0xff0000), at
0xff2b6dec
=>[2] main(argc = 1, argv = 0xffbef39c), line 9 in "foo.c"
(dbx)