You can use it to find out why/where a program caused an exception that
caused the OS to perform a core-dump.
GDB requires that you compile with the gcc -g flag (include symbols) to
get useful information. If you complied without the -g flag, the core
dump will not be very useful to you.
(If you have the source file, you can recompile once more with the -g
flag, then run gdb against the new executable and the old core dump file.)
Presuming you have complied file.c into myfile with the -g flag and
running it created a core dump named 'core'
Do:
$> gdb myfile core
This will start GDB and read in 'myfile' and 'core' and process it
At the gdb prompt, type bt (for backtrace)
(gdb)$ bt
This will walk you backward through the stack trace showing you where
the exception that caused the OS to abort and cause the core-dump. You
should see a line at the end of the output identifying which line of
source code caused the abort.
*******
On solaris, you can also use dbx. Run it as:
$> dbx myfile core
The opening screen will contain the backtrace by default.