How to debug pvserver with MPI and gdb

A simple yet very practical way to debug pvserver with mpi and gdb.

mpirun -np 4 xterm -e gdb ./bin/pvserver -ex 'run'

This will open 4 xterm windows, one for each process and start the pvserver inside gdb. You can then place breakpoints as needed.

This does not allows to create breakpoints on all instance with a single command, they need to be repeated.

You can then connect to the pvserver as usual.

5 Likes

A great tool for performing this kind of operation is tmpi (GitHub - Azrael3000/tmpi: Run a parallel command inside a split tmux window).

By prefixing your debug command with tmpi as such:

tmpi 4 gdb ./bin/pvserver -ex 'run'

your parallel processes get attached to split tmux terminals and commands for controlling your debugger can be invoked on all processes at the same time.

I highly recommend it!

4 Likes