Basic Info

Posted by Beetle B. on Wed 09 October 2019

To start gdb on a certain program, type gdb progname.

If, for whatever reason, you want to change the width of the text (to fit in your console), do

set width 70

To break on a particular function, do:

break function_name

Or

b function_name

To start execution, type run

Once you are at a breakpoint, type n to go to the next line, or s to step into the function at the current line.

At any point, if you want to see where you are in the stack, type backtrace or bt.

To see the value of a variable var, do:

p var

p is for print.

To see some of the code around your current point, type l (for list).

If you want to modify the value of a variable, use p again:

p var=value

Note that value could be a function call.

To continue execution, type c for continue.

To quit, type q or quit. Can also do EOF (Ctrl-d in Linux).

You can execute shell commands from within via

shell command

Or

!command

You can always type help to get some help. If you want to search all of help for a word, use apropos.

If you want to see the breakpoints that have been set, do either of the following:

info breakpoints
i breakpoints

tags : gdb