Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ adb(1) — SunOS 5.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ptrace(2)

a.out(4)

core(4)

adb(1)

NAME

adb − general-purpose debugger

SYNOPSIS

adb [ −w ] [ −k ] [ −I dir ] [ objectfile [ corefile ] ]

DESCRIPTION

adb is an interactive, general-purpose debugger.  It can be used to examine files and provides a controlled environment for the execution of programs. 

objectfile is normally an executable program file, preferably containing a symbol table. If the file does not contain a symbol table, it can still be examined, but the symbolic features of adb cannot be used.  The default for objectfile is a.out.  corefile is assumed to be a core image file produced after executing objectfile. The default for corefile is core. 

OPTIONS

−w Create both objectfile and corefile, if necessary, and open them for reading and writing so that they can be modified using adb. 

−k Perform kernel memory mapping; use when corefile is a system crash dump or /dev/mem. 

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

USAGE

adb reads commands from the standard input and displays responses on the standard output.  It does not supply a prompt.  It ignores the QUIT signal.  INTERRUPT invokes the next adb command.  adb generally recognizes command input of the form:

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

address and count (if supplied) are expressions that result, respectively, in a new current address, and a repetition count.  command is composed of a verb followed by a modifier or list of modifiers. 

The symbol ‘.’ represents the current location.  It is initially zero.  The default count is ‘1’. 

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.  (In older versions of adb, ‘"’ was used.) 

integer A number.  The prefixes 0o and 0O indicate octal; 0t and 0T, decimal; 0x and 0X, hexadecimal (the default). 

int.frac A floating-point number. 

’cccc’ ASCII value of up to 4 characters. 

<name The value of name, which is either a variable name or a register name.

symbol A symbol in the symbol table. 

(exp) The value of exp.

Unary Operators

∗exp The contents of location exp in corefile.

%exp The contents of location exp in objectfile (In older versions of adb, ‘@’ was used). 

−exp Integer negation. 

~exp Bitwise complement. 

#exp Logical negation. 

Binary Operators

Binary operators are left associative and have lower precedence than unary operators. 

+ Integer addition. 

− Integer subtraction. 

∗ Integer multiplication. 

% Integer division. 

& Bitwise conjunction (“AND”). 

| Bitwise disjunction (“OR”). 

# lhs rounded up to the next multiple of rhs.

Variables

Named variables are set initially by adb but are not used subsequently. 

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 corefile or objectfile as appropriate. 

b The base address of the data segment. 

d The data segment size. 

e The entry point. 

m The ‘magic’ number

t The text segment size. 

Commands

Commands to adb consist of a verb followed by a modifier or list of modifiers. 

Verbs

?  Print locations starting at address in objectfile.

/ Print locations starting at address in corefile.

= Print the value of address itself. 

: Manage a subprocess. 

$r Print names and contents of CPU registers. 

$x Print the names and contents of floating point registers 0 through 15. 

$X Print the names and contents of floating point registers 16 through 31. 

> Assign a value to a variable or register. 

RETURN Repeat the previous command with a count of 1.  Increment ‘.’. 

!  Shell escape. 

?, /, and = Modifiers

The following format modifiers apply to the commands ?, /, and =.  To specify a format, follow the command with an optional repeat count, and the desired format letter or letters:

{ ?,/,= } [ [ r ] f ... ]

where r is a repeat count, and f is one of the format letters listed below:

o (‘.’ increment:  2) Print 2 bytes in octal. 

O (4) Print 4 bytes in octal. 

q (2) Print in signed octal. 

Q (4) Print long signed octal. 

d (2) Print in decimal. 

D (4) Print long decimal. 

x (2) Print 2 bytes in hexadecimal. 

X (4) Print 4 bytes in hexadecimal. 

u (2) Print as an unsigned decimal number. 

U (4) Print long unsigned decimal. 

f (4) Print a single-precision floating-point number. 

F (8) Print a double-precision floating-point number. 

b (1) Print the addressed byte in octal. 

c (1) Print the addressed character. 

C (1) Print the addressed character using ^ escape convention. 

s (n) Print the addressed string.

S (n) Print a string using the ^ escape convention. 

Y (4) Print 4 bytes in date format. 

i (4) Print as machine instructions.

a (0) Print the value of ‘.’ in symbolic form. 

p (4) Print the addressed value in symbolic form. 

t (0) Tab to the next appropriate TAB stop. 

r (0) Print a SPACE. 

n (0) Print a NEWLINE. 

... (0) Print the enclosed string. 

^ (0) Decrement ‘.’. 

+ (0) Increment ‘.’. 

− (0) Decrement ‘.’ by 1. 

? and / Modifiers

l value mask Apply mask and compare for value; move ‘.’ to matching location. 

L value mask Apply mask and compare for 4-byte value; move ‘.’ to matching location. 

w value Write the 2-byte value to address. 

W value Write the 4-byte value to address. 

m b1 e1 f1[ ?] Map new values for b1, e1, f1. If the ?  or / is followed by ∗ then the second segment (b2,e2,f2) of the address mapping is changed. 

: Modifiers

b commands Set breakpoint, execute commands when reached. 

r Run objectfile as a subprocess. 

d Delete breakpoint at address . 

cs The subprocess is continued with signal s.

ss Single-step the subprocess with signal s.

i Add the signal specified by address to the list of signals passed directly to the subprocess. 

t Remove the signal specified by address from the list implicitly passed to the subprocess. 

k Terminate (kill) the current subprocess, if any. 

A Attach adb to an existing process id.  (For example, 0t1234:A would attach adb to decimal process number 1234.) 

R Release the previously attached process. 

$ Modifiers

<filename Read commands from the file filename.

<<filename Similar to <, but can be used in a file of commands without closing the file. 

>filename Append output to filename, which is created if it does not exist.

?  Print process ID, the signal which stopped the subprocess, and the registers. 

r Print the names and contents of the general CPU registers, and the instruction addressed by pc. 

x Print the names and contents of the floating-point registers 0 through 15. 

X Print the names and contents of floating-point registers 16 through 31. 

b Print all breakpoints and their associated counts and commands. 

c C stack backtrace.  On Sun-4 systems, it is impossible for adb to determine how many parameters were passed to a function.  The default that adb chooses in a $c command is to show the six parameter registers.  This can be overridden by appending a hexadecimal number to the $c command, specifying how many parameters to display.  For example, the $cf command will print 15 parameters for each function in the stack trace. 

d Set the default radix to address and report the new value.  Note: address is interpreted in the (old) current radix.  Thus ‘10$d’ never changes the default radix. 

e Print the names and values of external variables. 

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. 

f Print a list of known source filenames. 

p (Kernel debugging) Change the current kernel memory mapping to map the designated user structure to the address given by u ; this is the address of the user’s proc structure. 

i Show which signals are passed to the subprocess with the minimum of adb interference. 

W Reopen objectfile and corefile for writing, as though the −w command-line argument had been given. 

FILES

/usr/lib/adb

a.out

core

SEE ALSO

ptrace(2), a.out(4), core(4)

DIAGNOSTICS

adb, when there is no current command or format, comments about inaccessible files, syntax errors, abnormal termination of commands, etc.  Exit status is 0, unless last command failed or returned nonzero status. 

NOTES

adb should be changed to use the new format symbolic information generated by −g. 

BUGS

There does not seem to be any way to clear all breakpoints. 

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

Since there is little type-checking on addresses, using a sourcefile address in an inappropriate context may lead to unexpected results. 

The $cparameter-count command is a workaround. 

Sun Microsystems  —  Last change: 27 Aug 1990

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