Revision as of 16:13, 9 January 2023 by Israel.herrera (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


gdb website  

GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it crashed.

GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

  • Start your program, specifying anything that might affect its behavior.
  • Make your program stop on specified conditions.
  • Examine what has happened, when your program has stopped.
  • Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.

Environment Modules

Run module spider gdb to find out what environment modules are available for this application.

System Variables

  • HPC_GDB_DIR - installation directory
  • HPC_GDB_BIN - executable directory

Additional Information

Pretty Printing

See for information on pretty printers in GDB.

Pretty printers are provided by the compiler module (i.e. gcc/9.3.0), so you will need to load the GCC module and customize your ~/.gdbinit file:

Create or modify ".gdbinit" in your home directory so that it contains the following code to look for and load the compiler module's pretty-print driver:

import os, sys
gcc_python_dir = os.environ.get('HPC_GCC_PYTHON_DIR')
if gcc_python_dir:
   sys.path.insert(0, gcc_python_dir)
   from libstdcxx.v6.printers import register_libstdcxx_printers
   register_libstdcxx_printers (None)
it is Python, so indentation matters!

Whenever you load the GDB module, load the appropriate GCC module along with it:

module load gdb/9.2 gcc/9.3.0

Now, when you start GDB, the libstdcxx pretty-printers will be available:

$ gdb -q
(gdb) info pretty-printer 
global pretty-printers: