Fri Sep 4 18:53:57 1992 Roland H. Pesch (pesch@fowanton.cygnus.com)
[deliverable/binutils-gdb.git] / gdb / doc / cygref.tex
CommitLineData
5ac0315a
RP
1%This file is TeX source for a reference card describing GDB, the GNU debugger.
2%$Id$
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%
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, nor
41% all variations of a command.
42% The GDB-under-Emacs section omits gdb-mode functions without default
43% keybindings. GDB startup options are not described.
44% set print sevenbit-strings, set symbol-reloading omitted.
45% printsyms, printpsyms, omitted since they're for GDB maintenance primarily
46% share omitted due to obsolescence
47% set check range/type omitted at least til code is in GDB.
48%
49\input epsf
50\epsfxsize=1.75in
51{%
52\def\$#1${{#1}}% Kluge: collect RCS revision info without $...$
53\xdef\manvers{\$Revision$}%
54}%
d98a0a44
RP
55%-------------------- Three column format -----------------------
56
57%%%% --- To disable three column format, comment out this entire section
58
59% Three-column format for landscape printing on 8.5x11 paper
60
61% We want output .25 inch *from paper edge*; i.e. -.75in from TeX default
62\hoffset=-0.8in \voffset=-0.75in
63\newdimen\fullhsize
64\fullhsize=10.5in \hsize=3.3in
65\def\fulline{\hbox to \fullhsize}
66\let\lcr=L \newbox\leftcolumn\newbox\centercolumn
67\output={\if L\lcr
68 \global\setbox\leftcolumn=\columnbox \global\let\lcr=C
69 \else
70 \if C\lcr
71 \global\setbox\centercolumn=\columnbox \global\let\lcr=R
72 \else \tripleformat \global\let\lcr=L
73 \fi
74 \fi
75% \ifnum\outputpenalty>-20000 \else\dosupereject\fi
76 }
77%
78%ALTERNATIVE FOLDING GUIDES:
79%
80%For NO printed folding guide, comment out other \def\vdecor's and uncomment:
81%\def\vdecor{\hskip .2in plus1fil}
82%
83%For SOLID LINE folding guide, comment out other \def\vdecor's and uncomment:
84%\def\vdecor{\hskip .1in plus1fil \vrule width .1pt \hskip .1in plus1fil}
85%
86%For SMALL MARKS NEAR TOP AND BOTTOM as folding guide,
87%comment out other \def\vdecor's and uncomment:
88\def\vdecor{\hskip .1in plus1fil
89\vbox to \vsize{\hbox to .1pt{\vrule height 2pt width .1pt}\vfill
90\hbox to .1pt{\vrule height 2pt width .1pt}}
91\hskip .1in plus1fil}
92%
93%END OF ALTERNATIVES FOR FOLDING GUIDES
94%
95\def\tripleformat{\shipout\vbox{\fulline{\box\leftcolumn\vdecor
96 \box\centercolumn\vdecor
97 \columnbox}
98 }
99 \advancepageno}
100\def\columnbox{\leftline{\pagebody}}
101\def\bye{\par\vfill
102 \supereject
103 \if R\lcr \null\vfill\eject\fi
104 \end}
105
106%-------------------- end three column format -----------------------
107
108%-------------------- PostScript (K Berry names) font defs: --------------
109\font\bbf=ptmb at 10pt
110\font\vbbf=ptmb at 12pt
111\font\smrm=ptmr at 6pt
112\font\brm=ptmr at 10pt
113\font\rm=ptmr at 8pt
114\font\it=ptmri at 8pt
115\font\tt=pcrr at 8pt
116% Used only for copyright, replacing plain TeX macro.
117\font\sym=psyr at 7pt
118\def\copyright{{\sym\char'323}}
119%-------------------- end font defs ---------------------------------
120
5ac0315a
RP
121%
122\vsize=8in
123\hyphenpenalty=5000\tolerance=2000\raggedright\raggedbottom
124\normalbaselineskip=9pt\baselineskip=9pt
125%
126\parindent=0pt
127\parskip=0pt
128\footline={\vbox to0pt{\hss}}
129%
130\def\ctl#1{{\tt C-#1}}
131\def\opt#1{{\brm[{\rm #1}]}}
132\def\xtra#1{\noalign{\smallskip{\tt#1}}}
133%
134\long\def\sec#1;#2\endsec{\vskip 1pc
135\halign{%
136%COL 1 (of halign):
137\vtop{\hsize=1.1in\tt
138##\par\vskip 2pt }\hfil
139%COL 2 (of halign):
140&\vtop{\hsize=2.1in\hangafter=1\hangindent=0.5em
141\rm ##\par\vskip 2pt}\cr
142%Tail of \long\def fills in halign body with \sec args:
143\noalign{{\bbf #1}\vskip 2pt}
144#2
145}
146}
147{\vbbf GDB QUICK REFERENCE}\hfil{\smrm GDB Version 4}
148{\baselineskip=0pt
149\vskip 7.15 in
150\hskip .33in\epsfbox{cyglogo.eps}
151\vskip -7.82 in}
152\vskip 3pt
153
154\sec Essential Commands;
155gdb {\it program} \opt{{\it core}}&debug {\it program} \opt{using
156coredump {\it core}}\cr
157b \opt{\it file\tt:}{\it function}&set breakpoint at {\it function} \opt{in \it file}\cr
158run \opt{{\it arglist}}&start your program \opt{with {\it arglist}}\cr
159bt& backtrace: display program stack\cr
160p {\it expr}&display the value of an expression\cr
161c &continue running your program\cr
162n &next line, stepping over function calls\cr
163s &next line, stepping into function calls\cr
164\endsec
165
166\sec Starting GDB;
167gdb&start GDB, with no debugging files\cr
168gdb {\it program}&begin debugging {\it program}\cr
169gdb {\it program core}&debug coredump {\it core} produced by {\it
170program}\cr
d98a0a44 171gdb --help&describe command line options\cr
5ac0315a
RP
172\endsec
173
174\sec Stopping GDB;
175quit&exit GDB; also {\tt q} or {\tt EOF} (eg \ctl{d})\cr
176INTERRUPT&(eg \ctl{c}) terminate current command, or send to running process\cr
177\endsec
178
179\sec Getting Help;
180help&list classes of commands\cr
181help {\it class}&one-line descriptions for commands in {\it class}\cr
182help {\it command}&describe {\it command}\cr
183\endsec
184
185\sec Executing your Program;
186run {\it arglist}&start your program with {\it arglist}\cr
187run&start your program with current argument list\cr
188run $\ldots$ <{\it inf} >{\it outf}&start your program with input, output
189redirected\cr
190\cr
191kill&kill running program\cr
192\cr
193tty {\it dev}&use {\it dev} as stdin and stdout for next {\tt run}\cr
194set args {\it arglist}&specify {\it arglist} for next
195{\tt run}\cr
196set args&specify empty argument list\cr
197show args&display argument list\cr
198\cr
199show environment&show all environment variables\cr
200show env {\it var}&show value of environment variable {\it var}\cr
201set env {\it var} {\it string}&set environment variable {\it var}\cr
202unset env {\it var}&remove {\it var} from environment\cr
203\endsec
204
205\sec Shell Commands;
206cd {\it dir}&change working directory to {\it dir}\cr
207pwd&Print working directory\cr
208make $\ldots$&call ``{\tt make}''\cr
209shell {\it cmd}&execute arbitrary shell command string\cr
210\endsec
211
212\vfill
213\eject
214\sec Breakpoints and Watchpoints;
215break \opt{\it file\tt:}{\it line}\par
216b \opt{\it file\tt:}{\it line}&set breakpoint at {\it line} number \opt{in \it file}\par
217eg:\quad{\tt break main.c:37}\quad\cr
218break \opt{\it file\tt:}{\it function}&set breakpoint at {\it
219function} \opt{in \it file}\cr
220break +{\it offset}\par
221break -{\it offset}&set break at {\it offset} lines from current stop\cr
222break *{\it addr}&set breakpoint at address {\it addr}\cr
223break&set breakpoint at next instruction\cr
224break $\ldots$ if {\it expr}&break conditionally on nonzero {\it expr}\cr
225cond {\it n} \opt{\it expr}&new conditional expression on breakpoint
226{\it n}; make unconditional if no {\it expr}\cr
227tbreak $\ldots$&temporary break; disable when reached\cr
228rbreak {\it regex}&break on all functions matching {\it regex}\cr
229watch {\it expr}&set a watchpoint for expression {\it expr}\cr
230catch {\it x}&break at C++ handler for exception {\it x}\cr
231\cr
232info break&show defined breakpoints\cr
233info watch&show defined watchpoints\cr
234\cr
235clear&delete breakpoints at next instruction\cr
236clear \opt{\it file\tt:}{\it fun}&delete breakpoints at entry to {\it fun}()\cr
237clear \opt{\it file\tt:}{\it line}&delete breakpoints on source line \cr
238delete \opt{{\it n}}&delete breakpoints
239\opt{or breakpoint {\it n}}\cr
240\cr
241disable \opt{{\it n}}&disable breakpoints
242\opt{or breakpoint {\it n}}
243\cr
244enable \opt{{\it n}}&enable breakpoints
245\opt{or breakpoint {\it n}}
246\cr
247enable once \opt{{\it n}}&enable breakpoints \opt{or breakpoint {\it n}};
248disable again when reached
249\cr
250enable del \opt{{\it n}}&enable breakpoints \opt{or breakpoint {\it n}};
251delete when reached
252\cr
253\cr
254ignore {\it n} {\it count}&ignore breakpoint {\it n}, {\it count}
255times\cr
256\cr
257commands {\it n}\par
258\qquad \opt{\tt silent}\par
259\qquad {\it command-list}&execute GDB {\it command-list} every time breakpoint {\it n} is reached. \opt{{\tt silent} suppresses default
260display}\cr
261end&end of {\it command-list}\cr
262\endsec
263
264\sec Program Stack;
265backtrace \opt{\it n}\par
266bt \opt{\it n}&print trace of all frames in stack; or of {\it n}
267frames---innermost if {\it n}{\tt >0}, outermost if {\it n}{\tt <0}\cr
268frame \opt{\it n}&select frame number {\it n} or frame at address {\it
269n}; if no {\it n}, display current frame\cr
270up {\it n}&select frame {\it n} frames up\cr
271down {\it n}&select frame {\it n} frames down\cr
272info frame \opt{\it addr}&describe selected frame, or frame at
273{\it addr}\cr
274info args&arguments of selected frame\cr
275info locals&local variables of selected frame\cr
276info reg \opt{\it rn}\par
277info all-reg \opt{\it rn}&register values \opt{for reg {\it rn\/}} in
278selected frame; {\tt all-reg} includes floating point\cr
279info catch&exception handlers active in selected frame\cr
280\endsec
281
282\vfill
283\line{\smrm \opt{ } surround optional arguments.\hfil $\ldots$ show
284one or more arguments}
285\vskip\baselineskip
286\centerline{\smrm \copyright 1991, 1992 Free Software Foundation, Inc.\qquad Permissions on back}
287\eject
288\sec Execution Control;
289continue \opt{\it count}\par
290c \opt{\it count}&continue running; if {\it count} specified, ignore
291this breakpoint next {\it count} times\cr
292\cr
293step \opt{\it count}\par
294s \opt{\it count}&execute until another line reached; repeat {\it count} times if
295specified\cr
296stepi \opt{\it count}\par
297si \opt{\it count}&step by machine instructions rather than source
298lines\cr
299\cr
300next \opt{\it count}\par
301n \opt{\it count}&execute next line, including any function calls\cr
302nexti \opt{\it count}\par
303ni \opt{\it count}&next machine instruction rather than source
304line\cr
305\cr
306until \opt{\it location}&run until next instruction (or {\it
307location})\cr
308finish&run until selected stack frame returns\cr
309return \opt{\it expr}&pop selected stack frame without executing
310\opt{setting return value}\cr
311signal {\it num}&resume execution with signal {\it s} (none if {\tt 0})\cr
312jump {\it line}\par
313jump *{\it address}&resume execution at specified {\it line} number or
314{\it address}\cr
315set var={\it expr}&evaluate {\it expr} without displaying it; use for
316altering program variables\cr
317\endsec
318
319\sec Display;
320print \opt{\tt/{\it f}\/} \opt{\it expr}\par
321p \opt{\tt/{\it f}\/} \opt{\it expr}&show value of {\it expr} \opt{or
322last value \tt \$} according to format {\it f}:\cr
323\qquad x&hexadecimal\cr
324\qquad d&signed decimal\cr
325\qquad u&unsigned decimal\cr
326\qquad o&octal\cr
327\qquad t&binary\cr
328\qquad a&address, absolute and relative\cr
329\qquad c&character\cr
330\qquad f&floating point\cr
331call \opt{\tt /{\it f}\/} {\it expr}&like {\tt print} but does not display
332{\tt void}\cr
333x \opt{\tt/{\it Nuf}\/} {\it expr}&examine memory at address {\it expr};
334optional format spec follows slash\cr
335\quad {\it N}&count of how many units to display\cr
336\quad {\it u}&unit size; one of\cr
337&{\tt\qquad b}\ individual bytes\cr
338&{\tt\qquad h}\ halfwords (two bytes)\cr
339&{\tt\qquad w}\ words (four bytes)\cr
340&{\tt\qquad g}\ giant words (eight bytes)\cr
341\quad {\it f}&printing format. Any {\tt print} format, or\cr
342&{\tt\qquad s}\ null-terminated string\cr
343&{\tt\qquad i}\ machine instructions\cr
344disassem \opt{\it addr}&display memory as machine instructions\cr
345\endsec
346
347\sec Automatic Display;
348display \opt{\tt/\it f\/} {\it expr}&show value of {\it expr} each time
349program stops \opt{according to format {\it f}\/}\cr
350display&display all enabled expressions on list\cr
351undisplay {\it n}&remove number(s) {\it n} from list of
352automatically displayed expressions\cr
353disable disp {\it n}&disable display for expression(s) number {\it
354n}\cr
355enable disp {\it n}&enable display for expression(s) number {\it
356n}\cr
357info display&numbered list of display expressions\cr
358\endsec
359
360\vfill\eject
361
362\sec Expressions;
363{\it expr}&an expression in C, C++, or Modula-2 (including function calls), or:\cr
364{\it addr\/}@{\it len}&an array of {\it len} elements beginning at {\it
365addr}\cr
366{\it file}::{\it nm}&a variable or function {\it nm} defined in {\it
367file}\cr
368$\tt\{${\it type}$\tt\}${\it addr}&read memory at {\it addr} as specified
369{\it type}\cr
370\$&most recent displayed value\cr
371\${\it n}&{\it n}th displayed value\cr
372\$\$&displayed value previous to \$\cr
373\$\${\it n}&{\it n}th displayed value back from \$\cr
374\$\_&last address examined with {\tt x}\cr
375\$\_\_&value at address \$\_\cr
376\${\it var}&convenience variable; assign any value\cr
377\cr
378show values \opt{{\it n}}&show last 10 values \opt{or surrounding
379\${\it n}}\cr
380show convenience&display all convenience variables\cr
381\endsec
382
383\sec Symbol Table;
384info address {\it s}&show where symbol {\it s} is stored\cr
385info func \opt{\it regex}&show names, types of defined functions
386(all, or matching {\it regex})\cr
387info var \opt{\it regex}&show names, types of global variables (all,
388or matching {\it regex})\cr
389whatis \opt{\it expr}\par
390ptype \opt{\it expr}&show data type of {\it expr} \opt{or \tt \$}
391without evaluating; {\tt ptype} gives more detail\cr
392ptype {\it type}&describe type, struct, union, or enum\cr
393\endsec
394
395\sec GDB Scripts;
396source {\it script}&read, execute GDB commands from file {\it
397script}\cr
398\cr
399define {\it cmd}\par
400\qquad {\it command-list}&create new GDB command {\it cmd};
401execute script defined by {\it command-list}\cr
402end&end of {\it command-list}\cr
403document {\it cmd}\par
404\qquad {\it help-text}&create online documentation
405for new GDB command {\it cmd}\cr
406end&end of {\it help-text}\cr
407\endsec
408
409\sec Signals;
410handle {\it signal} {\it act}&specify GDB actions for {\it signal}:\cr
411\quad print&announce signal\cr
412\quad noprint&be silent for signal\cr
413\quad stop&halt execution on signal\cr
414\quad nostop&do not halt execution\cr
415\quad pass&allow your program to handle signal\cr
416\quad nopass&do not allow your program to see signal\cr
417info signals&show table of signals, GDB action for each\cr
418\endsec
419
420\sec Debugging Targets;
421target {\it type} {\it param}&connect to target machine, process, or file\cr
422help target&display available targets\cr
423attach {\it param}&connect to another process\cr
424detach&release target from GDB control\cr
425\endsec
426
427\vfill\eject
428\sec Controlling GDB;
429set {\it param} {\it value}&set one of GDB's internal parameters\cr
430show {\it param}&display current setting of parameter\cr
431\xtra{\rm Parameters understood by {\tt set} and {\tt show}:}
432\quad complaints {\it limit}&number of messages on unusual symbols\cr
433\quad confirm {\it on/off}&enable or disable cautionary queries\cr
434\quad editing {\it on/off}&control {\tt readline} command-line editing\cr
435\quad height {\it lpp}&number of lines before pause in display\cr
436\quad language {\it lang}&Language for GDB expressions ({\tt auto}, {\tt c} or
437{\tt modula-2})\cr
438\quad listsize {\it n}&number of lines shown by {\tt list}\cr
439\quad prompt {\it str}&use {\it str} as GDB prompt\cr
440\quad radix {\it base}&octal, decimal, or hex number representation\cr
441\quad verbose {\it on/off}&control messages when loading
442symbols\cr
443\quad width {\it cpl}&number of characters before line folded\cr
444\quad write {\it on/off}&Allow or forbid patching binary, core files
445(when reopened with {\tt exec} or {\tt core})
446\cr
447\quad history $\ldots$\par
448\quad h $\ldots$&groups with the following options:\cr
449\quad h exp {\it off/on}&disable/enable {\tt readline} history expansion\cr
450\quad h file {\it filename}&file for recording GDB command history\cr
451\quad h size {\it size}&number of commands kept in history list\cr
452\quad h save {\it off/on}&control use of external file for
453command history\cr
454\cr
455\quad print $\ldots$\par
456\quad p $\ldots$&groups with the following options:\cr
457\quad p address {\it on/off}&print memory addresses in stacks,
458values\cr
459\quad p array {\it off/on}&compact or attractive format for
460arrays\cr
461\quad p demangl {\it on/off}&source (demangled) or internal form for C++
462symbols\cr
463\quad p asm-dem {\it on/off}&demangle C++ symbols in
464machine-instruction output\cr
465\quad p elements {\it limit}&number of array elements to display\cr
466\quad p object {\it on/off}&print C++ derived types for objects\cr
467\quad p pretty {\it off/on}&struct display: compact or indented\cr
468\quad p union {\it on/off}&display of union members\cr
469\quad p vtbl {\it off/on}&display of C++ virtual function
470tables\cr
471\cr
472show commands&show last 10 commands\cr
473show commands {\it n}&show 10 commands around number {\it n}\cr
474show commands +&show next 10 commands\cr
475\endsec
476
477\sec Working Files;
478file \opt{\it file}&use {\it file} for both symbols and executable;
479with no arg, discard both\cr
480core \opt{\it file}&read {\it file} as coredump; or discard\cr
481exec \opt{\it file}&use {\it file} as executable only; or discard\cr
482symbol \opt{\it file}&use symbol table from {\it file}; or discard\cr
483load {\it file}&dynamically link {\it file\/} and add its symbols\cr
484add-sym {\it file} {\it addr}&read additional symbols from {\it file},
485dynamically loaded at {\it addr}\cr
486info files&display working files and targets in use\cr
487path {\it dirs}&add {\it dirs} to front of path searched for
488executable and symbol files\cr
489show path&display executable and symbol file path\cr
490info share&list names of shared libraries currently loaded\cr
491\endsec
492
493\vfill\eject
494\sec Source Files;
495dir {\it names}&add directory {\it names} to front of source path\cr
496dir&clear source path\cr
497show dir&show current source path\cr
498\cr
499list&show next ten lines of source\cr
500list -&show previous ten lines\cr
501list {\it lines}&display source centered around {\it lines},
502specified as one of:\cr
503\quad{\opt{\it file\tt:}\it num}&line number \opt{in named file}\cr
504\quad{\opt{\it file\tt:}\it function}&beginning of function \opt{in
505named file}\cr
506\quad{\tt +\it off}&{\it off} lines after last printed\cr
507\quad{\tt -\it off}&{\it off} lines previous to last printed\cr
508\quad{\tt*\it address}&line containing {\it address}\cr
509list {\it f},{\it l}&from line {\it f} to line {\it l}\cr
510info line {\it num}&show starting, ending addresses of compiled code for
511source line {\it num}\cr
512info source&show name of current source file\cr
513info sources&list all source files in use\cr
514forw {\it regex}&search following source lines for {\it regex}\cr
515rev {\it regex}&search preceding source lines for {\it regex}\cr
516\endsec
517
518\sec GDB under GNU Emacs;
519M-x gdb&run GDB under Emacs\cr
520\ctl{h} m&describe GDB mode\cr
521M-s&step one line ({\tt step})\cr
522M-n&next line ({\tt next})\cr
523M-i&step one instruction ({\tt stepi})\cr
524\ctl{c} \ctl{f}&finish current stack frame ({\tt finish})\cr
525M-c&continue ({\tt cont})\cr
526M-u&up {\it arg} frames ({\tt up})\cr
527M-d&down {\it arg} frames ({\tt down})\cr
528\ctl{x} \&&copy number from point, insert at end\cr
529\ctl{x} SPC&(in source file) set break at point\cr
530\endsec
531
532\sec GDB License;
533show copying&Display GNU General Public License\cr
534show warranty&There is NO WARRANTY for GDB. Display full no-warranty
535statement.\cr
536\endsec
537
538
539\vfill
540{\smrm\parskip=6pt
541\centerline{Copyright \copyright 1991, 1992 Free Software Foundation, Inc.}
542\centerline{Roland Pesch (pesch@cygnus.com), January 1992---\manvers}
543\centerline{The author assumes no responsibility for any errors on this card.}
544
545This card may be freely distributed under the terms of the GNU
546General Public License.
547
548\centerline{Please contribute to development of this card by
549annotating it.}
550
551GDB itself is free software; you are welcome to distribute copies of
552it under the terms of the GNU General Public License. There is
553absolutely no warranty for GDB.
554}
555\end
This page took 0.059912 seconds and 4 git commands to generate.