DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

adb(CP)


adb -- invokes a general-purpose debugger.

Syntax

adb [-w] [-p prompt ] [ objfil [ corefile ]

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

objfil is normally an executable file of either ELF or COFF format, preferably containing a symbol table; if not then the symbolic features of adb cannot be used although the file can still be examined. The default filename for objfil is a.out. corefile is assumed to be a core image file produced after executing objfil; the default for corefile is core.

Requests to adb are read from standard input. If the -w option is specified, both objfil and corefile are created if necessary and opened for reading and writing. The QUIT and INTERRUPT keys cause adb to return to the next command. The -p option defines the prompt string, which may be any combination of characters. The default is an asterisk (*).

In general requests to adb are of the form:

   [address]  [, count] [command] [;]
If address is present then the current position in the file (called dot) is set to the value given by 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 is a special expression having the form:
   [segment:]offset
where segment gives the address of a specific text or data segment, and offset gives an offset from the beginning of that segment. If segment is not given, the last segment value given in a command is used.

The interpretation of an address depends on the context in which it is used. If a subprocess is being debugged then addresses are interpreted in the usual way in the address space of the subprocess. For further details of address mapping see ``Addresses''.

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
An octal number if integer begins with a 0; a hexadecimal number if preceded by # or 0x; otherwise a decimal number.

integer.integer
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 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 corefile. The 286 register names are ax bx cx dx di si bp fl ip cs ds ss es sp. The 386 register names are eax ebx ecx edx edi esi ebp esp. The name fl refers to the status flags.

symbol
A symbol is a sequence of upper or lower case letters, underscores or digits, not starting with a digit. ``´' may be used to escape other characters. The value of the symbol is taken from the symbol table in objfil. An initial \_ or ~ will be prepended to symbol if needed.

_symbol
In C, the ``true name'' of an external symbol begins with an underscore (_). It may be necessary to use this name to distinguish it from internal or hidden variables of a program.

(exp)
The value of the expression exp.

Monadic operators


*exp
The contents of the location addressed by exp.

-exp
Integer negation.

~exp
Bitwise complement.

Dyadic operators

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
Remainder after division of e1 by e2.

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 following verbs are available. (The commands ? and \/ may be followed by *; see ``Addresses'' for further details.)

?f
Locations starting at text address in objfil are printed according to the format f.

\/f
Locations starting at data address in corefile are printed according to the format f.

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

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 temporarily 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:

Letter Format
o 2 bytes in octal
O 4 bytes in octal
q 2 bytes in signed octal
Q 4 bytes in signed long octal
d 2 bytes in decimal
D 4 bytes in decimal
x 2 bytes in hexadecimal
X 4 bytes in hexadecimal
u 2 bytes as an unsigned integer
U 4 bytes as an unsigned integer
f 4 bytes in floating point
F 8 bytes in floating point

 
b 1 address byte in octal
c 1 byte as a character
C 1 byte as a character using the following escape convention. Character values 000 to 040 are printed as an at-sign (@) followed by the corresponding character in octal range 0100 to 0140. The at-sign character itself is printed as @@.

 
s Prints the addressed characters until a zero character is reached.
S Prints a string using the at-sign (@) escape convention When n is a length of the string including its zero terminator.

 
Y 4 bytes in date format. See ctime(S).
i Machine instructions. n is the number of bytes occupied by the instruction. This style of printing causes variable 1 and 2 to be set the the offset parts of the source and destination respectively.
a The current symbolic address. Symbols are checked to ensure that they have an appropriate type as follows:
/ local or global data symbols
? local or global text symbols
= local or global absolute symbols
A The current absolute address
p Prints the addressed value in symbolic form using the same rules for symbol lookup as a

 
t A horizontal TAB
r A blank space
n A Newline
'...' Prints the enclosed string
^ Decrements dot by the current increment. Nothing is printed
= Increments dot by 1. Nothing is printed
- Decrements dot by 1. Nothing is printed
+ Increments dot by 1. Nothing is printed

 +-------+------------------------------------------+
 |Letter | Format                                   |
 +-------+------------------------------------------+
 |o      | 2 bytes in octal                         |
 +-------+------------------------------------------+
 |O      | 4 bytes in octal                         |
 +-------+------------------------------------------+
 |q      | 2 bytes in signed octal                  |
 +-------+------------------------------------------+
 |Q      | 4 bytes in signed long octal             |
 +-------+------------------------------------------+
 |d      | 2 bytes in decimal                       |
 +-------+------------------------------------------+
 |D      | 4 bytes in decimal                       |
 +-------+------------------------------------------+
 |x      | 2 bytes in hexadecimal                   |
 +-------+------------------------------------------+
 |X      | 4 bytes in hexadecimal                   |
 +-------+------------------------------------------+
 |u      | 2 bytes as an unsigned integer           |
 +-------+------------------------------------------+
 |U      | 4 bytes as an unsigned integer           |
 +-------+------------------------------------------+
 |f      | 4 bytes in floating point                |
 +-------+------------------------------------------+
 |F      | 8 bytes in floating point                |
 +-------+------------------------------------------+
 |       |                                          |
 +-------+------------------------------------------+
 |b      | 1 address byte in octal                  |
 +-------+------------------------------------------+
 |c      | 1 byte as a character                    |
 +-------+------------------------------------------+
 |C      | 1 byte as a character using the          |
 |       | following escape convention.  Character  |
 |       | values 000 to 040 are printed as an at-  |
 |       | sign (@) followed by the corresponding   |
 |       | character in octal range 0100 to 0140.   |
 |       | The at-sign character itself is printed  |
 |       | as @@.                                   |
 +-------+------------------------------------------+
 |       |                                          |
 +-------+------------------------------------------+
 |s      | Prints the addressed characters until a  |
 |       | zero character is reached.               |
 +-------+------------------------------------------+
 |S      | Prints a string using the at-sign (@)    |
 |       | escape convention When n is a length of  |
 |       | the string including its zero            |
 |       | terminator.                              |
 +-------+------------------------------------------+
 |       |                                          |
 +-------+------------------------------------------+
 |Y      | 4 bytes in date format. See ctime(S).    |
 +-------+------------------------------------------+
 |i      | Machine instructions.  n is the number   |
 |       | of bytes occupied by the instruction.    |
 |       | This style of printing causes variable 1 |
 |       | and 2 to be set the the offset parts of  |
 |       | the source and destination respectively. |
 +-------+------------------------------------------+
 |a      | The current symbolic address. Symbols    |
 |       | are checked to ensure that they have an  |
 |       | appropriate type as follows:             |
 |       | /    local or global data symbols        |
 |       | ?    local or global text symbols        |
 |       | =    local or global absolute symbols    |
 +-------+------------------------------------------+
 |A      | The current absolute address             |
 +-------+------------------------------------------+
 |p      | Prints the addressed value in symbolic   |
 |       | form using the same rules for symbol     |
 |       | lookup as a                              |
 +-------+------------------------------------------+
 |       |                                          |
 +-------+------------------------------------------+
 |t      | A horizontal TAB                         |
 +-------+------------------------------------------+
 |r      | A blank space                            |
 +-------+------------------------------------------+
 |n      | A Newline                                |
 +-------+------------------------------------------+
 |'...'  | Prints the enclosed string               |
 +-------+------------------------------------------+
 |^      | Decrements dot by the current increment. |
 |       | Nothing is printed                       |
 +-------+------------------------------------------+
 |=      | Increments dot by 1. Nothing is printed  |
 +-------+------------------------------------------+
 |-      | Decrements dot by 1. Nothing is printed  |
 +-------+------------------------------------------+
 |+      | Increments dot by 1. Nothing is printed  |
 +-------+------------------------------------------+

newline
If the previous command temporarily incremented dot, makes the increment permanent. 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 then dot is unchanged; otherwise dot is set to the matched location. If mask is omitted then -1 is used.

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

[?/]m segnum fpos size
Sets new values for the given segment's file position and size. If size is not given, then only the file position is changed. The segnum must the segment number of a segment already in the memory map (see ``Addresses''). If ? is given, a text segment is affected; if / a data segment.

[?/]M segnum fpos size
Creates a new segment in the memory map. The segment is given file position fpos and physical size size. The segnum must not already exist in the memory map. If ? is given, a text segment is created; if / a data segment.

<name
dot is assigned to the variable or register named.

!
A shell is called to read the rest of the line following !.

$modifier
Miscellaneous commands. The available modifiers are:

\<f
Read commands from the file f and return.

\>f
Send output to the file f, which is created if it does not exist.

r
Print the general registers and the instruction addressed by ip. Dot is set to ip.

f
Print the floating registers in single or double length.

b
Print 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 bp). If count is given then only the first count frames are printed. This command is case insensitive.

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
Sets input and output default format to octal.

