Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

ADB(1)  —  Unix Programmer’s Manual

NAME

adb − debugger

SYNOPSIS

adb [ options ] [ 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 UNIX programs. 

Objfil is normally an executable program file, which should contain a symbol table. If it does not, then 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 sent to the standard output.  Adb ignores QUIT;  INTERRUPT causes return to the next adb command. 

In general, requests to adb are of the form

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

If address is present then dot is set to address. Initially dot is set to 0.  For most commands count specifies how many times the command will be executed.  The default count is 1.  Address and count are expressions (see below). 

OPTIONS

−I Specifies a directory in which files to be read with $< or $<< (see below) will be sought; the default is /usr/lib/adb. 

−k Forces adb to perform UNIX kernel memory mapping.  This option should be used when core is a UNIX crash dump or /dev/mem.  Note:  this option is not yet implemented. 

−w Creates and opens both objfil and corfil, if necessary, so that files can be read, written, and modified.

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. 

´cccc´ The ASCII value of up to 4 characters.  Backslash ( \ ) may be used to escape the ´ character. 

(exp) The value of the expression exp.

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 = 16. 

−n Causes msgs to start n messages back from the one indicated by the user’s .msgsrc file.  Useful for review of recent messages. 

−p Pipes long messages through more(1). 

−q Notifies the user of new messages.  The command msgs −q is often used in login scripts. 
 

Within msgs the user can go to any specific message by typing its number when msgs requests input. 

FILES

/usr/msgs/∗database
~/.msgsrcnumber of nexfault 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 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). 

integer.fraction
A 32-bit floating point number.

< name The value of name, which is either a variable name or a register name. Adb maintains a number of variables (see VARIABLES) named by single letters or digits.  If name is a register name, then the value of the register is obtained from the system header in corfil. The register names are those printed by the $r command. 

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 activated C stack frame corresponding to routine.

symbol A sequence of upper- or lower-case letters, underscores or digits, which does not start 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. An initial _ will be prepended to symbol if needed. 

_ symbol
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.

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

These 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.

Verbs

The following verbs are available.  (The commands ?  and / may be followed by ∗ .  See ADDRESSES for further details.) 
 

?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. 

/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 indicated by the format f. (For i format ?  is printed for the parts of the instruction that reference subsequent words.) 

newline
Repeats 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 then dot is unchanged; otherwise dot is set to the matched location.  If mask is omitted then -1 is used. 

[?/]m b1 e1 f1[?/]
New values for (b1, e1, f1) are recorded.  If fewer than three expressions are given then the remaining map parameters are left unchanged. If the ?  or / is followed 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.  (Thus /m?  will cause / to refer to objfil.)

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

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

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

Formats

A format 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, dot is incremented 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. 

a0 Prints the value of dot in symbolic form.  Symbols are checked to ensure that they have an appropriate type as indicated below:

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

b1 Prints the addressed byte in octal. 

c1 Prints the addressed character. 

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

d2 Prints in decimal. 

D4 Prints long decimal. 

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

F8 Prints double floating point. 

in Prints 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. 

n0 Prints a newline. 

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

O4 Prints 4 bytes in octal. 

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

q2 Prints in signed octal. 

Q4 Prints long signed octal. 

r0 Prints a space. 

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

Sn Prints a string using the ^X escape convention (see C above).  N is the length of the string including its zero terminator. 

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

u2 Prints as an unsigned decimal number. 

U4 Prints long unsigned decimal. 

x2 Prints 2 bytes in hexadecimal. 

X4 Prints 4 bytes in hexadecimal. 

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

“...” 0 Prints 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. 

Modifiers

$modifier
Miscellaneous commands.  The available modifiers are as follows:

<f Reads 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 of zero is given, 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 that 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 Appends output to the file f, which is created if it does not exist.  If f is omitted, output is returned to the terminal. 

?  Prints process ID, the signal which caused stoppage or termination, as well as the registers as $r.  This is the default if modifier is omitted. 
 
 
 
 
 
 
 
 

b Prints all breakpoints and their associated counts and commands. 
 
 
 
 

c C stack backtrace.  If address is given, it is taken as the address of the current frame instead of the contents of the frame−pointer register.  If C is used then the names and (32-bit) values of all automatic and static variables are printed for each active function.  If count is given then only the first count frames are printed. 
 
 
 
 

d Sets the default radix to address and reports the new value.  Note that address is interpreted in the (old) current radix.  Thus, for example, 10$d never changes the default radix.  To make decimal the default radix, use 0t10$d. 

e Prints the names and values of external variables. 

m Prints the address map. 

o Causes all integers input to be regarded as octal. 

p (Kernel debugging.)  Changes 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. 

q Exits from adb. 

r Prints the general registers and the instruction addressed by pc.  Dot is set to pc. 

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

v Prints all non-zero variables in octal. 

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

:modifier
Manages a subprocess.  Available modifiers are as follows:

bc Sets breakpoint at address. The breakpoint is executed count−1 times before causing a stop. Each time the breakpoint is encountered the command c

NAME

mail − send and receive mail

SYNOPSIS

mail [ −v ] [ −i ] [ −n ] [ −s subject ] [ users ]
mail [ −v ] [ −i ] [ −n ] −f [ name ]
mail [ −v ] [ −i ] [ −n ] −u user

DESCRIPTION

Mail is an intelligent mail processing system which has a command syntax reminiscent of ed, with lines replaced by messages. 
 

Sending Mail: To send a message to one or more people, the s omitted or sets dot to zero, then the breakpoint causes a stop. 

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

d Deletes breakpoint at address.

k Terminates the current subprocess, if any. 

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

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

VARIABLES

Adb provides a number of 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 values 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 data segment size. 

e The entry point. 

m The “magic” number (0407, 0410 or 0413). 

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.  Each mapping is represented by two triples (b1, e1, f1) and (b2, e2, f2). 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.  In some cases (e.g., programs with separated I and D space) the two segments for a

4th Berkeley Distribution  —  1 August 1985

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