Sun Studio 12 Update 1:使用 dbx 调试程序

检查核心转储文件

确定程序发生崩溃的位置,可能需要检查核心转储文件,即程序崩溃时的程序内存映像。可使用 where 命令(请参见where 命令)确定程序在转储核心时的执行位置。


注 –

dbx 无法像对待本机代码那样通过核心转储文件来指明 Java 应用程序的状态。


要调试核心转储文件,请键入:


$ dbx program_name core


$ dbx - core

在下面的示例中,程序因段故障和转储核心而崩溃。用户启动 dbx 并装入核心转储文件。然后使用 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)

有关调试核心转储文件的更多信息,请参见调试核心转储文件。有关使用调用栈的更多信息,请参见查看调用栈


注 –

如果程序与共享库动态链接,最好在创建核心转储文件的操作环境中调试该文件。有关如何调试在不同的操作环境中创建的核心转储文件的信息,请参见调试不匹配的核心转储文件