1 %This file is TeX source for a reference card describing GDB, the GNU debugger.
2 %Copyright (C) 1991 Free Software Foundation, Inc.
3 %Permission is granted to make and distribute verbatim copies of
4 %this reference provided the copyright notices and permission notices
5 %are preserved on all copies.
7 %TeX markup is a programming language; accordingly this file is source
8 %for a program to generate a reference.
10 %This program is free software; you can redistribute it and/or modify
11 %it under the terms of the GNU General Public License as published by
12 %the Free Software Foundation; either version 1, or (at your option)
15 %This program is distributed in the hope that it will be useful, but
16 %WITHOUT ANY WARRANTY; without even the implied warranty of
17 %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 %General Public License for more details.
20 %You can find a copy of the GNU General Public License in the GDB
21 %manual; or write to the Free Software Foundation, Inc.,
22 %675 Mass Ave, Cambridge, MA 02139, USA.
29 % Palo Alto, CA 94301 USA
33 % Cygnus Support is an organization devoted to commercial
34 % support of free software. For general information
40 \def\$#1${{#1}}% Kluge: collect RCS revision info without $...$
41 \xdef\manvers{\$Revision$}%
44 \hyphenpenalty=5000\tolerance=2000\raggedright
53 \normalbaselineskip=9pt\baselineskip=9pt
57 \footline={\vbox to0pt{\hss}}
59 \def\ctl#1{{\tt C-#1}}
60 \def\opt#1{{\brm[{\rm #1}]}}
61 \def\xtra#1{\noalign{\smallskip{\tt#1}}}
63 \long\def\sec#1;#2\endsec{\vskip 1pc
70 &\vtop{\hsize=2.1in\hangafter=1\hangindent=0.5em
71 \rm ##\par\vskip 2pt}\cr
72 %Tail of \long\def fills in halign body with \sec args:
73 \noalign{{\bbf #1}\vskip 2pt}
78 {\vbbf GDB QUICK REFERENCE}
80 {\smrm GDB Version 4.00---Cygnus Support 1991}
83 gdb&starts GDB, with no debugging files\cr
84 gdb {\it program}&begin debugging {\it program}\cr
85 gdb {\it program core}&debug coredump {\it core} produced by {\it program}\cr
89 quit&Exit GDB; abbreviate as {\tt q} or {\tt EOF}\par (eg \ctl{d})\cr
90 INTERRUPT&(eg \ctl{c}) terminate current command\cr
94 help&List classes of commands\cr
95 help {\it class}&One-line descriptions for commands in {\it class}\cr
96 help {\it command}&Describe {\it command}\cr
99 \sec Executing your Program;
100 run {\it arglist}&start your program with {\it arglist}\cr
101 run&start your program with current argument list\cr
102 run $\ldots$ <{\it inf} >{\it outf}&start program with input, output
105 kill&Kill running program\cr
107 tty {\it dev}&Use {\it dev} as default i/o for next {\tt run}\cr
108 set args {\it arglist}&specify {\it arglist} for next
110 set args&specify empty argument list\cr
111 show args&display argument list\cr
113 show environment&show all environment variables\cr
114 show env {\it var}&show value of environment variable {\it var}\cr
115 set env {\it var} {\it expr}&set environment variable {\it var}\cr
116 delete env {\it var}&Remove {\it var} from environment\cr
120 cd {\it dir}&Change working directory to {\it dir}\cr
121 pwd&Print working directory\cr
122 make $\ldots$&Call ``{\tt make}''\cr
123 shell {\it cmd}&Execute arbitrary shell command string\cr
127 \centerline{\smrm \copyright 1991 Free Software Foundation, Inc.\qquad Permissions on back}
129 \sec Breakpoints and Watchpoints;
130 break \opt{\it file\tt:}{\it line}&Set breakpoint at {\it line} number \opt{in \it file}\par
131 eg:\quad{\tt break main.c:37}\quad\cr
132 break \opt{\it file\tt:}{\it fun}&Set breakpoint at {\it
133 fun}() \opt{in \it file}\cr
134 break +{\it offset}\par
135 break -{\it offset}&Set break at offset from current stop\cr
136 break *{\it addr}&Set breakpoint at address {\it addr}\cr
137 break&Set breakpoint at next instruction\cr
138 break $\ldots$ if {\it expr}&Break conditionally on nonzero {\it expr}\cr
139 cond {\it bno} \opt{\it expr}&New conditional expression on breakpoint
140 number {\it bno}; make unconditional if no {\it expr}\cr
141 tbreak $\ldots$&Temporary break; disable when reached\cr
142 rbreak {\it regex}&Break on all functions matching {\it regex}\cr
143 watch {\it expr}&Set a watchpoint for expression {\it expr}\cr
144 catch {\it x}&Set breakpoint at C++ handler for exception {\it x}\cr
146 info break&Show defined breakpoints\cr
147 info watch&Show defined watchpoints\cr
149 clear&Delete breakpoints at next instruction\cr
150 clear \opt{\it file\tt:}{\it fun}&Delete breakpoints at entry to {\it fun}()\cr
151 clear \opt{\it file\tt:}{\it line}&Delete breakpoints on source line \cr
152 delete \opt{{\it bnos}}&Delete breakpoints numbered {\it bnos};
153 \opt{or all breakpoints}\cr
155 disable \opt{{\it bnos}}&Disable breakpoints {\it bnos} \opt{or all}\cr
156 enable {\it bnos}&Enable breakpoints {\it bnos} \opt{or all}\cr
157 enable once {\it bnos}&Enable breakpoints; disable again when
159 enable del {\it bnos}&Enable breakpoints; delete when reached\cr
161 ignore {\it bno} {\it count}&Ignore breakpoint number {\it bno}, {\it count}
164 commands {\it bno}\par
165 \qquad {\it command list}&Execute GDB {\it command list} every time breakpoint {\it bno} is reached\cr
166 end&(use only with {\tt commands}) End of {\it command list}\cr
170 handle {\it signal} {\it act}&Specify GDB actions when {\it signal} occurs:\cr
171 \quad print&Announce when signal occurs\cr
172 \quad noprint&Be silent when signal occurs\cr
173 \quad stop&Halt execution on signal\cr
174 \quad nostop&Do not halt execution\cr
175 \quad pass&Allow your program to handle signal\cr
176 \quad nopass&Do not allow your program to see signal\cr
177 info signal&Show table of signals and GDB action for each\cr
181 \sec Execution Control;
182 continue \opt{\it count}\par
183 c \opt{\it count}&Continue running; if {\it count} specified, ignore
184 this breakpoint next {\it count} times\cr
186 step \opt{\it count}\par
187 s \opt{\it count}&Execute until another line reached; repeat {\it count} times if
190 stepi \opt{\it count}\par
191 si \opt{\it count}&Step by machine instructions rather than source
194 next \opt{\it count}\par
195 n \opt{\it count}&Execute next line, including any function calls.\cr
197 nexti \opt{\it count}\par
198 ni \opt{\it count}&Next machine instruction rather than source
201 until \opt{\it location}&Run until next instruction (or {\it
202 location}) reached\cr
204 finish&Run until selected stack frame returns\cr
205 return \opt{\it expr}&Pop selected stack frame without executing,
206 optionally setting return value\cr
208 signal {\it num}&Resume execution with signal {\it num} (none if {\tt 0})\cr
210 jump *{\it address}&Resume execution at specified {\it line} number or
212 set var {\it expr}&Evaluate {\it expr} without displaying it; use for
213 altering program variables\cr
216 \sec Debugging Targets;
217 target {\it type} {\it param}&Connect to target machine, process, or file\cr
218 info targets&Display available targets\cr
219 attach {\it param}&Connect to another target of same type\cr
220 detach&Release target from GDB control\cr
224 {\it expr}&An expression in C or C++ (including function calls), or:\cr
225 {\it addr\/}@{\it len}&An array of {\it len} elements beginning at {\it
227 {\it file}::{\it nm}&A variable or function {\it nm} defined in {\it
229 $\tt\{${\it type}$\tt\}${\it addr}&Read memory at {\it addr} as specified
231 print \opt{\tt/{\it f}\/} {\it expr}\par
232 p \opt{\tt/{\it f}\/} {\it expr}&Display the value of an expression\par
233 in format {\it f}:\cr
234 \qquad x&hexadecimal\cr
235 \qquad d&signed decimal\cr
236 \qquad u&unsigned decimal\cr
238 \qquad a&address, absolute and relative\cr
239 \qquad c&character constant\cr
240 \qquad f&floating point\cr
241 call \opt{\tt /{\it f}\/} {\it expr}&Like {\tt print} but does not display
247 x \opt{\tt/{\it Nuf}\/} {\it expr}&Examine memory at address {\it expr};
248 optional format spec follows slash.\cr
249 \quad {\it N}&Count of how many units to display;\cr
250 \quad {\it u}&Unit size; one of\cr
251 &{\tt\qquad b}\ individual bytes\cr
252 &{\tt\qquad h}\ halfwords (two bytes)\cr
253 &{\tt\qquad w}\ words (four bytes)\cr
254 &{\tt\qquad g}\ giant words (eight bytes)\cr
255 \quad {\it f}&Printing format. Any {\tt print} format, or\cr
256 &{\tt\qquad s}\ Null-terminated string\cr
257 &{\tt\qquad i}\ Machine instructions\cr
258 disassem \opt{\it addr}&Display range of memory as machine
259 instructions; function surrounding {\it addr} or program counter, or range between two arguments\cr
262 \sec Automatic Display;
263 display \opt{\tt/\it f\/} {\it expr}&Show value of {\it expr} each time
264 program stops \opt{according to format {\it f}\/}\cr
265 display&Display all enabled expressions on list\cr
266 undisplay {\it dnos}&Remove number(s) {\it dnos} from list of
267 automatically displayed expressions\cr
268 disable dis {\it dnos}&Disable display for expression(s) number {\it
270 enable dis {\it dnos}&Enable display for expression(s) number {\it
272 info display&Show numbered list of expressions to display\cr
276 backtrace \opt{\it n}\par
277 bt \opt{\it n}&Print trace of all frames in stack; or of {\it n}
278 frames---innermost if {\it n}{\tt >0}, outermost if {\it n}{\tt <0}\cr
279 frame \opt{\it n}&Select frame number {\it n} or frame at address {\it
280 n}; if no {\it n}, display current frame\cr
281 up {\it n}&Select frame {\it n} frames up\cr
282 down {\it n}&Select frame {\it n} frames down\cr
283 info frame \opt{\it addr}&Description of selected frame, or frame at
285 info args&Arguments of selected frame\cr
286 info locals&Local variables of selected frame\cr
287 info catch&Exception handlers active in selected frame\cr
291 info address {\it s}&Show where symbol {\it s} is stored\cr
292 info func \opt{\it regex}&Show names, types of defined functions
293 (all, or matching {\it regex})\cr
294 info var \opt{\it regex}&Show names, types of global variables (all,
295 or matching {\it regex})\cr
296 info sources&Show all sources having debugging information\cr
297 whatis {\it expr}\par
298 ptype {\it expr}&Show data type of {\it expr} without evaluating; {\tt
299 ptype} gives more detail\cr
300 ptype {\it type}&Describe type, struct, union, or enum\cr
304 \sec Controlling GDB;
305 set {\it param} {\it expr}&Set one of GDB's internal parameters,
306 controlling its interaction with you\cr
307 show {\it param}&Display current setting of a GDB parameter\cr
308 \xtra{\rm Parameters understood by {\tt set} and {\tt show}:}
309 \quad addressp {\it on/off}&print memory addresses in stacks,
311 \quad array-max {\it limit}&Number of elements to display from an
313 \quad arraypr {\it off/on}&Compact or attractive format for
315 \quad caution {\it on/off}&Enable or disable cautionary queries\cr
316 \quad editing {\it on/off}&Control {\tt readline} command-line editing\cr
317 \quad history&({\tt h}) covers a number of options:\cr
318 \quad h exp {\it off/on}&Disable or enable {\tt readline} history expansion\cr
319 \quad h file {\it filename}&File for recording GDB command history\cr
320 \quad h size {\it size}&Number of commands kept in history list\cr
321 \quad h write {\it off/on}&Control use of external file for
324 \quad pretty {\it off/on}&Compact or indented format for struct
326 \quad prompt {\it str}&Use {\it str} as GDB prompt\cr
327 \quad radix {\it base}&Octal, decimal, or hex number representation\cr
328 \quad screen-h {\it lpp}&Number of lines before pause in
330 \quad screen-w {\it cpl}&Number of characters before line folded\cr
331 \quad unionpr {\it on/off}&Enable or disable display of unions in
333 \quad verbose {\it on/off}&Control messages when loading
335 \quad vtblpr {\it off/on}&Display of C++ virtual function tables\cr
336 info editing&Show last 10 commands\cr
337 info editing {\it n}&Show 10 commands around number {\it n}\cr
338 info editing +&Show next 10 commands\cr
342 file {\it name}&Use {\it file} for symbols and executable\cr
343 core {\it name}&Read {\it file} as coredump\cr
344 exec {\it name}&Use {\it file} as executable only\cr
345 symbol {\it name}&Use only symbol table from {\it file}\cr
346 load {\it file} {\it addr}&Read additional symbols from {\it file},
347 dynamically loaded at {\it addr}\cr
348 info files&Display working files and targets in use\cr
350 share \opt{\it regex}&Add symbol information for shared libraries
351 matching {\it regex}, or all shared libraries\cr
352 info share&List names of shared libraries currently loaded\cr
357 dir {\it name}&Add directory {\it name} to front of source path\cr
358 dir&Clear source path\cr
359 info dir&Show current source path\cr
361 list&Show next ten lines of source\cr
362 list -&Show previous ten lines\cr
363 list {\it lines}&Display source centered around {\it lines},
364 specified as one of:\cr
365 \quad{\opt{\it file\tt:}\it num}&Line number \opt{in named file}\cr
366 \quad{\opt{\it file\tt:}\it function}&Beginning of function \opt{in
368 \quad{\tt +\it off}&{\it off} lines after last printed\cr
369 \quad{\tt -\it off}&{\it off} lines previous to last printed\cr
370 \quad{\tt*\it address}&Line containing {\it address}\cr
371 list {\it f},{\it l}&from line {\it f} to line {\it l}\cr
372 info line {\it num}&Show starting, ending addresses of compiled code for
373 source line {\it num}\cr
374 forw {\it regex}&Search following source lines for {\it regex}\cr
375 rev {\it regex}&Search preceding source lines for {\it regex}\cr
378 \sec GDB under GNU Emacs;
379 M-x gdb&Run GDB under Emacs\cr
380 \ctl{h} m&Describe GDB mode\cr
381 M-s&Step one line ({\tt step})\cr
382 M-n&Next line ({\tt next})\cr
383 M-i&Step one instruction ({\tt stepi})\cr
384 \ctl{c} \ctl{f}&Finish current stack frame ({\tt finish})\cr
385 M-c&Continue ({\tt cont})\cr
386 M-u&Up {\it arg} frames ({\tt up})\cr
387 M-d&Down {\it arg} frames ({\tt down})\cr
388 \ctl{x} SPC&(in source file) set break at point\cr
394 \centerline{Copyright \copyright 1991 Free Software Foundation, Inc.}
397 This card may be freely distributed under the terms of the GNU
398 General Public License.
400 Please contribute to development of this card by annotating it.
402 No author assumes any responsibility for any errors on this card.}