]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/doc/refcard.tex
This commit was generated by cvs2svn to track changes on a CVS vendor
[thirdparty/binutils-gdb.git] / gdb / doc / refcard.tex
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.
6 %
7 %TeX markup is a programming language; accordingly this file is source
8 %for a program to generate a reference.
9 %
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)
13 %any later version.
14 %
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.
19 %
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.
23 %
24 %You can contact the author as: pesch@cygnus.com
25 %
26 % Roland Pesch
27 % Cygnus Support
28 % 814 University Ave.
29 % Palo Alto, CA 94301 USA
30 %
31 % +1 415 322 3811
32 %
33 % Cygnus Support is an organization devoted to commercial
34 % support of free software. For general information
35 % contact ``info@cygnus.com''
36 %
37 %
38 \input threecol
39 {%
40 \def\$#1${{#1}}% Kluge: collect RCS revision info without $...$
41 \xdef\manvers{\$Revision$}%
42 }
43 \vsize=8in
44 \hyphenpenalty=5000\tolerance=2000\raggedright
45 %
46 \font\bbf=cmbx10
47 \font\vbbf=cmbx12
48 \font\smrm=cmr6
49 \font\brm=cmr10
50 \font\rm=cmr8
51 \font\it=cmti8
52 \font\tt=cmtt8
53 \normalbaselineskip=9pt\baselineskip=9pt
54 %
55 \parindent=0pt
56 \parskip=0pt
57 \footline={\vbox to0pt{\hss}}
58 %
59 \def\ctl#1{{\tt C-#1}}
60 \def\opt#1{{\brm[{\rm #1}]}}
61 \def\xtra#1{\noalign{\smallskip{\tt#1}}}
62 %
63 \long\def\sec#1;#2\endsec{\vskip 1pc
64 \halign{%
65 %COL 1 (of halign):
66 \vtop{\hsize=1in\tt
67 ##\par\vskip 2pt
68 }\quad
69 %COL 2 (of halign):
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}
74 #2
75 }
76 }
77
78 {\vbbf GDB QUICK REFERENCE}
79 \vskip 5pt
80 {\smrm GDB Version 4.00---Cygnus Support 1991}
81
82 \sec Starting GDB;
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
86 \endsec
87
88 \sec Stopping GDB;
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
91 \endsec
92
93 \sec Getting Help;
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
97 \endsec
98
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
103 redirected\cr
104 \cr
105 kill&Kill running program\cr
106 \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
109 {\tt run}\cr
110 set args&specify empty argument list\cr
111 show args&display argument list\cr
112 \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
117 \endsec
118
119 \sec Shell Commands;
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
124 \endsec
125
126 \vfill
127 \centerline{\smrm \copyright 1991 Free Software Foundation, Inc.\qquad Permissions on back}
128 \eject
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
145 \cr
146 info break&Show defined breakpoints\cr
147 info watch&Show defined watchpoints\cr
148 \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
154 \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
158 reached\cr
159 enable del {\it bnos}&Enable breakpoints; delete when reached\cr
160 \cr
161 ignore {\it bno} {\it count}&Ignore breakpoint number {\it bno}, {\it count}
162 times\cr
163 \cr
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
167 \endsec
168
169 \sec Signals;
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
178 \endsec
179
180 \vfill\eject
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
185 \cr
186 step \opt{\it count}\par
187 s \opt{\it count}&Execute until another line reached; repeat {\it count} times if
188 specified\cr
189 \cr
190 stepi \opt{\it count}\par
191 si \opt{\it count}&Step by machine instructions rather than source
192 lines\cr
193 \cr
194 next \opt{\it count}\par
195 n \opt{\it count}&Execute next line, including any function calls.\cr
196 \cr
197 nexti \opt{\it count}\par
198 ni \opt{\it count}&Next machine instruction rather than source
199 line\cr
200 \cr
201 until \opt{\it location}&Run until next instruction (or {\it
202 location}) reached\cr
203 \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
207 \cr
208 signal {\it num}&Resume execution with signal {\it num} (none if {\tt 0})\cr
209 jump {\it line}\par
210 jump *{\it address}&Resume execution at specified {\it line} number or
211 {\it address}\cr
212 set var {\it expr}&Evaluate {\it expr} without displaying it; use for
213 altering program variables\cr
214 \endsec
215
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
221 \endsec
222
223 \sec Expressions;
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
226 addr}\cr
227 {\it file}::{\it nm}&A variable or function {\it nm} defined in {\it
228 file}\cr
229 $\tt\{${\it type}$\tt\}${\it addr}&Read memory at {\it addr} as specified
230 {\it type}\cr
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
237 \qquad o&octal\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
242 {\tt void}\cr
243 \endsec
244
245 \vfill\eject
246 \sec Memory;
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
260 \endsec
261
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
269 dnos}\cr
270 enable dis {\it dnos}&Enable display for expression(s) number {\it
271 dnos}\cr
272 info display&Show numbered list of expressions to display\cr
273 \endsec
274
275 \sec Program Stack;
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
284 {\it addr}\cr
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
288 \endsec
289
290 \sec Symbol Table;
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
301 \endsec
302
303 \vfill\eject
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,
310 structs\cr
311 \quad array-max {\it limit}&Number of elements to display from an
312 array\cr
313 \quad arraypr {\it off/on}&Compact or attractive format for
314 arrays\cr
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
322 command history\cr
323 \cr
324 \quad pretty {\it off/on}&Compact or indented format for struct
325 display\cr
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
329 display\cr
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
332 structs\cr
333 \quad verbose {\it on/off}&Control messages when loading
334 symbol table\cr
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
339 \endsec
340
341 \sec Working Files;
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
349 \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
353 \endsec
354
355 \vfill\eject
356 \sec Source Files;
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
360 \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
367 named file}\cr
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
376 \endsec
377
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
389 \endsec
390
391
392 \vfill
393 {\smrm\parskip=6pt
394 \centerline{Copyright \copyright 1991 Free Software Foundation, Inc.}
395 \centerline{Roland Pesch (pesch@cygnus.com), January 1991---\manvers}
396
397 This card may be freely distributed under the terms of the GNU
398 General Public License.
399
400 Please contribute to development of this card by annotating it.
401
402 No author assumes any responsibility for any errors on this card.}
403 \end