BSD 4_3_Tahoe development
[unix-history] / usr / man / cat1 / adb.0
ADB(1) UNIX Programmer's Manual ADB(1)
N\bNA\bAM\bME\bE
adb - debugger
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
a\bad\bdb\bb [-\b-w\bw] [ -\b-k\bk ] [ -\b-I\bIdir ] [ objfil [ corfil ] ]
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
_\bA_\bd_\bb is a general purpose debugging program. It may be used
to examine files and to provide a controlled environment for
the execution of UNIX programs.
_\bO_\bb_\bj_\bf_\bi_\bl is normally an executable program file, preferably
containing a symbol table; if not then the symbolic features
of _\ba_\bd_\bb cannot be used although the file can still be exam-
ined. The default for _\bo_\bb_\bj_\bf_\bi_\bl is a\ba.\b.o\bou\but\bt.\b. _\bC_\bo_\br_\bf_\bi_\bl is assumed to
be a core image file produced after executing _\bo_\bb_\bj_\bf_\bi_\bl; the
default for _\bc_\bo_\br_\bf_\bi_\bl is c\bco\bor\bre\be.\b.
Requests to _\ba_\bd_\bb are read from the standard input and
responses are to the standard output. If the -\b-w\bw flag is
present then both _\bo_\bb_\bj_\bf_\bi_\bl and _\bc_\bo_\br_\bf_\bi_\bl are created if necessary
and opened for reading and writing so that files can be
modified using _\ba_\bd_\bb.
The -\b-k\bk option makes _\ba_\bd_\bb do UNIX kernel memory mapping; it
should be used when _\bc_\bo_\br_\be is a UNIX crash dump or /_\bd_\be_\bv/_\bm_\be_\bm.
The -\b-I\bI option specifies a directory where files to be read
with $< or $<< (see below) will be sought; the default is
/_\bu_\bs_\br/_\bl_\bi_\bb/_\ba_\bd_\bb.
_\bA_\bd_\bb ignores QUIT; INTERRUPT causes return to the next _\ba_\bd_\bb
command.
In general requests to _\ba_\bd_\bb are of the form
[_\ba_\bd_\bd_\br_\be_\bs_\bs] [, _\bc_\bo_\bu_\bn_\bt] [_\bc_\bo_\bm_\bm_\ba_\bn_\bd] [;]
If _\ba_\bd_\bd_\br_\be_\bs_\bs is present then _\bd_\bo_\bt is set to _\ba_\bd_\bd_\br_\be_\bs_\bs. Initially
_\bd_\bo_\bt is set to 0. For most commands _\bc_\bo_\bu_\bn_\bt specifies how many
times the command will be executed. The default _\bc_\bo_\bu_\bn_\bt is 1.
_\bA_\bd_\bd_\br_\be_\bs_\bs and _\bc_\bo_\bu_\bn_\bt are expressions.
The interpretation of an address depends on the context it
is used in. If a subprocess is being debugged then
addresses are interpreted in the usual way in the address
space of the subprocess. If the operating system is being
debugged either post-mortem or using the special file
/_\bd_\be_\bv/_\bm_\be_\bm to interactive examine and/or modify memory the
maps are set to map the kernel virtual addresses which start
at 0x80000000 (on the VAX). ADDRESSES.
Printed 7/9/88 April 29, 1985 1
ADB(1) UNIX Programmer's Manual ADB(1)
E\bEX\bXP\bPR\bRE\bES\bSS\bSI\bIO\bON\bNS\bS
.\b. The value of _\bd_\bo_\bt.
+ The value of _\bd_\bo_\bt incremented by the current incre-
ment.
^ The value of _\bd_\bo_\bt decremented by the current incre-
ment.
" The last _\ba_\bd_\bd_\br_\be_\bs_\bs typed.
_\bi_\bn_\bt_\be_\bg_\be_\br
A number. The prefixes 0o and 0O ("zero oh") force
interpretation in octal radix; the prefixes 0t and 0T
force interpretation in decimal radix; the prefixes
0x and 0X force interpretation in hexadecimal radix.
Thus 0o20 = 0t16 = 0x10 = sixteen. If no prefix
appears, then the _\bd_\be_\bf_\ba_\bu_\bl_\bt _\br_\ba_\bd_\bi_\bx is used; see the $d
command. The default radix is initially hexadecimal.
The hexadecimal digits are 0123456789abcdefABCDEF
with the obvious values. Note that a hexadecimal
number whose most significant digit would otherwise
be an alphabetic character must have a 0x (or 0X)
prefix (or a leading zero if the default radix is
hexadecimal).
_\bi_\bn_\bt_\be_\bg_\be_\br.\b._\bf_\br_\ba_\bc_\bt_\bi_\bo_\bn
A 32 bit floating point number.
'_\bc_\bc_\bc_\bc' The ASCII value of up to 4 characters. \ may be used
to escape a '.
< _\bn_\ba_\bm_\be The value of _\bn_\ba_\bm_\be, which is either a variable name or
a register name. _\bA_\bd_\bb maintains a number of variables
(see VARIABLES) named by single letters or digits.
If _\bn_\ba_\bm_\be is a register name then the value of the
register is obtained from the system header in _\bc_\bo_\br_\b-
_\bf_\bi_\bl. The register names are those printed by the $r
command.
_\bs_\by_\bm_\bb_\bo_\bl A _\bs_\by_\bm_\bb_\bo_\bl is a sequence of upper or lower case
letters, underscores or digits, not starting with a
digit. The backslash character \\b\ may be used to
escape other characters. The value of the _\bs_\by_\bm_\bb_\bo_\bl is
taken from the symbol table in _\bo_\bb_\bj_\bf_\bi_\bl. An initial _
will be prepended to _\bs_\by_\bm_\bb_\bo_\bl if needed.
_ _\bs_\by_\bm_\bb_\bo_\bl
In C, the `true name' of an external symbol begins
with _. It may be necessary to utter this name to
distinguish it from internal or hidden variables of a
program.
Printed 7/9/88 April 29, 1985 2
ADB(1) UNIX Programmer's Manual ADB(1)
_\br_\bo_\bu_\bt_\bi_\bn_\be.\b._\bn_\ba_\bm_\be
The address of the variable _\bn_\ba_\bm_\be in the specified C
routine. Both _\br_\bo_\bu_\bt_\bi_\bn_\be and _\bn_\ba_\bm_\be are _\bs_\by_\bm_\bb_\bo_\bl_\bs. If _\bn_\ba_\bm_\be
is omitted the value is the address of the most
recently activated C stack frame corresponding to
_\br_\bo_\bu_\bt_\bi_\bn_\be. (This form is currently broken on the VAX;
local variables can be examined only with _\bd_\bb_\bx(1).)
(_\be_\bx_\bp) The value of the expression _\be_\bx_\bp.
M\bMo\bon\bna\bad\bdi\bic\bc o\bop\bpe\ber\bra\bat\bto\bor\brs\bs
*_\be_\bx_\bp The contents of the location addressed by _\be_\bx_\bp in _\bc_\bo_\br_\b-
_\bf_\bi_\bl.
@_\be_\bx_\bp The contents of the location addressed by _\be_\bx_\bp in
_\bo_\bb_\bj_\bf_\bi_\bl.
-_\be_\bx_\bp Integer negation.
~_\be_\bx_\bp Bitwise complement.
#_\be_\bx_\bp Logical negation.
D\bDy\bya\bad\bdi\bic\bc o\bop\bpe\ber\bra\bat\bto\bor\brs\bs are left associative and are less binding
than monadic operators.
_\be_\b1+_\be_\b2 Integer addition.
_\be_\b1-_\be_\b2 Integer subtraction.
_\be_\b1*_\be_\b2 Integer multiplication.
_\be_\b1%_\be_\b2 Integer division.
_\be_\b1&_\be_\b2 Bitwise conjunction.
_\be_\b1|_\be_\b2 Bitwise disjunction.
_\be_\b1#_\be_\b2 _\bE_\b1 rounded up to the next multiple of _\be_\b2.
C\bCO\bOM\bMM\bMA\bAN\bND\bDS\bS
Most commands consist of a verb followed by a modifier or
list of modifiers. The following verbs are available. (The
commands `?' and `/' may be followed by `*'; see ADDRESSES
for further details.)
?_\bf Locations starting at _\ba_\bd_\bd_\br_\be_\bs_\bs in _\bo_\bb_\bj_\bf_\bi_\bl are printed
according to the format _\bf. _\bd_\bo_\bt is incremented by the
sum of the increments for each format letter (q.v.).
/_\bf Locations starting at _\ba_\bd_\bd_\br_\be_\bs_\bs in _\bc_\bo_\br_\bf_\bi_\bl are printed
Printed 7/9/88 April 29, 1985 3
ADB(1) UNIX Programmer's Manual ADB(1)
according to the format _\bf and _\bd_\bo_\bt is incremented as for
`?'.
=_\bf The value of _\ba_\bd_\bd_\br_\be_\bs_\bs itself is printed in the styles
indicated by the format _\bf. (For i\bi format `?' is
printed for the parts of the instruction that reference
subsequent words.)
A _\bf_\bo_\br_\bm_\ba_\bt consists of one or more characters that specify a
style of printing. Each format character may be preceded by
a decimal integer that is a repeat count for the format
character. While stepping through a format _\bd_\bo_\bt is incre-
mented by the amount given for each format letter. If no
format is given then the last format is used. The format
letters available are as follows.
o\bo 2 Print 2 bytes in octal. All octal numbers output
by _\ba_\bd_\bb are preceded by 0.
O\bO 4 Print 4 bytes in octal.
q\bq 2 Print in signed octal.
Q\bQ 4 Print long signed octal.
d\bd 2 Print in decimal.
D\bD 4 Print long decimal.
x\bx 2 Print 2 bytes in hexadecimal.
X\bX 4 Print 4 bytes in hexadecimal.
u\bu 2 Print as an unsigned decimal number.
U\bU 4 Print long unsigned decimal.
f\bf 4 Print the 32 bit value as a floating point number.
F\bF 8 Print double floating point.
b\bb 1 Print the addressed byte in octal.
c\bc 1 Print the addressed character.
C\bC 1 Print the addressed character using the standard
escape convention where control characters are
printed as ^X and the delete character is printed
as ^?.
s\bs _\bn Print the addressed characters until a zero char-
acter is reached.
S\bS _\bn Print a string using the ^_\bX escape convention (see
C\bC above). _\bn is the length of the string including
its zero terminator.
Y\bY 4 Print 4 bytes in date format (see _\bc_\bt_\bi_\bm_\be(3)).
i\bi n Print as machine instructions. _\bn is the number of
bytes occupied by the instruction. This style of
printing causes variables 1 and 2 to be set to the
offset parts of the source and destination respec-
tively.
a\ba 0 Print the value of _\bd_\bo_\bt in symbolic form. Symbols
are checked to ensure that they have an appropri-
ate type as indicated below.
/ local or global data symbol
? local or global text symbol
Printed 7/9/88 April 29, 1985 4
ADB(1) UNIX Programmer's Manual ADB(1)
= local or global absolute symbol
p\bp 4 Print the addressed value in symbolic form using
the same rules for symbol lookup as a\ba.
t\bt 0 When preceded by an integer tabs to the next
appropriate tab stop. For example, 8\b8t\bt moves to
the next 8-space tab stop.
r\br 0 Print a space.
n\bn 0 Print a newline.
"\b".\b..\b..\b."\b" 0
Print the enclosed string.
^\b^ _\bD_\bo_\bt is decremented by the current increment.
Nothing is printed.
+ _\bD_\bo_\bt is incremented by 1. Nothing is printed.
- _\bD_\bo_\bt is decremented by 1. Nothing is printed.
newline
Repeat the previous command with a _\bc_\bo_\bu_\bn_\bt of 1.
[?\b?/\b/]l\bl _\bv_\ba_\bl_\bu_\be _\bm_\ba_\bs_\bk
Words starting at _\bd_\bo_\bt are masked with _\bm_\ba_\bs_\bk and compared
with _\bv_\ba_\bl_\bu_\be until a match is found. If L\bL is used then
the match is for 4 bytes at a time instead of 2. If no
match is found then _\bd_\bo_\bt is unchanged; otherwise _\bd_\bo_\bt is
set to the matched location. If _\bm_\ba_\bs_\bk is omitted then
-1 is used.
[?\b?/\b/]w\bw _\bv_\ba_\bl_\bu_\be ...
Write the 2-byte _\bv_\ba_\bl_\bu_\be into the addressed location. If
the command is W\bW, write 4 bytes. Odd addresses are not
allowed when writing to the subprocess address space.
[?\b?/\b/]m\bm _\bb_\b1 _\be_\b1 _\bf_\b1[?\b?/\b/]
New values for (_\bb_\b1, _\be_\b1, _\bf_\b1) are recorded. If less than
three expressions are given then the remaining map
parameters are left unchanged. If the `?' or `/' is
followed by `*' then the second segment (_\bb_\b2,_\be_\b2,_\bf_\b2) of
the mapping is changed. If the list is terminated by
`?' or `/' then the file (_\bo_\bb_\bj_\bf_\bi_\bl or _\bc_\bo_\br_\bf_\bi_\bl respec-
tively) is used for subsequent requests. (So that, for
example, `/m?' will cause `/' to refer to _\bo_\bb_\bj_\bf_\bi_\bl.)
>\b>_\bn_\ba_\bm_\be
_\bD_\bo_\bt is assigned to the variable or register named.
!\b! A shell (/bin/sh) is called to read the rest of the
line following `!'.
$_\bm_\bo_\bd_\bi_\bf_\bi_\be_\br
Miscellaneous commands. The available _\bm_\bo_\bd_\bi_\bf_\bi_\be_\br_\bs are:
<\b<_\bf Read commands from the file _\bf. If this command is
Printed 7/9/88 April 29, 1985 5
ADB(1) UNIX Programmer's Manual ADB(1)
executed in a file, further commands in the file
are not seen. If _\bf is omitted, the current input
stream is terminated. If a _\bc_\bo_\bu_\bn_\bt is given, and is
zero, the command will be ignored. The value of
the count will be placed in variable _\b9 before the
first command in _\bf is executed.
<\b<<\b<_\bf Similar to <\b< except it can be used in a file of
commands without causing the file to be closed.
Variable _\b9 is saved during the execution of this
command, and restored when it completes. There is
a (small) finite limit to the number of <\b<<\b< files
that can be open at once.
>\b>_\bf Append output to the file _\bf, which is created if
it does not exist. If _\bf is omitted, output is
returned to the terminal.
?\b? Print process id, the signal which caused stoppage
or termination, as well as the registers as $\b$r\br.
This is the default if _\bm_\bo_\bd_\bi_\bf_\bi_\be_\br is omitted.
r\br Print the general registers and the instruction
addressed by p\bpc\bc. _\bD_\bo_\bt is set to p\bpc\bc.
b\bb Print all breakpoints and their associated counts
and commands.
c\bc C stack backtrace. If _\ba_\bd_\bd_\br_\be_\bs_\bs is given then it is
taken as the address of the current frame instead
of the contents of the frame-pointer register. If
C\bC is used then the names and (32 bit) values of
all automatic and static variables are printed for
each active function. (broken on the VAX). If
_\bc_\bo_\bu_\bn_\bt is given then only the first _\bc_\bo_\bu_\bn_\bt frames
are printed.
d\bd Set the default radix to _\ba_\bd_\bd_\br_\be_\bs_\bs and report the
new value. Note that _\ba_\bd_\bd_\br_\be_\bs_\bs is interpreted in
the (old) current radix. Thus "10$d" never
changes the default radix. To make decimal the
default radix, use "0t10$d".
e\be The names and values of external variables are
printed.
w\bw Set the page width for output to _\ba_\bd_\bd_\br_\be_\bs_\bs (default
80).
s\bs Set the limit for symbol matches to _\ba_\bd_\bd_\br_\be_\bs_\bs
(default 255).
o\bo All integers input are regarded as octal.
q\bq Exit from _\ba_\bd_\bb.
v\bv Print all non zero variables in octal.
m\bm Print the address map.
p\bp (_\bK_\be_\br_\bn_\be_\bl _\bd_\be_\bb_\bu_\bg_\bg_\bi_\bn_\bg) Change the current kernel
memory mapping to map the designated u\bus\bse\ber\br s\bst\btr\bru\buc\bc-\b-
t\btu\bur\bre\be to the address given by the symbol __\bu. The
_\ba_\bd_\bd_\br_\be_\bs_\bs argument is the address of the user's user
page table entries (on the VAX).
:\b:_\bm_\bo_\bd_\bi_\bf_\bi_\be_\br
Printed 7/9/88 April 29, 1985 6
ADB(1) UNIX Programmer's Manual ADB(1)
Manage a subprocess. Available modifiers are:
b\bb_\bc Set breakpoint at _\ba_\bd_\bd_\br_\be_\bs_\bs. The breakpoint is exe-
cuted _\bc_\bo_\bu_\bn_\bt-1 times before causing a stop. Each
time the breakpoint is encountered the command _\bc
is executed. If this command is omitted or sets
_\bd_\bo_\bt to zero then the breakpoint causes a stop.
d\bd Delete breakpoint at _\ba_\bd_\bd_\br_\be_\bs_\bs.
r\br Run _\bo_\bb_\bj_\bf_\bi_\bl as a subprocess. If _\ba_\bd_\bd_\br_\be_\bs_\bs is given
explicitly then the program is entered at this
point; otherwise the program is entered at its
standard entry point. _\bc_\bo_\bu_\bn_\bt specifies how many
breakpoints are to be ignored before stopping.
Arguments to the subprocess may be supplied on the
same line as the command. An argument starting
with < or > causes the standard input or output to
be established for the command.
c\bc_\bs The subprocess is continued with signal _\bs, see
_\bs_\bi_\bg_\bv_\be_\bc(2). If _\ba_\bd_\bd_\br_\be_\bs_\bs is given then the subpro-
cess is continued at this address. If no signal
is specified then the signal that caused the sub-
process to stop is sent. Breakpoint skipping is
the same as for r\br.
s\bs_\bs As for c\bc except that the subprocess is single
stepped _\bc_\bo_\bu_\bn_\bt times. If there is no current sub-
process then _\bo_\bb_\bj_\bf_\bi_\bl is run as a subprocess as for
r\br. In this case no signal can be sent; the
remainder of the line is treated as arguments to
the subprocess.
k\bk The current subprocess, if any, is terminated.
V\bVA\bAR\bRI\bIA\bAB\bBL\bLE\bES\bS
_\bA_\bd_\bb provides a number of variables. Named variables are set
initially by _\ba_\bd_\bb but are not used subsequently. Numbered
variables are reserved for communication as follows.
0 The last value printed.
1 The last offset part of an instruction source.
2 The previous value of variable 1.
9 The count on the last $< or $<< command.
On entry the following are set from the system header in the
_\bc_\bo_\br_\bf_\bi_\bl. If _\bc_\bo_\br_\bf_\bi_\bl does not appear to be a c\bco\bor\bre\be file then
these values are set from _\bo_\bb_\bj_\bf_\bi_\bl.
b The base address of the data segment.
d The data segment size.
Printed 7/9/88 April 29, 1985 7
ADB(1) UNIX Programmer's Manual ADB(1)
e The entry point.
m The `magic' number (0407, 0410 or 0413).
s The stack segment size.
t The text segment size.
A\bAD\bDD\bDR\bRE\bES\bSS\bSE\bES\bS
The address in a file associated with a written address is
determined by a mapping associated with that file. Each
mapping is represented by two triples (_\bb_\b1, _\be_\b1, _\bf_\b1) and (_\bb_\b2,
_\be_\b2, _\bf_\b2) and the _\bf_\bi_\bl_\be _\ba_\bd_\bd_\br_\be_\bs_\bs corresponding to a written
_\ba_\bd_\bd_\br_\be_\bs_\bs is calculated as follows.
_\bb_\b1<\b__\ba_\bd_\bd_\br_\be_\bs_\bs<_\be_\b1 => _\bf_\bi_\bl_\be _\ba_\bd_\bd_\br_\be_\bs_\bs=_\ba_\bd_\bd_\br_\be_\bs_\bs+_\bf_\b1-_\bb_\b1, otherwise,
_\bb_\b2<\b__\ba_\bd_\bd_\br_\be_\bs_\bs<_\be_\b2 => _\bf_\bi_\bl_\be _\ba_\bd_\bd_\br_\be_\bs_\bs=_\ba_\bd_\bd_\br_\be_\bs_\bs+_\bf_\b2-_\bb_\b2,
otherwise, the requested _\ba_\bd_\bd_\br_\be_\bs_\bs is not legal. In some
cases (e.g. for programs with separated I and D space) the
two segments for a file may overlap. If a ?\b? or /\b/ is fol-
lowed by an *\b* then only the second triple is used.
The initial setting of both mappings is suitable for normal
a\ba.\b.o\bou\but\bt and c\bco\bor\bre\be files. If either file is not of the kind
expected then, for that file, _\bb_\b1 is set to 0, _\be_\b1 is set to
the maximum file size and _\bf_\b1 is set to 0; in this way the
whole file can be examined with no address translation.
F\bFI\bIL\bLE\bES\bS
a.out
core
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
cc(1), dbx(1), ptrace(2), a.out(5), core(5)
D\bDI\bIA\bAG\bGN\bNO\bOS\bST\bTI\bIC\bCS\bS
`Adb' when there is no current command or format. Comments
about inaccessible files, syntax errors, abnormal termina-
tion of commands, etc. Exit status is 0, unless last com-
mand failed or returned nonzero status.
B\bBU\bUG\bGS\bS
Since no shell is invoked to interpret the arguments of the
:\b:r\br command, the customary wild-card and variable expansions
cannot occur.
Printed 7/9/88 April 29, 1985 8