Notes on debugging

The GNU Project debugger, displays what is going on 'inside' a program while it executes - or what it was doing at the moment it crashed.

Commands

gdb ./programstarts gdb
runexecutes the code
ssteps to the next line
njumps over the next function
ccontinues execution
lprints 5 lines above and below current statement
breaksets a breakpoint either at line number of function name
watchstops the execution everytime a variable value changes
displayprints a variable value on execution stops
infodisplays information on breakpoints and watchpoints
clear #removes the breakpoint at line #
condition 1 i == "test"breaks at breakpoint 1 when i is "test"

Links

incoming(1) | clang