GDB (project, documentation) is a simple debugging tool for GNU command line systems.
You can Google around for lots of information about it. A short tutorial, a longer tutorial, and a reference card are pretty easy to find.
For GDB to be most effective, you should compile your code with the -g flag to leave debugging symbols in your executable. This will do things like leave variable names and line numbers in the executable so that GDB can show you what/were things are.
The commands that you will use the most are: