gnu debugger

gdb is a useful debugger

for c segmentation faults, you may also want address sanitizer

useful commands

gdb has tons of commands. these are the ones i use most often.

abbrevcommanddescription
rrunstart execution, from the beginning
bbreakcreate a breakpoint
ddeletedelete a breakpoint or clear all breakpoints
sstepdo one instruction
nnextstep until the next line
fframeshow where you are in execution again
finfinishstep until the current funtion returns
llistshow the source code
pprintget the value of variable
btbacktraceshow the backtrace

logging

enable logging to gdb.txt with set log en on (short for set logging enabled on )

full backtrace

an extra verbose backtrace can be obtained with bt full. if the program has multiple threads, this can be applied to all of them with th a a bt full (short for thread apply all backtrace full)

debuginfod

gdb supports an automatic debug symbol downloading service called debuginfod. this means you will usually not have to go search for a package providing debug symbols for some library and restart your debugging.