Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Examining a Core File

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


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

or

$ dbx - core

In the following example, the program has crashed with a segmentation fault and dumped core. First, dbx s started with the core file loaded. Then, the where command displays 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
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)

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


Note -  If your program is dynamically linked with any shared libraries, 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.