This is Lite Plone Theme
You are here: Home Developer Guide Debuggers

Debuggers

Overview of the debuggers GDB, DDT, and Intel Inspector.

Introduction

Debuggers are an essential tool to identify and fix programming errors. It is highly recommended that you familiarize yourself with one of them and use it regularly when faced with unexpected behaviour of your program - even for simple bugs, the use of a debugger is preferable to peppering your code with print statements. Although the list of commands might seem daunting to the novice user, there are only a handful of of them that you will be needing to solve most problems. To debug your program you must first compile your code with the -g flag, and then launch the application from inside the debugger. It is also recommended that you disable optimisation via the flag -O0, otherwise the output from the debugger is likely to be confusing. On COSMOS you may need to increase the stack size before launching your application because debuggers will hugely increase the amount of memory required.

GNU Debugger (GDB)

The GNU Debugger (GDB) supports C/C++ and Fortran77/90 debugging, and is compatible with code generated via GNU and Intel compilers. It is purely command line based. GDB can be used to debug parallel (MPI) and threaded programs, although OpenMP is currently supported. The command line interface is very rich, and the documentation can be accessed by consulting the 'man' pages or looking at the official manual from the FSF online. Additionally, there are plenty of tutorials and guides available on the web. The GDB tutorial is a good starting point.

Distributed Debugging Tool (DDT)

DDT is a commercial debugger designed for debugging MPI, multi-threaded (e.g. OpenMP), hybrid MPI / multi-threaded, and CUDA applications. It is a graphical debugger, which means you can see your source code in a GUI while you are debugging. DDT will display all the MPI ranks and threads that are running, allowing you to pause the program and see where a particular MPI process or thread is in your code and see what its local variables are.

DDT has many other useful features such as a memory debugging module which will can be used to detect memory leaks, or reading and writing beyond the bounds of arrays; and an array visualiser, which allows you to view the values of a multi-dimensional array, compute statistics of the values, and also to visualise it as a 2D or 3D plot.

To use DDT, you must first be running an interactive job on one of the machines and make sure that you have X11 forwarding enabled in your SSH session (the -X flag). You then need to load the module:

$ module load allinea

You then start DDT via:

$ ddt &

...

Please see this page for good materials for using DDT.