Using the GDB debugger

GDB is a GNU serial debugger that allows users to inspect what is going on inside programs during execution. It supports C, C++ and Fortran programs. GDB can be used to debug a single process in a parallel job. Errors like segmentation faults may be easier to find with the help of gdb. It works fine with all compilers GNU, INTEL and IBM.

First we compile using the debug flag '-g':

gcc -g -o execFile srcFile.c

After compiling we launch gdb with:

gdb execFile

The main commands used for debugging with gdb are:


Then we compile with '-g' flag as follows:

mpicc -g -o execFile srcFile.c  

To debug parallel programs we first should have an xterm running, this best achievd by using an interactive job launched by LoadLeveler (see Now we launch gdb with

mpirun -np 4 xterm -e gdb execFile

This command generates 4 gdb running xterms. Each terminal corresponds to a different MPI "processor".

More details are available in the following link: