GDB Commands
GDB is command line utility
Good practice: Use command
gdb
with-tui
flag, it will show a gui interface.
r/run
: Start running program until a breakpoint or end of programstart
: Start running program until the begining of “main” functionb/break fun
: Set a breakpoint at the begining of function “fun”b N
: Set a breakpoint at line number N of source file currently executingb file.c:N
: Set a breakpoint at line number N of file “file.c”d/delete N
: Remove breakpoint number Ndisable
i/info b/break
: List all breakpointsc/continue
: Continues/Resumes running the program until the next breakpoint or end of programf/finish
: Runs until the current function is finisheds/step
: Runs the next line of the programs N
: Runs the next N lines of programn/next
: Like s, but it does not step into functionsp/print var
: Prints the current value of the variable “var”display, undisplay
:set var=val
: Assign “val” value to the variable “var”bt
: Prints a stack traceq/quit
: Quit from gdb