run
file <prog>use prog as the program to be debugged
run <arg1> <arg2>run the process with the specified arguments
runrun the process with the last specified arguments
to run the process without the last specified arguments, use before set args
set args <arg1> <arg2>set the run arguments
show argsdisplay the run arguments
killkill the process being debugged
contcontinue to run the debugged process
cont <n>when stopped at a breakpoint, continue to run until the same breakpoint is reached for the nth time
stepcontinue to run the debugged process until it reaches a different line of code including subroutine calls (i.e. goes in subroutines)
step <n>perform n steps
stepicontinue to run the debugged process up to the next instruction (i.e. goes in subroutines)
stepi <n>perform n steptis
nextcontinue to run the debugged process until it reaches a different line of code in the same routine (i.e. does not go in subroutines)
next <n>perform n nexts
nexticontinue to run the debugged process up to the next instruction of the routine (i.e. does not go in subroutines)
nexti <n>perform n nextis
returncontinue to run the debugged process until it reaches the calling routine
return <value>continue to run the debugged process until it reaches the calling routine, value is the returned value

stack
bt
where
info stack
print stack trace
upselect and display stack frame of calling routine
up <n>select and display nth upper stack frame
downselect and display stack frame of called routine
down <n>select and display nth lower stack frame
framedisplay current stack frame
frame <n>select and display stack frame number n
select-frame <n>select stack frame number n (there is no display)
list <n>display 10 lines around line number n

examination
info stackdisplay the addresses of frame, called frame, calling frame, frame arguments, frame local variables and also the language, program counter and saved register values
info argsdisplay the arguments
info localsdisplay the local variables
whatis <expr>print the type of expression expr
ptype <expr>print a description of the type of expression expr
ptype differs from whatis by printing a detailed description, instead of just the name of the type
ptype <type>print a description of type
print [/<fmt>] <expr>print the value of expression expr with format fmt
display [/<fmt>] <expr>print the value of expression expr with format fmt each time the program stops
displayprint the values of the expressions to be displayed
undisplay <expr>stop to display the expression expr

source
dir <path>add path at the beginning of the source path
the directories must be separated by : (; on Windows)
adding a directory already present in the source path moves it at the beginning
$cdir is the compilation directory
$cwd is the current working directory
show directoriesprint the source path

breakpoints
break file.c:105set a breakpoint at the line 105 of file file.c
break foobarset a breakpoint at the beginning of routine foobar
but, in order to get access to the list of all symbols, we have to start the program (break main then run) before
break 'ValueHandler2::getSt Tabautocompletion of the routine name
info breakpointslist the breakpoints
info watchpointslist the watchpoints
deleteremove all the breakpoints and watchpoints
delete <n>remove the breakpoint/watchpoint number n

info
listdisplay ten lines around the current line
disassemble <routine>disassemble a routine
info sourceshow the name of the current source file
info sourcesshow all the source files which have debugging information
info functionsshow signatures of all functions
info function <regexp>show the signatures of functions whose name matches a regexp

interaction with the shell
pwdprint working directory
shell <command>execute a shell command
set environment <var> <value>set an environment variable for the next run of the application
unset environment <var>remove a variable from the environment
show environmentshow the environment given to the next run of the application
show environment <var>show the value of the environment variable for the next run of the application

misceallaneous
quitexit
source <file>execute the commands of file file

automated launching
When debugging a process forked from another, the usual solution is to A much easier solution is to The debugger will automatically start on the child process.