GDB Cheat Sheet
Launch GDB
# - break at first line in main
# - binary + application arguments to use
gdb \
-ex "break +2" \
-ex "run" \
--args <path to binary>/<binary> <application arguments>
Run
(gdb) run # start program to be debugged
Break
# break at certain position
(gdb) break (b) <full path to file>/<filename.extension>:<line number>
# if file in shared library: confirm future load information
Break in the main function
(gdb) break main
Step
(gdb) step (s) # goes to next instruction
(gdb) next (n) # jumps to next breakpoint
View Variable Values
(gdb) p <variablename>
Stop Debugging
(gdb) kill # terminates program
(gdb) quit # terminates gdb session
Launch GDB for remote debugging
(gdb) -x atxtfile
example text file:
target remote tstci02:10000 break 2
#symbol-file remote:/opt/slits/fesa/MBoxDeployUnit_M
symbol-file ../../../build/bin/i686/MBoxDeployUnit_M
directory ../../../
Use GDB for Remote Debugging
(gdb) b / break main
(gdb) c / continue