Sun Studio 12 Update 1: Debugging a Program With dbx

Examining a Core File

To determine where your program is crashing, you may want to examine the core file, the memory image of your program when it crashed. You can use the where command (see where Command) to determine where the program was executing when it dumped core.

Note –

dbx cannot tell you the state of a Java application from a core file as it can with native code.

To debug a core file, type:

$ dbx program_name core


$ dbx - core

In the following example, the program has crashed with a segmentation fault and dumped core. The user starts dbx and loads the core file. Then he uses the where command to display a stack trace, which shows that the crash occurred at line 9 of the file foo.c.

% dbx a.out core
Reading a.out
core file header read successfully
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
=>[2] main(argc = 1, argv = 0xffbef39c), line 9 in "foo.c"

For more information on debugging core files, see Debugging a Core File. For more information on using the call stack, see Looking at the Call Stack.

Note –

If your program is dynamically linked with any shared libraries, it is best to debug the core file in the same operating environment in which it was created. For information on debugging a core file that was created in a different operating environment, see Debugging a Mismatched Core File .