Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ adb(1) — AOS 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

dbx(1)

ptrace(2)

a.out(5)

core(5)

ADB(1)  —  

NAME

adb − debugger

SYNOPSIS

adb [−w]  [−k] [-Idir]  [ objfil [ corfil ] ]

DESCRIPTION

Adb is a general-purpose debugging program.  It may be used to examine files and to provide a controlled environment for the execution of programs. 

Objfil is normally an executable program file, preferably containing a symbol table; if not, the symbolic features of adb cannot be used, although the file can still be examined.  The default for objfil is a.out.  Corfil is assumed to be a core image file produced after executing objfil; the default for corfil is core. 

Requests to adb are read from the standard input and responses are to the standard output.  If the −w flag is present, both objfil and corfil are created, if needed, and opened for reading and writing so that files can be modified using adb.

The −k option makes adb do kernel memory mapping; it should be used when corefil is a crash dump or /dev/mem.

The −I option specifies a directory where files to be read with $< or $<< are sought; the default is /usr/lib/adb.

Adb ignores QUIT; INTERRUPT causes adb to stop processing the current command and await a new command. 

In general, requests to adb are of the form:

[address]  [, count] [command] [;]

If address is present, dot is set to address. Initially, dot is set to 0.  For most commands, count specifies how many times the command executes.  The default count is 1.  Address and count are expressions.  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.  If the operating system is being debugged -- either post-mortem or using the special file /dev/mem to examine or modify memory interactively -- the maps are set to map the kernel virtual addresses which start at 0xe0000000 on the IBM RT PC. 

EXPRESSIONS

.  The value of dot.

+ The value of dot incremented by the current increment. 

^ The value of dot decremented by the current increment. 

" The last address typed. 

integer 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, the default radix 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 leading digit is alphabetic must have a 0x (or 0X) prefix or a leading zero, even if the default radix is hexadecimal. 

integer.fraction
A 32-bit floating point number.

´cccc´ The ASCII value of up to 4 characters.  \ may be used to escape a ´. 
 

< name The value of name, which is either a variable name or a register name. Adb maintains several variables (see “Variables”) 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. Register names are those printed by the $r command.

symbol A symbol is a sequence of upper or lower-case letters, underscores and digits, not starting with a digit.  The backslash character (“\”) may be used to escape other characters.  The value of the symbol is taken from the symbol table in objfil. If symbol is not defined, adb searches for _.symbol, the internal name of the entry point of the C function symbol. If _.symbol is not defined, adb searches for _symbol, the internal name of the C variable symbol or the data area of the C function symbol.

routine.name
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 started C stack frame corresponding to routine (see “Bugs”). 

(exp) The value of the expression exp.

Monadic operators

∗exp The contents of the location addressed by exp in corfil.

@exp The contents of the location addressed by exp in objfil.

−exp Integer negation. 

~exp Bitwise complement. 

#exp Logical negation. 

Dyadic operators are left-associative and are less binding than monadic operators. 

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.

COMMANDS

Most commands consist of a verb followed by a modifier or list of modifiers.  (The commands “?” and “/” may be followed by “∗”; see “Addresses” for further details.)  The following verbs are available:

?f Locations starting at address in objfil are printed according to the format f. Dot is incremented by the sum of the increments for each format letter (q.v.). 

/f Locations starting at address in corfil are printed according to the format f and dot is incremented as for “?”. 

=f The value of address itself is printed in the styles shown by the format f. (For i, format “?” is printed for the parts of the instruction that refer to subsequent words.) 

A format consists of one or more characters specifying 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, dot is incremented 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:

o2 Print 2 bytes in octal.  All octal numbers output by adb are preceded by 0. 

O4 Print 4 bytes in octal. 

q2 Print in signed octal. 

Q4 Print long signed octal. 

d2 Print in decimal. 

D4 Print long decimal. 

x2 Print 2 bytes in hexadecimal. 

X4 Print 4 bytes in hexadecimal. 

u2 Print as an unsigned decimal number. 

U4 Print long unsigned decimal. 

f4 Print the 32-bit value as a floating-point number. 

F8 Print double floating point. 

b1 Print the addressed byte in octal. 

c1 Print the addressed character. 

C1 Print the addressed character using the standard escape convention where control characters are printed as ^X and the delete character is printed as ^?. 

sn Print the addressed characters until a zero character is reached. 

Sn Print a string using the ^X escape convention (n is the length of the string including its zero terminator).  See C above. 

Y4 Print 4 bytes in date format (see ctime(3)).

