* doc/gdb.texinfo: (1) Updated w/ref to RMS comments through
[deliverable/binutils-gdb.git] / gdb / doc / refcard.tex
CommitLineData
bca43169 1%This file is TeX source for a reference card describing GDB, the GNU debugger.
98088880 2%$Id$
bca43169
RP
3%Copyright (C) 1991 Free Software Foundation, Inc.
4%Permission is granted to make and distribute verbatim copies of
5%this reference provided the copyright notices and permission notices
6%are preserved on all copies.
7%
8%TeX markup is a programming language; accordingly this file is source
9%for a program to generate a reference.
10%
11%This program is free software; you can redistribute it and/or modify
12%it under the terms of the GNU General Public License as published by
13%the Free Software Foundation; either version 1, or (at your option)
14%any later version.
15%
16%This program is distributed in the hope that it will be useful, but
17%WITHOUT ANY WARRANTY; without even the implied warranty of
18%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19%General Public License for more details.
20%
21%You can find a copy of the GNU General Public License in the GDB
22%manual; or write to the Free Software Foundation, Inc.,
23%675 Mass Ave, Cambridge, MA 02139, USA.
24%
25%You can contact the author as: pesch@cygnus.com
26%
27% Roland Pesch
28% Cygnus Support
29% 814 University Ave.
30% Palo Alto, CA 94301 USA
31%
32% +1 415 322 3811
33%
34% Cygnus Support is an organization devoted to commercial
35% support of free software. For general information
36% contact ``info@cygnus.com''
37%
98088880
RP
38% NOTE ON INTENTIONAL OMISSIONS: This reference card includes most GDB
39% commands, but due to space constraints there are some things I chose
40% to omit. In general, not all synonyms for commands are covered.
41% The GDB-under-Emacs section omits gdb-mode functions without default
42% keybindings. GDB startup options are not described.
43%
bca43169
RP
44%
45\input threecol
46{%
47\def\$#1${{#1}}% Kluge: collect RCS revision info without $...$
48\xdef\manvers{\$Revision$}%
49}
50\vsize=8in
98088880 51\hyphenpenalty=5000\tolerance=2000\raggedright\raggedbottom
bca43169 52%
98088880
RP
53%The Times-Roman family is used below because it is both more
54%attractive and more compact than Computer Modern. On the other hand,
55%while common, it is not Free. The commented-out font definitions
56%will be close (but may cause some column overflows) if you must use
57%the CM fonts.
58%\font\bbf=cmbx10
59\font\bbf=Times-Bold at 10pt
60%\font\vbbf=cmbx12
61\font\vbbf=Times-Bold at 12pt
62%\font\smrm=cmr5
63\font\smrm=Times-Roman at 6pt
64%\font\brm=cmr10
65\font\brm=Times-Roman at 10pt
66%\font\rm=cmr7
67\font\rm=Times-Roman at 8pt
68%\font\it=cmti7
69\font\it=Times-Italic at 8pt
70% We *do* use CMtt rather than Courier because TeX and PS fonts have
71% different ideas about where ``funny'' chars go.
bca43169 72\font\tt=cmtt8
98088880
RP
73% Finally, the following common-but-not-free font (Symbol) is used
74% only for the copyright symbol. Comment out the whole definition of
75% \copyright if you insist on using only Free fonts, and you'll pick
76% up the kluge in plain.tex that defines \copyright by overstriking.
77\font\sym=Symbol at 7pt
78\def\copyright{{\sym\char'323}}
bca43169
RP
79\normalbaselineskip=9pt\baselineskip=9pt
80%
81\parindent=0pt
82\parskip=0pt
83\footline={\vbox to0pt{\hss}}
84%
85\def\ctl#1{{\tt C-#1}}
86\def\opt#1{{\brm[{\rm #1}]}}
87\def\xtra#1{\noalign{\smallskip{\tt#1}}}
88%
89\long\def\sec#1;#2\endsec{\vskip 1pc
90\halign{%
91%COL 1 (of halign):
92\vtop{\hsize=1in\tt
93##\par\vskip 2pt
94}\quad
95%COL 2 (of halign):
96&\vtop{\hsize=2.1in\hangafter=1\hangindent=0.5em
97\rm ##\par\vskip 2pt}\cr
98%Tail of \long\def fills in halign body with \sec args:
99\noalign{{\bbf #1}\vskip 2pt}
100#2
101}
102}
103
104{\vbbf GDB QUICK REFERENCE}
105\vskip 5pt
98088880
RP
106{\smrm GDB Version 4.0---Cygnus Support 1991}
107
108\sec Essential Commands;
109gdb {\it program} \opt{{\it core}}&debug {\it program} \opt{using
110coredump {\it core}}\cr
111bt& backtrace: display program stack\cr
112b \opt{\it file\tt:}{\it function}&set breakpoint at {\it function} \opt{in \it file}\cr
113run \opt{{\it arglist}}&start your program \opt{with {\it arglist}}\cr
114p {\it expr}&display the value of an expression\cr
115c &continue running your program\cr
116n &execute next line, including function calls\cr
117s &execute until another line is reached\cr
118\endsec
bca43169
RP
119
120\sec Starting GDB;
121gdb&starts GDB, with no debugging files\cr
122gdb {\it program}&begin debugging {\it program}\cr
123gdb {\it program core}&debug coredump {\it core} produced by {\it program}\cr
124\endsec
125
126\sec Stopping GDB;
98088880
RP
127quit&exit GDB; also {\tt q} or {\tt EOF} (eg \ctl{d})\cr
128INTERRUPT&(eg \ctl{c}) terminate current command, or send to running process\cr
bca43169
RP
129\endsec
130
131\sec Getting Help;
98088880
RP
132help&list classes of commands\cr
133help {\it class}&one-line descriptions for commands in {\it class}\cr
134help {\it command}&describe {\it command}\cr
bca43169
RP
135\endsec
136
137\sec Executing your Program;
138run {\it arglist}&start your program with {\it arglist}\cr
139run&start your program with current argument list\cr
140run $\ldots$ <{\it inf} >{\it outf}&start program with input, output
141redirected\cr
142\cr
98088880 143kill&kill running program\cr
bca43169 144\cr
98088880 145tty {\it dev}&use {\it dev} as stdin and stdout for next {\tt run}\cr
bca43169
RP
146set args {\it arglist}&specify {\it arglist} for next
147{\tt run}\cr
148set args&specify empty argument list\cr
149show args&display argument list\cr
150\cr
151show environment&show all environment variables\cr
152show env {\it var}&show value of environment variable {\it var}\cr
98088880
RP
153set env {\it var} {\it string}&set environment variable {\it var}\cr
154unset env {\it var}&remove {\it var} from environment\cr
bca43169
RP
155\endsec
156
157\sec Shell Commands;
98088880 158cd {\it dir}&change working directory to {\it dir}\cr
bca43169 159pwd&Print working directory\cr
98088880
RP
160make $\ldots$&call ``{\tt make}''\cr
161shell {\it cmd}&execute arbitrary shell command string\cr
bca43169
RP
162\endsec
163
164\vfill
165\centerline{\smrm \copyright 1991 Free Software Foundation, Inc.\qquad Permissions on back}
166\eject
167\sec Breakpoints and Watchpoints;
98088880
RP
168break \opt{\it file\tt:}{\it line}\par
169b \opt{\it file\tt:}{\it line}&set breakpoint at {\it line} number \opt{in \it file}\par
bca43169 170eg:\quad{\tt break main.c:37}\quad\cr
98088880
RP
171break \opt{\it file\tt:}{\it function}&set breakpoint at {\it
172function} \opt{in \it file}\cr
bca43169 173break +{\it offset}\par
98088880
RP
174break -{\it offset}&set break at {\it offset} lines from current stop\cr
175break *{\it addr}&set breakpoint at address {\it addr}\cr
176break&set breakpoint at next instruction\cr
177break $\ldots$ if {\it expr}&break conditionally on nonzero {\it expr}\cr
178cond {\it n} \opt{\it expr}&new conditional expression on breakpoint
179{\it n}; make unconditional if no {\it expr}\cr
180tbreak $\ldots$&temporary break; disable when reached\cr
181rbreak {\it regex}&break on all functions matching {\it regex}\cr
182watch {\it expr}&set a watchpoint for expression {\it expr}\cr
183catch {\it x}&break at C++ handler for exception {\it x}\cr
bca43169 184\cr
98088880
RP
185info break&show defined breakpoints\cr
186info watch&show defined watchpoints\cr
bca43169 187\cr
98088880
RP
188clear&delete breakpoints at next instruction\cr
189clear \opt{\it file\tt:}{\it fun}&delete breakpoints at entry to {\it fun}()\cr
190clear \opt{\it file\tt:}{\it line}&delete breakpoints on source line \cr
191delete \opt{{\it n}}&delete breakpoints {\it n};
bca43169
RP
192\opt{or all breakpoints}\cr
193\cr
98088880
RP
194disable \opt{{\it n}}&disable breakpoints {\it n} \opt{or all}\cr
195enable \opt{{\it n}}&enable breakpoints {\it n} \opt{or all}\cr
196enable once \opt{{\it n}}&enable breakpoints; disable again when
bca43169 197reached\cr
98088880 198enable del \opt{{\it n}}&enable breakpoints; delete when reached\cr
bca43169 199\cr
98088880 200ignore {\it n} {\it count}&ignore breakpoint {\it n}, {\it count}
bca43169
RP
201times\cr
202\cr
98088880
RP
203commands {\it n}\par
204\qquad {\it command list}&execute GDB {\it command list} every time breakpoint {\it n} is reached\cr
205end&end of {\it command list}\cr
bca43169
RP
206\endsec
207
98088880
RP
208\sec Program Stack;
209backtrace \opt{\it n}\par
210bt \opt{\it n}&print trace of all frames in stack; or of {\it n}
211frames---innermost if {\it n}{\tt >0}, outermost if {\it n}{\tt <0}\cr
212frame \opt{\it n}&select frame number {\it n} or frame at address {\it
213n}; if no {\it n}, display current frame\cr
214up {\it n}&select frame {\it n} frames up\cr
215down {\it n}&select frame {\it n} frames down\cr
216info frame \opt{\it addr}&describe selected frame, or frame at
217{\it addr}\cr
218info args&arguments of selected frame\cr
219info locals&local variables of selected frame\cr
220info reg \opt{\it{rn}}&register values \opt{for reg {\it rn\/}} in selected frame\cr
221info catch&exception handlers active in selected frame\cr
bca43169
RP
222\endsec
223
224\vfill\eject
225\sec Execution Control;
226continue \opt{\it count}\par
98088880 227c \opt{\it count}&continue running; if {\it count} specified, ignore
bca43169
RP
228this breakpoint next {\it count} times\cr
229\cr
230step \opt{\it count}\par
98088880 231s \opt{\it count}&execute until another line reached; repeat {\it count} times if
bca43169
RP
232specified\cr
233\cr
234stepi \opt{\it count}\par
98088880 235si \opt{\it count}&step by machine instructions rather than source
bca43169
RP
236lines\cr
237\cr
238next \opt{\it count}\par
98088880 239n \opt{\it count}&execute next line, including any function calls\cr
bca43169
RP
240\cr
241nexti \opt{\it count}\par
98088880 242ni \opt{\it count}&next machine instruction rather than source
bca43169
RP
243line\cr
244\cr
98088880
RP
245until \opt{\it location}&run until next instruction (or {\it
246location})\cr
247finish&run until selected stack frame returns\cr
248return \opt{\it expr}&pop selected stack frame without executing
249\opt{setting return value}\cr
250signal {\it num}&resume execution with signal {\it s} (none if {\tt 0})\cr
bca43169 251jump {\it line}\par
98088880 252jump *{\it address}&resume execution at specified {\it line} number or
bca43169 253{\it address}\cr
98088880 254set var={\it expr}&evaluate {\it expr} without displaying it; use for
bca43169
RP
255altering program variables\cr
256\endsec
257
98088880 258\sec Display;
bca43169 259print \opt{\tt/{\it f}\/} {\it expr}\par
98088880 260p \opt{\tt/{\it f}\/} {\it expr}&show value of {\it expr} according to format {\it f}:\cr
bca43169
RP
261\qquad x&hexadecimal\cr
262\qquad d&signed decimal\cr
263\qquad u&unsigned decimal\cr
264\qquad o&octal\cr
265\qquad a&address, absolute and relative\cr
98088880 266\qquad c&character\cr
bca43169 267\qquad f&floating point\cr
98088880 268call \opt{\tt /{\it f}\/} {\it expr}&like {\tt print} but does not display
bca43169 269{\tt void}\cr
98088880
RP
270x \opt{\tt/{\it Nuf}\/} {\it expr}&examine memory at address {\it expr};
271optional format spec follows slash\cr
272\quad {\it N}&count of how many units to display\cr
273\quad {\it u}&unit size; one of\cr
bca43169
RP
274&{\tt\qquad b}\ individual bytes\cr
275&{\tt\qquad h}\ halfwords (two bytes)\cr
276&{\tt\qquad w}\ words (four bytes)\cr
277&{\tt\qquad g}\ giant words (eight bytes)\cr
98088880
RP
278\quad {\it f}&printing format. Any {\tt print} format, or\cr
279&{\tt\qquad s}\ null-terminated string\cr
280&{\tt\qquad i}\ machine instructions\cr
281disassemble \opt{\it addr}&display memory as machine instructions\cr
bca43169
RP
282\endsec
283
284\sec Automatic Display;
98088880 285display \opt{\tt/\it f\/} {\it expr}&show value of {\it expr} each time
bca43169 286program stops \opt{according to format {\it f}\/}\cr
98088880
RP
287display&display all enabled expressions on list\cr
288undisplay {\it n}&remove number(s) {\it n} from list of
bca43169 289automatically displayed expressions\cr
98088880
RP
290disable display {\it n}&disable display for expression(s) number {\it
291n}\cr
292enable display {\it n}&enable display for expression(s) number {\it
293n}\cr
294info display&numbered list of display expressions\cr
bca43169
RP
295\endsec
296
98088880
RP
297\vfill\eject
298
299\sec Expressions;
300{\it expr}&an expression in C or C++ (including function calls), or:\cr
301{\it addr\/}@{\it len}&an array of {\it len} elements beginning at {\it
302addr}\cr
303{\it file}::{\it nm}&a variable or function {\it nm} defined in {\it
304file}\cr
305$\tt\{${\it type}$\tt\}${\it addr}&read memory at {\it addr} as specified
306{\it type}\cr
307\$&most recent displayed value\cr
308\${\it n}&{\it n}th displayed value\cr
309\$\$&displayed value previous to \$\cr
310\$\${\it n}&{\it n}th displayed value back from \$\cr
311\$\_&last address examined with {\tt x}\cr
312\$\_\_&value at address \$\_\cr
313\${\it var}&convenience variable; assign any value\cr
314\cr
315show values \opt{{\it n}}&show last 10 values \opt{or surrounding
316\${\it n}}\cr
317show convenience&display all convenience variables\cr
bca43169
RP
318\endsec
319
320\sec Symbol Table;
98088880
RP
321info address {\it s}&show where symbol {\it s} is stored\cr
322info func \opt{\it regex}&show names, types of defined functions
bca43169 323(all, or matching {\it regex})\cr
98088880 324info var \opt{\it regex}&show names, types of global variables (all,
bca43169 325or matching {\it regex})\cr
bca43169 326whatis {\it expr}\par
98088880 327ptype {\it expr}&show data type of {\it expr} without evaluating; {\tt
bca43169 328ptype} gives more detail\cr
98088880
RP
329ptype {\it type}&describe type, struct, union, or enum\cr
330\endsec
331
332\sec GDB Scripts;
333source {\it script}&read, execute GDB commands from file {\it
334script}\cr
335\cr
336define {\it cmd}\par
337\qquad {\it command list}&new GDB command {\it cmd}, executes script
338defined by {\it command list} \cr
339end&end of {\it command list}\cr
340document {\it cmd}\par
341\qquad {\it help text}&new online documentation for GDB command {\it
342cmd}\cr
343end&end of {\it help text}\cr
344\endsec
345
346\sec Signals;
347handle {\it signal} {\it act}&specify GDB actions when {\it signal} occurs:\cr
348\quad print&announce when signal occurs\cr
349\quad noprint&be silent when signal occurs\cr
350\quad stop&halt execution on signal\cr
351\quad nostop&do not halt execution\cr
352\quad pass&allow your program to handle signal\cr
353\quad nopass&do not allow your program to see signal\cr
354info signals&show table of signals, GDB action for each\cr
355\endsec
356
357\sec Debugging Targets;
358target {\it type} {\it param}&connect to target machine, process, or file\cr
359help target&display available targets\cr
360attach {\it param}&connect to another process\cr
361detach&release target from GDB control\cr
bca43169
RP
362\endsec
363
364\vfill\eject
365\sec Controlling GDB;
98088880
RP
366set {\it param} {\it expr}&set one of GDB's internal parameters\cr
367show {\it param}&display current setting of a GDB parameter\cr
bca43169 368\xtra{\rm Parameters understood by {\tt set} and {\tt show}:}
98088880
RP
369\quad complaints {\it limit}&number of messages on unusual symbols\cr
370\quad confirm {\it on/off}&enable or disable cautionary queries\cr
371\quad editing {\it on/off}&control {\tt readline} command-line editing\cr
372\quad height {\it lpp}&number of lines before pause in
bca43169 373display\cr
98088880
RP
374\quad prompt {\it str}&use {\it str} as GDB prompt\cr
375\quad radix {\it base}&octal, decimal, or hex number representation\cr
376\quad verbose {\it on/off}&control messages when loading
bca43169 377symbol table\cr
98088880
RP
378\quad width {\it cpl}&number of characters before line folded\cr
379\cr
380\quad history $\ldots$&({\tt h}) groups the following options:\cr
381\quad h exp {\it off/on}&disable or enable {\tt readline} history expansion\cr
382\quad h file {\it filename}&file for recording GDB command history\cr
383\quad h size {\it size}&number of commands kept in history list\cr
384\quad h save {\it off/on}&control use of external file for
385command history\cr
386\cr
387\quad print $\ldots$&({\tt p}) groups the following options:\cr
388\quad p address {\it on/off}&print memory addresses in stacks,
389values\cr
390\quad p array {\it off/on}&compact or attractive format for
391arrays\cr
392\quad p demangle {\it on/off}&source or internal form for C++
393symbols\cr
394\quad p asm-dem {\it on/off}&demangle C++ symbols in
395machine-instruction output\cr
396\quad p elements {\it limit}&number of elements to display from an
397array\cr
398\quad p object {\it on/off}&print C++ derived types for objects\cr
399\quad p pretty {\it off/on}&struct display: compact or indented\cr
400\quad p union {\it on/off}&enable or disable display of union members\cr
401\quad p vtbl {\it off/on}&display of C++ virtual function
402tables\cr
403\cr
404show commands&show last 10 commands\cr
405show commands {\it n}&show 10 commands around number {\it n}\cr
406show commands +&show next 10 commands\cr
bca43169
RP
407\endsec
408
409\sec Working Files;
98088880
RP
410file {\it name}&use {\it file} for symbols and executable\cr
411core {\it name}&read {\it file} as coredump\cr
412exec {\it name}&use {\it file} as executable only\cr
413symbol {\it name}&use only symbol table from {\it file}\cr
414load {\it file}&dynamically link {\it file\/} and add its symbols\cr
415add-sym {\it file} {\it addr}&read additional symbols from {\it file},
bca43169 416dynamically loaded at {\it addr}\cr
98088880
RP
417info files&display working files and targets in use\cr
418path {\it dirs}&add {\it dirs} to front of path searched for
419executable and symbol files\cr
420info path&display executable and symbol file path\cr
421share \opt{\it regex}&add symbol information for shared libraries
bca43169 422matching {\it regex}, or all shared libraries\cr
98088880 423info share&list names of shared libraries currently loaded\cr
bca43169
RP
424\endsec
425
426\vfill\eject
427\sec Source Files;
98088880
RP
428dir {\it names}&add directory {\it names} to front of source path\cr
429dir&clear source path\cr
430show dir&show current source path\cr
bca43169 431\cr
98088880
RP
432list&show next ten lines of source\cr
433list -&show previous ten lines\cr
434list {\it lines}&display source centered around {\it lines},
bca43169 435specified as one of:\cr
98088880
RP
436\quad{\opt{\it file\tt:}\it num}&line number \opt{in named file}\cr
437\quad{\opt{\it file\tt:}\it function}&beginning of function \opt{in
bca43169
RP
438named file}\cr
439\quad{\tt +\it off}&{\it off} lines after last printed\cr
440\quad{\tt -\it off}&{\it off} lines previous to last printed\cr
98088880 441\quad{\tt*\it address}&line containing {\it address}\cr
bca43169 442list {\it f},{\it l}&from line {\it f} to line {\it l}\cr
98088880 443info line {\it num}&show starting, ending addresses of compiled code for
bca43169 444source line {\it num}\cr
98088880
RP
445info source&show name of current source file\cr
446info sources&list all source files in use\cr
447forw {\it regex}&search following source lines for {\it regex}\cr
448rev {\it regex}&search preceding source lines for {\it regex}\cr
bca43169
RP
449\endsec
450
451\sec GDB under GNU Emacs;
98088880
RP
452M-x gdb&run GDB under Emacs\cr
453\ctl{h} m&describe GDB mode\cr
454M-s&step one line ({\tt step})\cr
455M-n&next line ({\tt next})\cr
456M-i&step one instruction ({\tt stepi})\cr
457\ctl{c} \ctl{f}&finish current stack frame ({\tt finish})\cr
458M-c&continue ({\tt cont})\cr
459M-u&up {\it arg} frames ({\tt up})\cr
460M-d&down {\it arg} frames ({\tt down})\cr
461\ctl{x} \&&copy number from point, insert at end\cr
bca43169
RP
462\ctl{x} SPC&(in source file) set break at point\cr
463\endsec
464
465
466\vfill
467{\smrm\parskip=6pt
468\centerline{Copyright \copyright 1991 Free Software Foundation, Inc.}
98088880
RP
469\centerline{Roland Pesch (pesch@cygnus.com), May 1991---\manvers}
470\centerline{The author assumes no responsibility for any errors on this card.}
bca43169
RP
471
472This card may be freely distributed under the terms of the GNU
473General Public License.
474
98088880
RP
475\centerline{Please contribute to development of this card by annotating it.}
476}
bca43169 477\end
This page took 0.046864 seconds and 4 git commands to generate.