adb
PURPOSE
Provides a general purpose debugger.
SYNOPSIS
adb [-w -p prompt]... [ objfil [corfil][core]][-a.out core]
DESCRIPTION
The adb command provides a debugger for C and assembler
language programs. With it, you can examine object and
core files and provide a controlled environment for
running a program.
Normally, objfil is an executable program file that con-
tains a symbol table. If objfil does not contain a
symbol table, the symbolic features of adb cannot be
used, although the file can still be examined. The
default objfil is a.out.
The corfil is assumed to be a core image file produced by
running objfil. The default corfil is core.
While running, adb takes input from standard input and
writes to standard output. adb does not recognize the
Quit or Interrupt keys. These keys cause adb to wait for
a new command.
In general, requests to adb are of the form
[address] [,count] [command] [;]
where address and count are expressions. The default
count is 1. If address is specified, then the expression
. (dot) is set to address.
The interpretation of an address depends on the context
in which it is used. If a subprocess is being debugged,
addresses are interpreted in the usual way in the address
space of the subprocess. For more information, see
"Addresses" on page .
You can enter more than one command at a time by sepa-
rating the commands with a ; (semicolon).
Expressions
. Specifies the last address used by a command;
this is also known as the current address.
+ Increases the value of . (dot) by the current
increment.
^ Decreases the value of . (dot) by the current
increment.
" Specifies the last address typed by a command.
integer Specifies an octal number if integer begins
with 0o, a hexadecimal number if preceded by 0x
or #, or a decimal number if preceded by 0t;
otherwise, a number interpreted in the current
radix. The radix is initially 16.
'cccc' Specifies the ASCII value of up to 4 charac-
ters. \ (slash) can be used to escape an '
(apostrophe).
< name Reads the current value of name. name is
either a variable name or a register name. adb
maintains a number of variables (see
"Variables" on page ) named by single letters
or digits. If name is a register name, the
value of the register is obtained from the
system header in corfil. The register names
are r0...r15, pc, ics, cs, mq; the names fp,
pcp, and link are recognized as synonyms for
r1, r14, and r15.
symbol Specifies a sequence of upper or lower case
letters, underscores, or digits, not starting
with a digit. The value of the symbol is taken
from the symbol table in objfil. An initial _
(underscore) is prefixed to symbol if needed.
_symbol Specifies, in C, the true name of an external
symbol begins with _ (underscore), as does the
name of the constant pool of an external func-
tion. It may be necessary to use this name to
distinguish it from internal or hidden vari-
ables of a program.
.symbol Specifies the entry point of the function named
by symbol.
routine.name
Specifies the address of the variable name in
the specified C routine. Both routine and name
are symbols. If name is omitted the value is
the address of the most recently activated C
stack frame corresponding to routine.
(exp) Specifies the value of the expression exp.
Operators
Integers, symbols, variables, and register names can be
combined with the following operators:
Unary
*exp Contents of location addressed by exp in
corefile.
@exp Contents of the location addressed by exp in
objfil.
-exp Integer negation.
~exp Bitwise complement.
Binary
e1+e2 Integer addition.
e1-e2 Integer subtraction.
e1*e2 Integer multiplication.
e1%e2 Integer division.
e1&e2 Bitwise conjunction.
e1|e2 Bitwise disjunction.
e1#e2 e1 rounded up to the next multiple of e2.
Binary operators are left associative and are less
binding than unary operators.
Commands
You can display the contents of a text or data segment
with the ? (question mark) or the / (slash) command. The
= (equal) command displays a given address in the speci-
fied format f. (The commands ? and / may be followed by
* (asterisk), see "Addresses" on page .)
?f Displays, in the format f, the contents of the
objfil starting at address. The value of .
(dot) increases by the sum of the increment for
each format letter.
/f Displays, in the format f, the contents of the
corfil starting at address. The value of .
(dot) increases by the sum of the increment for
each format letter.
=f Displays the value of address in the format f.
The i and s format letters are not meaningful
for this command.
The format consists of one or more characters that
specify print style. Each format character may be pre-
ceded by a decimal integer that is a repeat count for the
format character. While stepping through a format, .
(dot) increments by the amount given for each format
letter. If no format is given, the last format is used.
The format letters available are as follows:
o 2 Prints 2 bytes in octal.
O 4 Prints 4 bytes in octal.
q 2 Prints 2 bytes in the current radix,
unsigned.
Q 4 Prints 4 bytes in the current radix,
unsigned.
d 2 Prints in decimal.
D 4 Prints long decimal.
x 2 Prints 2 bytes in hexadecimal.
X 4 Prints 4 bytes in hexadecimal.
u 2 Prints as an unsigned decimal number.
U 4 Prints long unsigned decimal.
b 1 Prints the addressed byte in the current
radix, unsigned.
c 1 Prints the addressed character.
C 1 Prints the addressed character using the fol-
lowing escape conventions:
1. Prints control characters as ~ followed
by the corresponding printing character.
2. Prints non-printable characters as ~<n>
where n is a hexadecimal value of the
character. The character ~ prints as ~
~.
s n Prints the addressed character until a zero
character is reached.
S n Prints a string using the ~ escape conven-
tion. n specifies the length of the string
including its zero terminator.
Y 4 Prints 4 bytes in date format (see ctime in
AIX Operating System Technical Reference).
i n Prints as instructions. n is the number of
bytes occupied by the instruction.
a 0 Prints the value of . (dot) in symbolic form.
Symbols are checked to ensure that they have
an appropriate type as follows:
/ local or global data symbol
? local or global text symbol
= local or global absolute symbol
p 4 Prints the addressed value in symbolic form
using the same rules for symbol lookup as a.
t 0 When preceded by an integer, tabs to the next
appropriate tab stop. For example, 8t moves
to the next 8-space tab stop.
r 0 Prints a space.
n 0 Prints a newline.
"..." 0 Prints the enclosed string.
^ Decreases . (dot) by the current increment.
Nothing prints.
+ Increases . (dot) by 1. Nothing prints.
- Decreases . (dot) decrements by 1. Nothing
prints.
newline Repeats the previous command incre-
mented with a count of 1.
[?/]lvalue mask Words starting at . (dot) are masked
with mask and compared with value
until a match is found. If L is used
then the match is for 4 bytes at a
time instead of 2. If no match is
found then . (dot) is unchanged; oth-
erwise . (dot) is set to the matched
location. If mask is omitted then -1
is used.
[?/]wvalue... Writes the 2-byte value into the
addressed location. If the command is
W, write 4 bytes. If the command is
V, write 1 byte. Alignment
restrictions may apply when using w or
W.
[?/]m b1 e1 f1[?/] Records new values for b1, e1, f1. If
less than three expressions are given
then the remaining map parameters are
left unchanged. If the ? or / is fol-
lowed by * then the second segment
(b2, e2, f2) of the mapping is
changed. If the list is terminated by
? or / then the file (objfil or corfil
respectively) is used for subsequent
requests. (For example, /m? causes /
to refer to objfil).
>name Assigns . (dot) to the variable or
register name.
! Calls a shell to read the rest of the
line following !.
$modifier Miscellaneous commands. The available
modifiers are:
<file Reads commands from file and
returns to the standard
input.
>file Sends output to file. If
file is omitted, output
returns to the standard
output. file is created if
it does not exist.
r Prints the general registers
and the instruction
addressed by pc and sets .
(dot) to pc.
b Prints all breakpoints and
their associated counts and
commands.
c C stack backtrace. If
address is given then it is
taken as the address of the
current frame (instead of
using the frame pointer reg-
ister). If C is used, then
the names and values of all
automatic and static vari-
ables are printed for each
active function. If count
is given then only the first
count frames are printed.
e Prints the names and values
of external variables.
w Sets the output page width
for address. The default is
80.
s Sets the limit for symbol
matches to address. The
default is 255.
o Sets the current radix to 8.
d Sets the current radix to
address or 16, if none is
specified.
q Exits adb.
v Prints all non-zero vari-
ables in octal.
m Prints the address map.
p Uses the remainder of the
line as a prompt string.
:modifier Manages a subprocess. Available modi-
fiers are:
bc Sets the breakpoint at
address. The breakpoint
runs count -1 times before
causing a stop. Each time
the breakpoint is encount-
ered, the command c runs.
If this command sets . (dot)
to 0, the breakpoint causes
a stop.
d Deletes the breakpoint at
address.
r Runs objfil as a subprocess.
If address is given explic-
itly, the program is entered
at this point; otherwise,
the program is entered at
its standard entry point.
count 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. On entry
to the subprocess, all
signals are turned on.
cs Continues the subprocess
with signal s (see the
signal system call in AIX
Operating System Technical
Reference). If address is
given,the subprocess is con-
tinued at this address. If
no signal is specified, the
signal that caused the sub-
process to stop is sent.
Breakpoint skipping is the
same as for r.
ss Continues the subprocess in
single steps count times.
If there is no current sub-
process, objfil is run as a
subprocess. In this case no
signal can be sent; the
remainder of the line is
treated as arguments to the
subprocess.
k Stops the current sub-
process, if one is running.
Variables
adb provides a number of variables. On entry to adb, the
following variables are set from the system header in the
corfil. If corfil does not appear to be a core file,
then these values are set from objfil.
b The base address of the data segment
d The size of the data segment
e The entry address of the program
m The "magic" number (0405, 0407, 0410, or 0411)
s The size of the stack segment
t The size of the text segment.
Addresses
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 (b1, e1, f1)
and (b2, e2, f2). The file address that corresponds to a
written address is calculated as follows:
b1<address<e1=>file address=address+f1-b1
or
b2<address<e2=>file address=address+f2-b2
Otherwise, the requested address is not legal. In some
cases (for example, programs with separated I and D
space) the two segments for a file may overlap. If a ?
or / is followed by an *, then only the second triple is
used.
The initial setting of both mappings is suitable for
normal a.out and core files. If either file is not of
the kind expected, then for that file b1 is set to 0, e1
is set to the maximum file size, and f1 is set to 0; in
this way, the whole file can be examined with no address
translation.
In order for adb to be used on large files, all appro-
priate values are kept as signed 32-bit integers.
FLAGS
-pprompt Sets the prompt used by adb to prompt. If the
prompt includes spaces, enclose the prompt in
quotation marks.
-w Opens the objfil and corfil for writing. This
flag makes either file if they do not exist.
FILES
/dev/mem
/dev/swap
a.out
core
RELATED INFORMATION
The ptrace system call in AIX Operating System Technical
Reference.
The a.out and core files in IBM RT PC AIX Operating
System Technical Reference.