Apr. 14, 2026
GDB Tutorial
GDB , the GNU Project debugger, is a useful debugger for many languages (C, C++, Fortran, etc). Here I keep a set of useful commands for my records.
Using GDB
To use GDB, compile the program with debugging information.
For standard C++ program, add -g flag when compiling, i.e.
something like
g++ -g -o myprogram myprogram.cpp
For AMReX related application codes like Castro, compile with
DEBUG=TRUE, i.e.
make DEBUG=TRUE
Now launch GDB with compiled program as the following.