Programming in C

(Barry) #1
Debugging Programs with gdb 409

Ta b le 18.1 Common gdbCommands


Command Meaning
SOURCEFILE
list [n]^2 Displays lines around line nor next 10 lines if nis not specified
list m,n Displays lines mthrough n
list +[n] Displays lines around line nlines forward in file or 10 lines forward
if nis not specified
list –[n] Displays lines around line nlines back in file or 10 lines back if nis
not specified
list func Displays lines from function func
listsize n Specifies number of lines to display with listcommand
info source Shows current source file name
VARIABLES ANDEXPRESSIONS
print /fmt expr Prints expraccording to format fmt, which can be d(decimal),u
(unsigned),o(octal),x(hexadecimal),c(character),f(floating
point),t(binary), or a(address)
info locals Shows value of local variables in current function
set var var=expr Sets variable varto value of expr
BREAKPOINTS
break n Sets breakpoint at line n
break func Sets breakpoint at start of function func
info break Shows all breakpoints
clear [n] Removes breakpoint at line nor at next line if not specified
clear func Removes breakpoint at start of function func
PROGRAMEXECUTION
run [args] [<file] [>file] Starts program execution from the beginning
continue Continues program execution
step [n]Executes next program line or next nprogram lines
next [n]Executes next program line or next nprogram lines without step-
ping into functions
quit Quitsgdbexecution
HELP
help [cmd]Displays classes of commands or help about specific command cmd
help [class] or class


  1. Note that each command that takes a line number or function name can be preceded by an
    optional filename followed by a colon (e.g., list main.c:1,10 or break main.c:12)

Free download pdf