GDB QUICK REFERENCE GDB Version 4 Breakpoints and Watchpoints Execution Control
continue[count] continue running; if count specified, ignore
break[file:]line set breakpoint at line number [in file]
this breakpoint next count times
eg: breakmain.c:37
Essential Commands c[count]
b[file:]line
gdbprogram [core] debug program [using coredump core]
break[file:]func set breakpoint at func [in file]
step[count] execute until another line reached; repeat
b[file:]function set breakpoint at function [in file]
break+offset set break at offset lines from current stop count times if specified
s[count]
break-offset
run[arglist] start your program [with arglist]
stepi[count] step by machine instructions rather than
break*addr set breakpoint at address addr
bt backtrace: display program stack
source lines
si[count]
break set breakpoint at next instruction
pexpr display the value of an expression
break. . .ifexpr break conditionally on nonzero expr
c continue running your program
next[count] execute next line, including any function
condn [expr] new conditional expression on breakpoint
n next line, stepping over function calls
calls
n[count]
n; make unconditional if no expr
s next line, stepping into function calls
tbreak. . . temporary break; disable when reached nexti[count] next machine instruction rather than
rbreakregex break on all functions matching regex source line
ni[count]
Starting GDB
watchexpr set a watchpoint for expression expr
gdb start GDB, with no debugging files catchevent break at event, which may becatch, until[location] run until next instruction (or location)
gdbprogram begin debugging program throw,exec,fork,vfork,load, or
finish run until selected stack frame returns
gdbprogram core debug coredump core produced by unload.
return[expr] pop selected stack frame without
program
infobreak show defined breakpoints executing [setting return value]
gdb--help describe command line options
infowatch show defined watchpoints
signalnum resume execution with signal s (none if0)
jumpline resume execution at specified line number
clear delete breakpoints at next instruction
jump*address or address
Stopping GDB
setvar=expr evaluate expr without displaying it; use
clear[file:]fun delete breakpoints at entry to fun()
quit exit GDB; alsoqorEOF(egC-d)
for altering program variables
INTERRUPT (egC-c) terminate current command, or
clear[file:]line delete breakpoints on source line
send to running process
delete[n] delete breakpoints [or breakpoint n]
Display
Getting Help print[/f ] [expr] show value of expr [or last value$]
disable[n] disable breakpoints [or breakpoint n]
according to format f:
help list classes of commands p[/f ] [expr]
enable[n] enable breakpoints [or breakpoint n]
helpclass one-line descriptions for commands in
x hexadecimal
enableonce[n] enable breakpoints [or breakpoint n];
class
d signed decimal
disable again when reached
helpcommand describe command
u unsigned decimal
enabledel[n] enable breakpoints [or breakpoint n]; o octal
delete when reached t binary
Executing your Program
a address, absolute and relative
ignoren count ignore breakpoint n, count times
runarglist start your program with arglist
c character
run start your program with current argument
f floating point
commandsn execute GDB command-list every time
list
[silent] breakpoint n is reached. [silent call[/f ] expr likeprintbut does not displayvoid
run. . .
outf start your program with input, output
command-list
redirected
suppresses default display]
x[/Nuf ] expr examine memory at address expr; optional
end end of command-list
kill kill running program format spec follows slash
N count of how many units to display
ttydev use dev as stdin and stdout for nextrun u unit size; one of
Program Stack
setargsarglist specify arglist for nextrun bindividual bytes
backtrace[n] print trace of all frames in stack; or of n
setargs specify empty argument list hhalfwords (two bytes)
frames innermost if n>0, outermost if
bt[n]
showargs display argument list wwords (four bytes)
n<0
ggiant words (eight bytes)
frame[n] select frame number n or frame at address
showenv show all environment variables f printing format. Anyprintformat, or
n; if no n, display current frame
showenvvar show value of environment variable var snull-terminated string
upn select frame n frames up
setenvvar string set environment variable var imachine instructions
downn select frame n frames down
unsetenvvar remove var from environment
disassem[addr] display memory as machine instructions
infoframe[addr] describe selected frame, or frame at addr
infoargs arguments of selected frame
Shell Commands
Automatic Display
infolocals local variables of selected frame
cddir change working directory to dir
inforeg[rn]. . . register values [for regs rn] in selected display[/f ] expr show value of expr each time program
pwd Print working directory
frame;all-regincludes floating point stops [according to format f ]
make. . . call make infoall-reg[rn]
display display all enabled expressions on list
shellcmd execute arbitrary shell command string
undisplayn remove number(s) n from list of
automatically displayed expressions
disabledispn disable display for expression(s) number n
[ ] surround optional arguments . . . show one or more arguments
enabledispn enable display for expression(s) number n
infodisplay numbered list of display expressions
©1998 Free Software Foundation, Inc. Permissions on back
Expressions Controlling GDB Source Files
expr an expression in C, C++, or Modula-2 setparam value set one of GDB s internal parameters dirnames add directory names to front of source
(including function calls), or: showparam display current setting of parameter path
addr@len an array of len elements beginning at dir clear source path
Parameters understood bysetandshow:
addr showdir show current source path
complaintlimit number of messages on unusual symbols
file::nm a variable or function nm defined in file
confirmon/off enable or disable cautionary queries
list show next ten lines of source
{type}addr read memory at addr as specified type
editingon/off controlreadlinecommand-line editing
list- show previous ten lines
$ most recent displayed value heightlpp number of lines before pause in display
listlines display source surrounding lines, specified
$n nth displayed value
languagelang Language for GDB expressions (auto,cor
as:
$$ displayed value previous to $
modula-2)
[file:]num line number [in named file]
$$n nth displayed value back from $
listsizen number of lines shown bylist
$ last address examined withx
promptstr use str as GDB prompt [file:]function beginning of function [in named file]
$ value at address $
radixbase octal, decimal, or hex number
+off off lines after last printed
$var convenience variable; assign any value
representation
-off off lines previous to last printed
verboseon/off control messages when loading symbols
*address line containing address
showvalues[n] show last 10 values [or surrounding $n] widthcpl number of characters before line folded
listf,l from line f to line l
writeon/off Allow or forbid patching binary, core files
showconv display all convenience variables infolinenum show starting, ending addresses of
(when reopened withexecorcore)
compiled code for source line num
history. . . groups with the following options: infosource show name of current source file
Symbol Table
h. . . infosources list all source files in use
infoaddresss show where symbol s is stored hexpoff/on disable/enablereadlinehistory expansion
forwregex search following source lines for regex
hfilefilename file for recording GDB command history
revregex search preceding source lines for regex
infofunc[regex] show names, types of defined functions
hsizesize number of commands kept in history list
(all, or matching regex)
hsaveoff/on control use of external file for command
infovar[regex] show names, types of global variables (all,
GDB under GNU Emacs
history
or matching regex)
M-xgdb run GDB under Emacs
print. . . groups with the following options:
whatis[expr] show data type of expr [or$] without C-hm describe GDB mode
p. . .
evaluating;ptypegives more detail M-s step one line (step)
ptype[expr]
paddresson/off print memory addresses in stacks, values
M-n next line (next)
ptypetype describe type, struct, union, or enum
parrayoff/on compact or attractive format for arrays
M-i step one instruction (stepi)
pdemanglon/off source (demangled) or internal form for
C-cC-f finish current stack frame (finish)
C++ symbols
GDB Scripts
M-c continue (cont)
pasm-demon/off demangle C++ symbols in machine-
sourcescript read, execute GDB commands from file M-u up arg frames (up)
instruction output
script
M-d down arg frames (down)
pelementslimit number of array elements to display
C-x& copy number from point, insert at end
definecmd create new GDB command cmd; execute
pobjecton/off print C++ derived types for objects
C-xSPC (in source file) set break at point
command-list script defined by command-list
pprettyoff/on struct display: compact or indented
end end of command-list
punionon/off display of union members
documentcmd create online documentation for new GDB
GDB License
pvtbloff/on display of C++ virtual function tables
help-text command cmd
showcopying Display GNU General Public License
end end of help-text
showwarranty There is NO WARRANTY for GDB.
showcommands show last 10 commands
Display full no-warranty statement.
showcommandsn show 10 commands around number n
Signals showcommands+ show next 10 commands
handlesignal act specify GDB actions for signal:
print announce signal
Working Files
noprint be silent for signal
file[file] use file for both symbols and executable;
stop halt execution on signal Copyright ©1991, 92, 93, 98 Free Software Foundation, Inc.
with no arg, discard both
nostop do not halt execution Roland H. Pesch
core[file] read file as coredump; or discard
pass allow your program to handle signal The author assumes no responsibility for any errors on this card.
nopass do not allow your program to see signal
exec[file] use file as executable only; or discard
This card may be freely distributed under the terms of the GNU
infosignals show table of signals, GDB action for each
symbol[file] use symbol table from file; or discard General Public License.
loadfile dynamically link file and add its symbols
Please contribute to development of this card by annotating it.
Debugging Targets
add-symfile addr read additional symbols from file,
Improvements can be sent to bug-gdb@gnu.org.
targettype param connect to target machine, process, or file dynamically loaded at addr
helptarget display available targets
infofiles display working files and targets in use
GDB itself is free software; you are welcome to distribute copies of
attachparam connect to another process
pathdirs add dirs to front of path searched for
it under the terms of the GNU General Public License. There is
detach release target from GDB control
executable and symbol files
absolutely no warranty for GDB.
showpath display executable and symbol file path
infoshare list names of shared libraries currently
loaded
Wyszukiwarka
Podobne podstrony:
Quick Reference Guide pl
CSS2 Quick Reference
w cusb20 Microsoft Office 2010 Free Quick Reference Card
quick reference
HP DesignJet 430 Quick Reference Service Manual
Microsoft Excel 2004 Quick Reference Card
Quick reference guide Fluke 1653
30 Quick Fixes For Everyday Disasters
w cusb05 Windows 7 Free Quick Reference Card
HARP Monsters A Field Guide Quick Reference
w cusb04 Share Point Foundation 2010 Free Quick Reference Card
BPMN Quick Reference Guide
quick reference pl
w cusbXX Microsoft Excel 2010 Free Quick Reference Card
więcej podobnych podstron