Debugging Tools

Debugging tools allow you to see what is going on inside your program as it runs and let you see what your program was doing when it crashed. Learning to use a debugger can save you hours/days/months of time over trying to find and fix bugs using only output statements.

General debuggers

General debuggers, like gdb, allow you to examine a program's state (variables, stack frame contents, etc.), allow you to set breakpoints to stop the program at a certain points to examine its state, allow you to step through the execution one instruction at a time, and allow you to alter the value of your program's state (change a variable's value, call a function) as it runs. gdb and ddd are debuggers you can use for C or C++ programs. ddd is an easy-to-use GUI wrapper around an inferior debugger (gdb for GNU compiled C or C++ code).

GDB Guide:
"how to use gdb" information, including information on compiling C (and C++) programs for use with gdb, running gdb, keyboard shortcuts, commonly used gdb commands, gdb and make, example gdb sessions, tips on setting breakpoints in C++ code, and links to GDB references.

Some sample programs that you can copy and try out with gdb are available here: /home/newhall/public/gdb_examples/

Debugging tools for Java

Memory debuggers

Memory debuggers find errors in how your program accesses memory. valgrid is a tool for finding heap memory access errors in C and C++ programs (memory leaks, reading uninitialized memory, accessing unallocated memory, array out-of-bounds errors, ...). These are often the types of program bugs that are very difficult to find, as the cause of the bug (ex. an out-of-bounds array write), may trigger your program crashing in a seemingly unrelated part (like reading the value of a different variable). Valgrind can quickly point you to the source and type of these memory access bugs in your program code. It is pretty easy to learn to use, and the effort you put in to learning how to use it will be more than made up for by the debugging time you save by using it.

Valgrind Guide: information on how to use valgrind with a sample session and links to valgrind references.

Some sample programs that you can copy and try out with valgrind are available here: /home/newhall/public/purify_valgrind_examples/

Performance debuggers

There are also performance debugging tools. Typically, they collect performance data as your program runs and the data are used to identify inefficiencies in your program. gprof is one example of a performance tool.