.ds TW \v'.25m'\s+2~\s-2\v'-.25m' .ds ST \v'.25m'*\v'-.25m' .ds IM \v'.1m'=\v'-.1m'\s-2\h'-.1m'>\h'.1m'\s+2 .ds LE \(<= .ds LT \s-2<\s+2 .ds GT \s-2>\s+2 .TH ADB 1 .UC .SH NAME adb \- debugger .SH SYNTAX .B adb [\fB\-w\fP] [\fB\-k\fP] [ objfil [ corfil ] ] .SH DESCRIPTION .I 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. .PP .I Objfil is normally an executable program file, preferably containing a symbol table; if not then the symbolic features of .I adb cannot be used although the file can still be examined. The default for .I objfil is .B a.out. .I corfil is assumed to be a core image file produced after executing .IR objfil ; the default for .I corfil is .B core. If the .B \-k option is given, the .I corfil is assumed to be a kernel core dump, and the maps are set accordingly. .PP Requests to .I adb are read from the standard input and responses are to the standard output. If the .B \-w flag is present then both .I objfil and .I corfil are created, if necessary, and opened for reading and writing so that files can be modified using .IR adb . .I Adb ignores QUIT; INTERRUPT causes return to the next .I adb command. .PP In general requests to .I adb are of the form: .PP .if n .ti 16 .if t .ti 1.6i [\|\fIaddress\fP\|] [\|, .IR count \|] [\|\fIcommand\fP\|] [\|;\|] .PP If .I address is present then .I dot is set to .IR address . Initially .I dot is set to 0. For most commands .I count specifies how many times the command will be executed. The default .I count is 1. .I Address and .I count are expressions. .PP The interpretation of an address depends on the context it is used in. 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 .SM ADDRESSES. .SH EXPRESSIONS .TP 7.2n .B . The value of .IR dot . .TP 7.2n + The value of .I dot incremented by the current increment. .TP 7.2n ^ The value of .I dot decremented by the current increment. .TP 7.2n " The last .I address typed. .TP 7.2n .I integer An octal number if .I integer begins with a 0; a hexadecimal number if preceded by .BR # ; otherwise a decimal number. .TP 7.2n .IB integer . fraction A 32 bit floating point number. .TP 7.2n .I \'cccc\|\' The ASCII value of up to 4 characters. \\ may be used to escape a \'. .TP 7.2n .I \*(LT name The value of .IR name , which is either a variable name or a register name. .I adb maintains a number of variables (see .SM VARIABLES\*S) named by single letters or digits. If .I name is a register name then the value of the register is obtained from the system header in .IR corfil . The register names are .BR "r0 ... r5 sp pc ps" "." .TP 7.2n .I symbol A .I symbol is a sequence of upper or lower case letters, underscores or digits, not starting with a digit. .BR \\ " may be used to escape other characters." The value of the .I symbol is taken from the symbol table in .IR objfil . An initial \_ or \*(TW will be prepended to .I symbol if needed. If the symbol is a text symbol and .I objfil is an overlay type, the default is .IR \*(TWsymbol , which is the subroutine itself, not the entry interface in the base segment. .TP .I \_ 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. For a subroutine in an overlay, .I \*(TWsymbol is the actual subroutine, and .I \_symbol is the entry point in the base segment (the "thunk"). Note that to explicitly specify the local name, the \*(TW must be preceeded by a backslash, since \*(TW is the bitwise complement operator: .I \e\*(TWsymbol must be typed. .TP 7.2n .IB routine . name The address of the variable .I name in the specified C routine. Both .I routine and .I name are .IR symbols . If .I name is omitted the value is the address of the most recently activated C stack frame corresponding to .IR routine . .TP 7.2n .RI ( exp \|) The value of the expression .IR exp . .LP .SM .B "Monadic\ operators" .TP 7.2n .RI \*(ST exp The contents of the location addressed by .I exp in .IR corfil . .TP 7.2n .RI @ exp The contents of the location addressed by .I exp in .IR objfil . .TP 7.2n .RI \- exp Integer negation. .TP 7.2n .RI \*(TW exp Bitwise complement. .LP .B "Dyadic\ operators" are left associative and are less binding than monadic operators. .TP 7.2n .IR e1 + e2 Integer addition. .TP 7.2n .IR e1 \- e2 Integer subtraction. .TP 7.2n .IR e1 \*(ST e2 Integer multiplication. .TP 7.2n .IR e1 % e2 Integer division. .TP 7.2n .IR e1 & e2 Bitwise conjunction. .TP 7.2n .IR e1 \(bv e2 Bitwise disjunction. .TP 7.2n .IR e1 # e2 .I E1 rounded up to the next multiple of .IR e2 . .DT .SH 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 `\*(ST'; see .SM ADDRESSES for further details.) .TP .5i .RI ? f Locations starting at .I address in .I objfil are printed according to the format .IR f . .TP .RI / f Locations starting at .I address in .I corfil are printed according to the format .IR f . .TP .RI = f The value of .I address itself is printed in the styles indicated by the format .IR f . (For .B i format `?' is printed for the parts of the instruction that reference subsequent words.) .PP A .I 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 .I 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. .ta 2.5n .5i .RS .TP .BR o " 2" Print 2 bytes in octal. All octal numbers output by .I adb are preceded by 0. .br .ns .TP .BR O " 4" Print 4 bytes in octal. .br .ns .TP .BR q " 2" Print in signed octal. .br .ns .TP .BR Q " 4" Print long signed octal. .br .ns .TP .BR d " 2" Print in decimal. .br .ns .TP .BR D " 4" Print long decimal. .br .ns .TP .BR x " 2" Print 2 bytes in hexadecimal. .br .ns .TP .BR X " 4" Print 4 bytes in hexadecimal. .br .ns .TP .BR u " 2" Print as an unsigned decimal number. .br .ns .TP .BR U " 4" Print long unsigned decimal. .br .ns .TP .BR f " 4" Print the 32 bit value as a floating point number. .br .ns .TP .BR F " 8" Print double floating point. .br .ns .TP .BR b " 1" Print the addressed byte in octal. .br .ns .TP .BR c " 1" Print the addressed character. .br .ns .TP .BR C " 1" Print the addressed character using the following escape convention. Character values 000 to 040 are printed as @ followed by the corresponding character in the range 0100 to 0140. The character @ is printed as @@. .br .ns .TP .BI s " n" Print the addressed characters until a zero character is reached. .br .ns .TP .BI S " n" Print a string using the @ escape convention. .I n is the length of the string including its zero terminator. .br .ns .TP .BR Y " 4" Print 4 bytes in date format (see \fIctime\fP\|(3)). .br .ns .TP .BR i " n" Print as PDP-11 instructions. .I 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. .br .ns .TP .BR a " 0" Print the value of .I dot in symbolic form. Symbols are checked to ensure that they have an appropriate type as indicated below. .LP / local or global data symbol .br ? local or global text symbol .br = local or global absolute symbol .TP .BR p " 2" Print the addressed value in symbolic form using the same rules for symbol lookup as .BR a . .br .ns .TP .BR t " 0" When preceded by an integer tabs to the next appropriate tab stop. For example, .B 8t moves to the next 8-space tab stop. .br .ns .TP .BR r " 0" Print a space. .br .ns .TP .BR n " 0" Print a newline. .br .ns .tr '" .TP .BR '...' " 0" Print the enclosed string. .br .tr '' .br .ns .TP .B ^ .I Dot is decremented by the current increment. Nothing is printed. .br .ns .TP + .I Dot is incremented by 1. Nothing is printed. .br .ns .TP \- .I Dot is decremented by 1. Nothing is printed. .RE .TP newline If the previous command temporarily incremented .IR dot , make the increment permanent. Repeat the previous command with a .I count of 1. .TP .RB [ ?/ ] l "\fI value mask\fP" Words starting at .I dot are masked with .I mask and compared with .I value until a match is found. If .B L is used then the match is for 4 bytes at a time instead of 2. If no match is found then .I dot is unchanged; otherwise .I dot is set to the matched location. If .I mask is omitted then \-1 is used. .TP .RB [ ?/ ] w "\fI value ...\fP" Write the 2-byte .I value into the addressed location. If the command is .BR W , write 4 bytes. Odd addresses are not allowed when writing to the subprocess address space. .TP [\fB?/\fP]\fBm\fI b1 e1 f1\fP[\fB?/\fP] .br New values for .RI ( b1,\ e1,\ f1 ) are recorded. If less than three expressions are given then the remaining map parameters are left unchanged. If the `?' or `/' is followed by `\*(ST' then the last segment (\fIb2\fP\|,\|\fIe2\fP\|,\|\fIf2\fP) of the mapping is changed. If the list is terminated by `?' or `/' then the file (\fIobjfil\fP or .I corfil respectively) is used for subsequent requests. (So that, for example, `/m?' will cause `/' to refer to .IR objfil .) .TP .BI \*(GT name .I Dot is assigned to the variable or register named. .TP .B ! A shell is called to read the rest of the line following `!'. .TP .RI $ modifier Miscellaneous commands. The available .I modifiers are: .RS .TP .BI < f Read commands from the file .I f and return. .br .ns .TP .BI > f Send output to the file .I f, which is created if it does not exist. .br .ns .TP .B r Print the general registers and the instruction addressed by .BR pc . .I Dot is set to \fBpc\fP. .br .ns .TP .B f Print the floating registers in single or double length. If the floating point status of .B ps is set to double (0200 bit) then double length is used anyway. .br .ns .TP .B b Print all breakpoints and their associated counts and commands. .br .ns .TP .B a ALGOL 68 stack backtrace. If .I address is given then it is taken to be the address of the current frame (instead of .BR r4 ). If .I count is given then only the first .I count frames are printed. .br .ns .TP .B c C stack backtrace. If .I address is given then it is taken as the address of the current frame (instead of .BR r5 ). If .B C is used then the names and (16 bit) values of all automatic and static variables are printed for each active function. If .I count is given then only the first .I count frames are printed. .br .ns .TP .B e The names and values of external variables are printed. .br .ns .TP .B w Set the page width for output to .I address (default 80). .br .ns .TP .B s Set the limit for symbol matches to .I address (default 255). .br .ns .TP .B o All integers input are regarded as octal. .br .ns .TP .B d Reset integer input as described in .SM EXPRESSIONS. .br .ns .TP .B q Exit from .IR adb . .br .ns .TP .B v Print all non zero variables in octal. .br .ns .TP .B m Print the address map. .RE .TP .BI : modifier Manage a subprocess. Available modifiers are: .RS .TP \fBb\fP\|\fIc\fP Set breakpoint at .IR address . If .I objfil is overlaid and .I address is in the overlay region, the breakpoint is set in the overlay of the symbol mentioned if .I address was given symbolically, otherwise it is set in the current overlay (that in variable c). The breakpoint is executed \fIcount\fP-1 times before causing a stop. Each time the breakpoint is encountered the command .I c is executed. If this command sets .I dot to zero then the breakpoint causes a stop. .TP .B d Delete breakpoint at .IR address . .TP .B r Run .I objfil as a subprocess. If .I address is given explicitly then the program is entered at this point; otherwise the program is entered at its standard entry point. .I 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. .TP \fBc\fP\|\fIs\fP The subprocess is continued with signal .IR s . See \fIsignal\fP\|(2). If .I 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 .BR r . .TP \fBs\fP\|\fIs\fP As for .B c except that the subprocess is single stepped .I count times. If there is no current subprocess then .I objfil is run as a subprocess as for .BR r . In this case no signal can be sent; the remainder of the line is treated as arguments to the subprocess. .TP .B k The current subprocess, if any, is terminated. .RE .SH VARIABLES .I Adb provides a number of variables. Named variables are set initially by .I adb but are not used subsequently (except for c). Numbered variables are reserved for communication as follows. .TP 0 The last value printed. .br .ns .TP 1 The last offset part of an instruction source. .br .ns .TP 2 The previous value of variable 1. .PP On entry the following are set from the system header in the .IR corfil . If .I corfil does not appear to be a .B core file then these values are set from .IR objfil . .TP b The base address of the data segment. .br .ns .TP c The current overlay. This is set from .IR corfil , and in turn sets the overlay map. This variable and the map may be changed by referring to other overlays symbolically (e.g. by examining text in subroutines in other overlays), using the $r command (which resets c from the core file), or explicitly (with the command >c). .br .ns .TP d The data segment size. .br .ns .TP e The entry point. .br .ns .TP m The `magic' number (0405, 0407, 0410, 0411, 0430 or 0431). The object is overlaid if m is 0430 or 0431. .br .ns .TP o The sum of the overlay segment sizes (if overlaid). .br .ns .TP s The stack segment size. .br .ns .TP t The text segment size. .SH 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 or three triples .RI ( "b1, e1, f1" ), .RI ( "bo, eo, fo" ) for overlaid object files, and .RI ( "b2, e2, f2" ) and the .I file address corresponding to a written .I address is calculated as follows. .PP .if t .ti 1.5i .if n .ti 8 .IR b1 \*(LE address < e1 \*(IM .IR "file address" = address + f1\-b1, otherwise, .PP if overlaid, .if t .ti 1.5i .if n .ti 8 .IR bo \*(LE address < eo \*(IM .IR "file address" = address + fo\-bo, otherwise, .PP .if t .ti 1.5i .if n .ti 8 .IR b2 \*(LE address < e2 \*(IM .IR "file address" = address + f2\-b2, .PP otherwise, the requested .I address is not legal. In some cases (e.g. for programs with separated I and D space) the two segments for a file may overlap. If a .B ? or .B / is followed by an .B \*(ST then only the last triple is used. .PP The initial setting of both mappings is suitable for normal .B a.out and .B core files. This means that the .B ? map corresponds with object text space, the .B ?* map corresponds to object data space, the .B / map corresponds to corfil data space, and the .B /* map corresponds to \fIcorfil\fP stack space. If the .B a.out file is overlaid, the overlay map is set up for the overlay found in the core file, and is changed whenever other overlays are examined. .PP If the object file is not of the kind expected then, for both files, .I b1 is set to 0, .I e1 is set to the maximum file size and .I f1 is set to 0; in this way the whole file can be examined with no address translation. .PP So that .I adb may be used on large files all appropriate values are kept as signed 32 bit integers. .SH FILES /dev/mem .br /dev/swap .br a.out .br core .SH SEE\ ALSO \fIADB - A Tutorial\fP, S. R. Bourne .br ptrace(2), a.out(5), core(5) .SH DIAGNOSTICS \fIadb\fP 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. .SH BUGS When single stepping, system calls do not count as an executed instruction. .br Local variables whose names are the same as an external variable may foul up the accessing of the external. .br Local variables cannot be accessed in routines that are in overlays.