Skip to content

Instantly share code, notes, and snippets.

@holmanb
Last active October 22, 2021 17:07
Show Gist options
  • Save holmanb/e0bc69d36c241f9efd0f750bb87b3e68 to your computer and use it in GitHub Desktop.
Save holmanb/e0bc69d36c241f9efd0f750bb87b3e68 to your computer and use it in GitHub Desktop.

so typically I run gdb like:

gdb --with-args ./mycmd arg1 arg2

break <function name>                            # set a breakpoint
break <filename>:<function name>:<line_nr>       # set a breakpoint

run                                              # starts the program

<breakpoint hit>

bt                                               # print the backtrace
frame <number>                                   # select which frame to inspect
list                                             # show the source code around the breakpoint
print <var name>                                 # with pointers, structs, and unions you can also cast, dereference, etc using (*, &, ->, (struct type *), etc) 
info locals                                      # print all local variables
step
<repeate any/all of the above>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment