Sometimes your programs can be dirty so u need to debug them. GDB is a powerfull debug tool. To use GDB simply call it :

gdm prog_to_debug

once inside GDB you can run the programm : run

and you can backtrace your error with : backtrace

Breakpoints are also available !

Very handy and easy.