GDB - GNU debugger#

gdb without any arguments automatically uses a.out

C programs should be compiled with -g -Og

To make a program produce a core file for debugging with gdb after-the-fact do: ulimit -c unlimited

gdb  myProgram  [core]

run [args] r run the program
kill k stop program from running
quit q exit debugger
help h
^C stop / interrupt the program
continue c continue execution
list l show program code
next n go over next line
step s go into next line
finish fin exit stack frame (go up)
print x p print value of x
backtrace bt show stack
frame n f change to stack frame n
info locals i lo display local variables
info args i ar display command line arguments
info frame i f stack frame information

Breakpoints#

break file.c:45 b set breakpoint at line 45 of file.c
break myfun b set breakpoint at beginning of myfun()
info breakpoints i br list breakpoints
disable 2 disable breakpoint 2
clear XXXX cl delete breakpoint at location XXXX
delete nnn d delete breakpoint number nnn

When lines are displayed, it is showing the line that is about to be executed, not the line that was just executed.

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-5) was last changed on 25-Jul-2021 11:23 by BlakeMcBride