in Print as machine instructions (n 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, respectively. 

a0 Print the value of dot in symbolic form.  Symbols are checked to ensure that they have the types shown below. 

/Local or global data symbol
?Local or global text symbol
=Local or global absolute symbol

p4 Print the addressed value in symbolic form using the same rules for symbol lookup as a. 

t0 Tabs to the next appropriate tab stop when preceded by an integer.  For example, 8t moves to the next eight-space tab stop. 

r0 Print a space. 

n0 Print a newline. 

"..." 0
Print the enclosed string.

^ Dot is decremented by the current increment.  Nothing is printed. 

+ Dot is incremented by 1.  Nothing is printed. 

− Dot is decremented by 1.  Nothing is printed. 

newline
Repeat the previous command with a count of 1. 

[?/]l value 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, dot is unchanged; otherwise, dot is set to the matched location.  If mask is omitted, −1 is used. 

[?/]w value ...
Write the 2-byte value into the addressed location.  If the command is W, write 4 bytes.  Odd addresses are not allowed when writing to the subprocess address space. 
 
 

[?/]m b1 e1 f1[?/]
New values for (b1, e1, f1) are recorded.  If fewer than three expressions are given, the remaining map parameters are left unchanged. If the “?” or “/” is followed by “∗”, the second segment (b2,e2,f2) of the mapping is changed.  If the list is terminated by “?” or “/”, the file (objfil or corfil, respectively) is used for later requests.  (Thus, for example, “/m?” will cause “/” to refer to objfil.)

>name
Dot is assigned to the variable or register named. 

!  A shell (/bin/sh) is called to read the rest of the line following “!”. 

$modifier
Miscellaneous commands.  The available modifiers are:

<f Read commands from the file f. If this command is executed in a file, further commands in the file are not seen. If f is omitted, the current input stream is terminated.  If a count is given, and is zero, the command will be ignored.  The value of the count will be placed in variable 9 before the first command in f is executed. 

<<f Similar to < except it can be used in a file of commands without causing the file to be closed.  Variable 9 is saved during the execution of this command, and restored when it completes.  There is a (small) finite limit to the number of << files that can be open at once. 

>f Append output to the file f which is created if it does not exist.  If f is omitted, output is returned to the terminal. 

?  Print process id, the signal that caused stoppage or termination, as well as the registers as $r.  This is the default if modifier is omitted. 

r Print the general registers and the instruction addressed by pc.  Dot is set to pc.  n$r prints register n only.  n, c$r prints registers n+ c −1, ..., n.

f Print the floating point registers in hexadecimal and decimal.  Register pairs are also formatted as doubles. 

b Print all breakpoints and their associated counts and commands. 

c Backtrace the call stack, starting either at address (if address is given), or at the most recently activated frame (if address is not given).  If count is given, only the first count frames are printed. 

C Like c; additionally print the auto area or the last 64 words of it, if it is large.  The last word printed corresponds to the first auto allocated by the C compiler. 

d Set the default radix to address and report the new value.  Note that address 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 The names and values of external variables are printed. 

w Set the page width for output to address (default 80). 

s Set the limit for symbol matches to address (default 255). 

o All integers input are regarded as octal. 

q Exit from adb.

v Print all non-zero variables in octal. 

m Print the address map. 

p (Kernel debugging) Change the current kernel memory mapping to map the designated user structure to the address given by the symbol _u.  The address argument is the address of the user’s user page table entries. 

:modifier
Manage a subprocess.  Available modifiers are:

bc Set breakpoint at address. The breakpoint is executed count−1 times before causing a stop. Each time the breakpoint is encountered the command c is executed.  If this command is omitted or sets dot to zero, the breakpoint causes a stop. 

d Delete breakpoint at address.

r Run objfil as a subprocess.  If address is given explicitly, 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. 

cs The subprocess is continued with signal s (see sigvec(2)). If address is given, the subprocess is continued at this address.  If no signal is specified, the signal that caused the subprocess to stop is sent.  Breakpoint skipping is the same as for r. 

ss As for c, except that the subprocess is single-stepped count times.  If there is no current subprocess, objfil is run as a subprocess as for r.  Here no signal can be sent; the remainder of the line is treated as arguments to the subprocess. 

k The current subprocess, if any, is terminated. 

VARIABLES

Adb provides several variables.  Named variables are set initially by adb 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 corfil. If corfil does not appear to be a core file, these values are set from objfil.

b The base address of the data segment. 

d The data segment size. 

e The entry point. 

m The “magic number” (0407, 0410 or 0413) (see a.out(5)).

s The stack segment size. 

t The text segment size. 

ADDRESSES

The address in a file associated with a written address is determined by a mapping associated with that file.  Two triples, (b1, e1, f1) and (b2, e2, f2), represent each mapping, and the file address corresponding to a written address is calculated as follows. 

b1≤address<e1 => file address=address+f1−b1, otherwise,

b2≤address<e2 => file address=address+f2−b2,

otherwise, the requested address is not legal.  Sometimes (e.g. for 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. 

FILES

a.out
core

SEE ALSO

cc(1), dbx(1), ptrace(2), a.out(5), core(5)
“Using ADB to Debug the Kernel”, by S. Leffler and W. Joy, in the UNIX System Manager’s Manual
“IBM/4.3 Linkage Convention” in Volume II, Supplementary Documents

DIAGNOSTICS

“Adb” is printed when there is no current command or format.  Adb complains about inaccessible files, syntax errors, abnormal termination of commands, etc.  Exit status is 0, unless the last command failed or returned nonzero status. 

BUGS

Since no shell is invoked to interpret the arguments of the :r command, the customary wild-card and variable expansions cannot occur. 

The $c and $C commands print incorrect values for arguments of class register.  Backtracing may fail entirely or print erroneous values if execution of the most recently called function has not proceeded past prolog code (e.g. when a breakpoint stops execution on an entry point).  Single step a few times, and reissue the $c or $C. 

Postmortem stack backtraces on a corfil require an objfil also. 

The $C command lists the values of automatic variables, but does not display their names; the symbol table does not currently contain the names of automatic variables.  The absence of automatic-variable names in the symbol table also means that expressions of the form “routine.name” are not supported. 

The adb scripts in /usr/lib/adb for kernel debugging probably do not work. 

Setting of variables 1 and 2 is not implemented for i format. 

NOTE

Because of the asynchronous nature of loads and stores on a machine with an Advanced Processor Card, the CPU may have executed one or more instructions beyond the one that causes a program check.  This means that the iar will be pointing to the instruction that would have been executed had the program check not occurred, and not the instruction that caused the program check.  The $r (or $) command will display the actual exception packets, if any, in pseudo-instruction form.  This may aid in locating the actual source of the error.  See the IBM RT PC Hardware Technical Reference, Volume I, SV21-8024, for more information on exception packets. 
 

PRPQs 5799-WZQ/5799-PFF: IBM/4.3  —  July 1987

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026