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:
The main commands used for debugging with gdb are:
run/kill continue/next/step break/watch print where help quit
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 https://www.hpc.kaust.edu.sa/documentation/user_guide/loadleveler_advanced/. 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: http://www.open-mpi.org/faq/?category=debugging#serial-debuggers