Debugging MPI Programs Using GDB

This skill comes from Professor Norm Matloff’s homepage: Here I make a digest of it:

  • Use the -g option, to retain the symbol table for gdb, during compiling.
  • Insert the following code to make it wait for gdb attachment during runtime:
    int DebugWait = 1;
    while (DebugWait) ;
  • Lunch the parallel program using mpiexec, make sure you know those computers on which processes are running.
  • Login to a computer, use the following bash commands to get a process id, and start gdb to attach to this process
    ps aux | grep program_name
    gdb program_name process_id
  • Use the following gdb commands to break the waiting and continue executing the process
    set DebugWait = 0