d
Sets input and output default format to decimal.

x
Sets input and output default format to hexadecimal.

q
Exit from adb.

v
Print all non zero variables in octal.

m
Print the address map.

:modifier
Manage a subprocess. Available modifiers are:

br
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 sets dot to zero then the breakpoint causes a stop.

dl
Delete breakpoint at address.

r[arguments]
Run 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. All signals are turned on on entry to the subprocess.

R[arguments]
Same as the r command except that arguments are passed through a shell before being passed to to the program. This means shell metacharacters can be used in filenames.

co
The subprocess is continued and signal s is passed to it, see signal(S). 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.

s
As for co 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.

k
The current subprocess, if any, is terminated.

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.

On entry the following are set from the system header in the corefile. If corefile 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 execution type.

n
The number of segments.

s
The stack segment size.

t
The text segment size.

Addresses

Addresses in adb refer to either a location in a file or in actual memory. When there is no current process in memory, adb addresses are computed as file locations, and requested text and data are read from the objfil and corefile files. When there is a process, such as after a :r command, addresses are computed as actual memory locations.

All text and data segments in a program have associated memory map entries. Each entry has a unique segment number. In addition, each entry has the file position of that segment's first byte, and the physical size of the segment in the file. When a process is running, a segment's entry has a virtual size which defines the size of the segment in memory at the current time. This size can change during execution.

When a address is given and no process is running, the file location corresponding to the address is calculated as:

   effective-file-address = file-position  + offset
If a process is running, the memory location is simply the offset in the given segment. These addresses are valid if and only if
   0 <= offset <= size
where size is physical size for file locations and virtual size for memory locations. Otherwise, the requested address is not legal.

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, file position is set to 0, and size is set to the maximum file size. In this way, the whole file can be examined with no address translation.

So that adb may be used on large files, all appropriate values are kept as signed 32 bit integers.

Files


a.out

core

Diagnostics

The message ``adb'' appears 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

A breakpoint set at the entry point is not effective on initial entry to the program.

System calls cannot be single stepped.

Local variables whose names are the same as an external variable may foul up the accessing of the external.

ELF or COFF format files are accepted and read transparently.

See also

ptrace(S), a.out(FP), core(FP)
© 2003 Commands for Programming (CP)
SCO OpenServer Release 5.0.7 -- 11 February 2003