binutils-gdb/gdb/doc/refcard.tex

466 lines
17 KiB
TeX
Raw Normal View History

1991-01-03 17:28:29 +01:00
%This file is TeX source for a reference card describing GDB, the GNU debugger.
%$Id$
1991-01-03 17:28:29 +01:00
%Copyright (C) 1991 Free Software Foundation, Inc.
%Permission is granted to make and distribute verbatim copies of
%this reference provided the copyright notices and permission notices
%are preserved on all copies.
%
%TeX markup is a programming language; accordingly this file is source
%for a program to generate a reference.
%
%This program is free software; you can redistribute it and/or modify
%it under the terms of the GNU General Public License as published by
%the Free Software Foundation; either version 1, or (at your option)
%any later version.
%
%This program is distributed in the hope that it will be useful, but
%WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%General Public License for more details.
%
%You can find a copy of the GNU General Public License in the GDB
%manual; or write to the Free Software Foundation, Inc.,
%675 Mass Ave, Cambridge, MA 02139, USA.
%
%You can contact the author as: pesch@cygnus.com
%
% Roland Pesch
% Cygnus Support
% 814 University Ave.
% Palo Alto, CA 94301 USA
%
% +1 415 322 3811
%
% Cygnus Support is an organization devoted to commercial
% support of free software. For general information
% contact ``info@cygnus.com''
%
% NOTE ON INTENTIONAL OMISSIONS: This reference card includes most GDB
% commands, but due to space constraints there are some things I chose
% to omit. In general, not all synonyms for commands are covered.
% The GDB-under-Emacs section omits gdb-mode functions without default
% keybindings. GDB startup options are not described.
% set print sevenbit-strings, set symbol-reloading omitted.
% set check range/type omitted at least til code is in GDB.
%
1991-01-03 17:28:29 +01:00
{%
\def\$#1${{#1}}% Kluge: collect RCS revision info without $...$
\xdef\manvers{\$Revision$}%
}%
\input threecol
\input rcfonts
%
1991-01-03 17:28:29 +01:00
\vsize=8in
\hyphenpenalty=5000\tolerance=2000\raggedright\raggedbottom
1991-01-03 17:28:29 +01:00
\normalbaselineskip=9pt\baselineskip=9pt
%
\parindent=0pt
\parskip=0pt
\footline={\vbox to0pt{\hss}}
%
\def\ctl#1{{\tt C-#1}}
\def\opt#1{{\brm[{\rm #1}]}}
\def\xtra#1{\noalign{\smallskip{\tt#1}}}
%
\long\def\sec#1;#2\endsec{\vskip 1pc
\halign{%
%COL 1 (of halign):
\vtop{\hsize=1.1in\tt
##\par\vskip 2pt }\hfil
1991-01-03 17:28:29 +01:00
%COL 2 (of halign):
&\vtop{\hsize=2.1in\hangafter=1\hangindent=0.5em
\rm ##\par\vskip 2pt}\cr
%Tail of \long\def fills in halign body with \sec args:
\noalign{{\bbf #1}\vskip 2pt}
#2
}
}
{\vbbf GDB QUICK REFERENCE}
\vskip 5pt
{\smrm GDB Version 4.2---Cygnus Support 1991}
\sec Essential Commands;
gdb {\it program} \opt{{\it core}}&debug {\it program} \opt{using
coredump {\it core}}\cr
b \opt{\it file\tt:}{\it function}&set breakpoint at {\it function} \opt{in \it file}\cr
run \opt{{\it arglist}}&start your program \opt{with {\it arglist}}\cr
bt& backtrace: display program stack\cr
p {\it expr}&display the value of an expression\cr
c &continue running your program\cr
n &next line, stepping over function calls\cr
s &next line, stepping into function calls\cr
\endsec
1991-01-03 17:28:29 +01:00
\sec Starting GDB;
gdb&starts GDB, with no debugging files\cr
gdb {\it program}&begin debugging {\it program}\cr
gdb {\it program core}&debug coredump {\it core} produced by {\it program}\cr
\endsec
\sec Stopping GDB;
quit&exit GDB; also {\tt q} or {\tt EOF} (eg \ctl{d})\cr
INTERRUPT&(eg \ctl{c}) terminate current command, or send to running process\cr
1991-01-03 17:28:29 +01:00
\endsec
\sec Getting Help;
help&list classes of commands\cr
help {\it class}&one-line descriptions for commands in {\it class}\cr
help {\it command}&describe {\it command}\cr
1991-01-03 17:28:29 +01:00
\endsec
\sec Executing your Program;
run {\it arglist}&start your program with {\it arglist}\cr
run&start your program with current argument list\cr
run $\ldots$ <{\it inf} >{\it outf}&start program with input, output
redirected\cr
\cr
kill&kill running program\cr
1991-01-03 17:28:29 +01:00
\cr
tty {\it dev}&use {\it dev} as stdin and stdout for next {\tt run}\cr
1991-01-03 17:28:29 +01:00
set args {\it arglist}&specify {\it arglist} for next
{\tt run}\cr
set args&specify empty argument list\cr
show args&display argument list\cr
\cr
show environment&show all environment variables\cr
show env {\it var}&show value of environment variable {\it var}\cr
set env {\it var} {\it string}&set environment variable {\it var}\cr
unset env {\it var}&remove {\it var} from environment\cr
1991-01-03 17:28:29 +01:00
\endsec
\sec Shell Commands;
cd {\it dir}&change working directory to {\it dir}\cr
1991-01-03 17:28:29 +01:00
pwd&Print working directory\cr
make $\ldots$&call ``{\tt make}''\cr
shell {\it cmd}&execute arbitrary shell command string\cr
1991-01-03 17:28:29 +01:00
\endsec
\vfill
\centerline{\smrm \copyright 1991 Free Software Foundation, Inc.\qquad Permissions on back}
\eject
\sec Breakpoints and Watchpoints;
break \opt{\it file\tt:}{\it line}\par
b \opt{\it file\tt:}{\it line}&set breakpoint at {\it line} number \opt{in \it file}\par
1991-01-03 17:28:29 +01:00
eg:\quad{\tt break main.c:37}\quad\cr
break \opt{\it file\tt:}{\it function}&set breakpoint at {\it
function} \opt{in \it file}\cr
1991-01-03 17:28:29 +01:00
break +{\it offset}\par
break -{\it offset}&set break at {\it offset} lines from current stop\cr
break *{\it addr}&set breakpoint at address {\it addr}\cr
break&set breakpoint at next instruction\cr
break $\ldots$ if {\it expr}&break conditionally on nonzero {\it expr}\cr
cond {\it n} \opt{\it expr}&new conditional expression on breakpoint
{\it n}; make unconditional if no {\it expr}\cr
tbreak $\ldots$&temporary break; disable when reached\cr
rbreak {\it regex}&break on all functions matching {\it regex}\cr
watch {\it expr}&set a watchpoint for expression {\it expr}\cr
catch {\it x}&break at C++ handler for exception {\it x}\cr
1991-01-03 17:28:29 +01:00
\cr
info break&show defined breakpoints\cr
info watch&show defined watchpoints\cr
1991-01-03 17:28:29 +01:00
\cr
clear&delete breakpoints at next instruction\cr
clear \opt{\it file\tt:}{\it fun}&delete breakpoints at entry to {\it fun}()\cr
clear \opt{\it file\tt:}{\it line}&delete breakpoints on source line \cr
delete \opt{{\it n}}&delete breakpoints {\it n};
1991-01-03 17:28:29 +01:00
\opt{or all breakpoints}\cr
\cr
disable \opt{{\it n}}&disable breakpoints {\it n} \opt{or all}\cr
enable \opt{{\it n}}&enable breakpoints {\it n} \opt{or all}\cr
enable once \opt{{\it n}}&enable breakpoints; disable again when
1991-01-03 17:28:29 +01:00
reached\cr
enable del \opt{{\it n}}&enable breakpoints; delete when reached\cr
1991-01-03 17:28:29 +01:00
\cr
ignore {\it n} {\it count}&ignore breakpoint {\it n}, {\it count}
1991-01-03 17:28:29 +01:00
times\cr
\cr
commands {\it n}\par
\qquad {\it command list}&execute GDB {\it command list} every time breakpoint {\it n} is reached\cr
end&end of {\it command list}\cr
1991-01-03 17:28:29 +01:00
\endsec
\sec Program Stack;
backtrace \opt{\it n}\par
bt \opt{\it n}&print trace of all frames in stack; or of {\it n}
frames---innermost if {\it n}{\tt >0}, outermost if {\it n}{\tt <0}\cr
frame \opt{\it n}&select frame number {\it n} or frame at address {\it
n}; if no {\it n}, display current frame\cr
up {\it n}&select frame {\it n} frames up\cr
down {\it n}&select frame {\it n} frames down\cr
info frame \opt{\it addr}&describe selected frame, or frame at
{\it addr}\cr
info args&arguments of selected frame\cr
info locals&local variables of selected frame\cr
info reg \opt{\it{rn}}&register values \opt{for reg {\it rn\/}} in selected frame\cr
info catch&exception handlers active in selected frame\cr
1991-01-03 17:28:29 +01:00
\endsec
\vfill\eject
\sec Execution Control;
continue \opt{\it count}\par
c \opt{\it count}&continue running; if {\it count} specified, ignore
1991-01-03 17:28:29 +01:00
this breakpoint next {\it count} times\cr
\cr
step \opt{\it count}\par
s \opt{\it count}&execute until another line reached; repeat {\it count} times if
1991-01-03 17:28:29 +01:00
specified\cr
\cr
stepi \opt{\it count}\par
si \opt{\it count}&step by machine instructions rather than source
1991-01-03 17:28:29 +01:00
lines\cr
\cr
next \opt{\it count}\par
n \opt{\it count}&execute next line, including any function calls\cr
1991-01-03 17:28:29 +01:00
\cr
nexti \opt{\it count}\par
ni \opt{\it count}&next machine instruction rather than source
1991-01-03 17:28:29 +01:00
line\cr
\cr
until \opt{\it location}&run until next instruction (or {\it
location})\cr
finish&run until selected stack frame returns\cr
return \opt{\it expr}&pop selected stack frame without executing
\opt{setting return value}\cr
signal {\it num}&resume execution with signal {\it s} (none if {\tt 0})\cr
1991-01-03 17:28:29 +01:00
jump {\it line}\par
jump *{\it address}&resume execution at specified {\it line} number or
1991-01-03 17:28:29 +01:00
{\it address}\cr
set var={\it expr}&evaluate {\it expr} without displaying it; use for
1991-01-03 17:28:29 +01:00
altering program variables\cr
\endsec
\sec Display;
1991-01-03 17:28:29 +01:00
print \opt{\tt/{\it f}\/} {\it expr}\par
p \opt{\tt/{\it f}\/} {\it expr}&show value of {\it expr} according to format {\it f}:\cr
1991-01-03 17:28:29 +01:00
\qquad x&hexadecimal\cr
\qquad d&signed decimal\cr
\qquad u&unsigned decimal\cr
\qquad o&octal\cr
\qquad a&address, absolute and relative\cr
\qquad c&character\cr
1991-01-03 17:28:29 +01:00
\qquad f&floating point\cr
call \opt{\tt /{\it f}\/} {\it expr}&like {\tt print} but does not display
1991-01-03 17:28:29 +01:00
{\tt void}\cr
x \opt{\tt/{\it Nuf}\/} {\it expr}&examine memory at address {\it expr};
optional format spec follows slash\cr
\quad {\it N}&count of how many units to display\cr
\quad {\it u}&unit size; one of\cr
1991-01-03 17:28:29 +01:00
&{\tt\qquad b}\ individual bytes\cr
&{\tt\qquad h}\ halfwords (two bytes)\cr
&{\tt\qquad w}\ words (four bytes)\cr
&{\tt\qquad g}\ giant words (eight bytes)\cr
\quad {\it f}&printing format. Any {\tt print} format, or\cr
&{\tt\qquad s}\ null-terminated string\cr
&{\tt\qquad i}\ machine instructions\cr
disassem \opt{\it addr}&display memory as machine instructions\cr
1991-01-03 17:28:29 +01:00
\endsec
\sec Automatic Display;
display \opt{\tt/\it f\/} {\it expr}&show value of {\it expr} each time
1991-01-03 17:28:29 +01:00
program stops \opt{according to format {\it f}\/}\cr
display&display all enabled expressions on list\cr
undisplay {\it n}&remove number(s) {\it n} from list of
1991-01-03 17:28:29 +01:00
automatically displayed expressions\cr
disable disp {\it n}&disable display for expression(s) number {\it
n}\cr
enable disp {\it n}&enable display for expression(s) number {\it
n}\cr
info display&numbered list of display expressions\cr
1991-01-03 17:28:29 +01:00
\endsec
\vfill\eject
\sec Expressions;
{\it expr}&an expression in C, C++, or Modula-2 (including function calls), or:\cr
{\it addr\/}@{\it len}&an array of {\it len} elements beginning at {\it
addr}\cr
{\it file}::{\it nm}&a variable or function {\it nm} defined in {\it
file}\cr
$\tt\{${\it type}$\tt\}${\it addr}&read memory at {\it addr} as specified
{\it type}\cr
\$&most recent displayed value\cr
\${\it n}&{\it n}th displayed value\cr
\$\$&displayed value previous to \$\cr
\$\${\it n}&{\it n}th displayed value back from \$\cr
\$\_&last address examined with {\tt x}\cr
\$\_\_&value at address \$\_\cr
\${\it var}&convenience variable; assign any value\cr
\cr
show values \opt{{\it n}}&show last 10 values \opt{or surrounding
\${\it n}}\cr
show convenience&display all convenience variables\cr
1991-01-03 17:28:29 +01:00
\endsec
\sec Symbol Table;
info address {\it s}&show where symbol {\it s} is stored\cr
info func \opt{\it regex}&show names, types of defined functions
1991-01-03 17:28:29 +01:00
(all, or matching {\it regex})\cr
info var \opt{\it regex}&show names, types of global variables (all,
1991-01-03 17:28:29 +01:00
or matching {\it regex})\cr
whatis {\it expr}\par
ptype {\it expr}&show data type of {\it expr} without evaluating; {\tt
1991-01-03 17:28:29 +01:00
ptype} gives more detail\cr
ptype {\it type}&describe type, struct, union, or enum\cr
\endsec
\sec GDB Scripts;
source {\it script}&read, execute GDB commands from file {\it
script}\cr
\cr
define {\it cmd}\par
\qquad {\it command list}&new GDB command {\it cmd}, executes script
defined by {\it command list} \cr
end&end of {\it command list}\cr
document {\it cmd}\par
\qquad {\it help text}&new online documentation for GDB command {\it
cmd}\cr
end&end of {\it help text}\cr
\endsec
\sec Signals;
handle {\it signal} {\it act}&specify GDB actions for {\it signal}:\cr
\quad print&announce signal\cr
\quad noprint&be silent for signal\cr
\quad stop&halt execution on signal\cr
\quad nostop&do not halt execution\cr
\quad pass&allow your program to handle signal\cr
\quad nopass&do not allow your program to see signal\cr
info signals&show table of signals, GDB action for each\cr
\endsec
\sec Debugging Targets;
target {\it type} {\it param}&connect to target machine, process, or file\cr
help target&display available targets\cr
attach {\it param}&connect to another process\cr
detach&release target from GDB control\cr
1991-01-03 17:28:29 +01:00
\endsec
\vfill\eject
\sec Controlling GDB;
set {\it param} {\it value}&set one of GDB's internal parameters\cr
show {\it param}&display current setting of a GDB parameter\cr
1991-01-03 17:28:29 +01:00
\xtra{\rm Parameters understood by {\tt set} and {\tt show}:}
\quad complaints {\it limit}&number of messages on unusual symbols\cr
\quad confirm {\it on/off}&enable or disable cautionary queries\cr
\quad editing {\it on/off}&control {\tt readline} command-line editing\cr
\quad height {\it lpp}&number of lines before pause in display\cr
\quad language {\it lang}&Language for GDB expressions ({\tt auto}, {\tt c} or
{\tt modula-2})\cr
\quad listsize {\it n}&number of lines shown by {\tt list}\cr
\quad prompt {\it str}&use {\it str} as GDB prompt\cr
\quad radix {\it base}&octal, decimal, or hex number representation\cr
\quad verbose {\it on/off}&control messages when loading
1991-01-03 17:28:29 +01:00
symbol table\cr
\quad width {\it cpl}&number of characters before line folded\cr
\quad write {\it on/off}&Allow or forbid patching binary, core files
(when reopened with {\tt exec} or {\tt core})
\cr
\quad history $\ldots$&({\tt h}) groups the following options:\cr
\quad h exp {\it off/on}&disable or enable {\tt readline} history expansion\cr
\quad h file {\it filename}&file for recording GDB command history\cr
\quad h size {\it size}&number of commands kept in history list\cr
\quad h save {\it off/on}&control use of external file for
command history\cr
\cr
\quad print $\ldots$&({\tt p}) groups the following options:\cr
\quad p address {\it on/off}&print memory addresses in stacks,
values\cr
\quad p array {\it off/on}&compact or attractive format for
arrays\cr
\quad p demangl {\it on/off}&source (demangled) or internal form for C++
symbols\cr
\quad p asm-dem {\it on/off}&demangle C++ symbols in
machine-instruction output\cr
\quad p elements {\it limit}&number of elements to display from an
array\cr
\quad p object {\it on/off}&print C++ derived types for objects\cr
\quad p pretty {\it off/on}&struct display: compact or indented\cr
\quad p union {\it on/off}&enable or disable display of union members\cr
\quad p vtbl {\it off/on}&display of C++ virtual function
tables\cr
\cr
show commands&show last 10 commands\cr
show commands {\it n}&show 10 commands around number {\it n}\cr
show commands +&show next 10 commands\cr
1991-01-03 17:28:29 +01:00
\endsec
\sec Working Files;
file {\it file}&use {\it file} for symbols and executable\cr
core {\it file}&read {\it file} as coredump\cr
exec {\it file}&use {\it file} as executable only\cr
symbol {\it file}&use only symbol table from {\it file}\cr
load {\it file}&dynamically link {\it file\/} and add its symbols\cr
add-sym {\it file} {\it addr}&read additional symbols from {\it file},
1991-01-03 17:28:29 +01:00
dynamically loaded at {\it addr}\cr
info files&display working files and targets in use\cr
path {\it dirs}&add {\it dirs} to front of path searched for
executable and symbol files\cr
show path&display executable and symbol file path\cr
info share&list names of shared libraries currently loaded\cr
1991-01-03 17:28:29 +01:00
\endsec
\vfill\eject
\sec Source Files;
dir {\it names}&add directory {\it names} to front of source path\cr
dir&clear source path\cr
show dir&show current source path\cr
1991-01-03 17:28:29 +01:00
\cr
list&show next ten lines of source\cr
list -&show previous ten lines\cr
list {\it lines}&display source centered around {\it lines},
1991-01-03 17:28:29 +01:00
specified as one of:\cr
\quad{\opt{\it file\tt:}\it num}&line number \opt{in named file}\cr
\quad{\opt{\it file\tt:}\it function}&beginning of function \opt{in
1991-01-03 17:28:29 +01:00
named file}\cr
\quad{\tt +\it off}&{\it off} lines after last printed\cr
\quad{\tt -\it off}&{\it off} lines previous to last printed\cr
\quad{\tt*\it address}&line containing {\it address}\cr
1991-01-03 17:28:29 +01:00
list {\it f},{\it l}&from line {\it f} to line {\it l}\cr
info line {\it num}&show starting, ending addresses of compiled code for
1991-01-03 17:28:29 +01:00
source line {\it num}\cr
info source&show name of current source file\cr
info sources&list all source files in use\cr
forw {\it regex}&search following source lines for {\it regex}\cr
rev {\it regex}&search preceding source lines for {\it regex}\cr
1991-01-03 17:28:29 +01:00
\endsec
\sec GDB under GNU Emacs;
M-x gdb&run GDB under Emacs\cr
\ctl{h} m&describe GDB mode\cr
M-s&step one line ({\tt step})\cr
M-n&next line ({\tt next})\cr
M-i&step one instruction ({\tt stepi})\cr
\ctl{c} \ctl{f}&finish current stack frame ({\tt finish})\cr
M-c&continue ({\tt cont})\cr
M-u&up {\it arg} frames ({\tt up})\cr
M-d&down {\it arg} frames ({\tt down})\cr
\ctl{x} \&&copy number from point, insert at end\cr
1991-01-03 17:28:29 +01:00
\ctl{x} SPC&(in source file) set break at point\cr
\endsec
\sec GDB License;
info copying&Display GNU General Public License\cr
info warranty&There is NO WARRANTY for GDB. Display full no-warranty
statement.\cr
\endsec
1991-01-03 17:28:29 +01:00
\vfill
{\smrm\parskip=6pt
\centerline{Copyright \copyright 1991 Free Software Foundation, Inc.}
\centerline{Roland Pesch (pesch@cygnus.com), September 1991---\manvers}
\centerline{The author assumes no responsibility for any errors on this card.}
1991-01-03 17:28:29 +01:00
This card may be freely distributed under the terms of the GNU
General Public License.
\centerline{Please contribute to development of this card by
annotating it.}
GDB itself is free software; you are welcome to distribute copies of
it under the terms of the GNU General Public License. There is
absolutely no warranty for GDB.
}
1991-01-03 17:28:29 +01:00
\end