The linux kernel is able to write a so called core dump if some application crashes. This core dump records the state of the process at the time of the crash. gdb can read such a core dump and get informations out of it.
Most distributions have core dumps disabled by default, thus you'll have to reenable them first
root ~ ] $ ulimit -c unlimited
Now, you will see:
root ~ ] Segmentation fault (core dumped)
instead of
root ~ ] Segmentation fault
The dumped core file is located into the current directory like: "core" or "core.pid"
Now, you can use GDB to dissect your program.
Reference:
http://linux.bytesex.org/gdb.html
Have fun!@