gdb ./[program] : debug program with GDBgdb --args ./[program] [args] : debug program with GDBmust compile the program using flags -O0 -g.
r: run programbt : show call stack / backtraceup : move up call stackdown : move down call stackframe : show stack framen : nexts : step intoc : continuefinish : step out of functionni : next instructionsi : step into instructionq : quitb [line] : add breakpoint at line X of current fileb [function] : add breakpoint at function Xb *[address] : add breakpoint at address/pointer Xinfo break : list breakpointsclear : delete all breakpointswatch [X] : add watchpoint on variable Xp [X] : print variable Xp/x [X] : print variable X in hexadecimalp [c expression] : print C expressiondisplay [X] : print variable X each stepwhat [X] : print type of variable Xi frame : show stack framei locals : show local variablesi args : show function argsi registers ax rip rbp cs ss ds : show registersdisplay/i $pc : show PC when changedx/100xg $sp : print stack memoryset var [X] : change variable valuel : shows the next set of codel - : show the prev set of codel [line] : show code on line Xl [start line, end line] : show code at line S to El [function] : show code of function Xdisassemble : show ASM codefile [code file] : load code filefile [bin] : load ELF bin and symbolstui enable/disable : enable tui for split viewlayout split : layout code/asmlayout asm : layout asmlayout reg : layout regiserstarget record-full : enable reverse debuggingrn : reverse nextrs : reverse steprc : reverse continuemight not always work properly!
tar rem [ip]:[port] : connect to remote target (localhost -> :1234)symbol-file [bin] : load symbolsgdb -x=[script.gdb] : load GDB script (text file with a list of GDB commands)valgrind ./[program] : run program under valgrindmust compile the program using flags -O0 -g.