What is GDB
GDB (GNU Debugger) is a command-line debugger from the GNU Project that lets you inspect, pause, and alter programs as they run or analyze them after a crash. It is an essential tool when exploring WHY something went wrong in your tool in a precise and methodical way (i.e., without having to fill every other line of code with print statements). There are multiple extensions and integrations that rely on GDB: some make it more suited for cybersecurity, like pwndbg, and other simply make GDB easier to use, like the common integration in IDE and code text editors.
Command line
Stack-related commands
Show the backtrace (i.e., the stack trace that lead to the current breakpoint).
# Show the list of stack frames
bt
# Show the last 10 stack frames
bt 10
# Show the full list of stack frames
bt full
Show the current frame
# Show the current frame
f
# Show frame number 2
f 2
Move around the stack frames.
# Move up a stack frame
up
# Move up 3 stack frames
up 3
# Move down a stack frame
down
# Move down 4 stack frames
down 4
Show additional information on the current frame.
# Show all details of the current frame
info frame
# Show the argument for the function call of the current frame
info args
# Show the local variable visible in the current frame
info locals