Difference between revisions of "GDB"

From UFRC
Jump to navigation Jump to search
m
Line 1: Line 1:
[[Category:Software]]
+
[[Category:Software]][[Category:Software Development]]
 
{|<!--CONFIGURATION: REQUIRED-->
 
{|<!--CONFIGURATION: REQUIRED-->
 
|{{#vardefine:app|gdb}}
 
|{{#vardefine:app|gdb}}

Revision as of 19:20, 3 June 2022

Description

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 https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html#Pretty-Printing 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:

python
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)
end
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:
  builtin
    mpx_bound128
  libstdc++-v6
    __gnu_cxx::_Slist_iterator
    __gnu_cxx::__8::_Slist_iterator
    ...
    ...