adb(1) adb(1)NAME adb - debugger SYNOPSIS adb [-k] [-w] [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 A/UX programs. objfil is normally an executable program file, 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 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 option is present, then both objfil and corfil are created (if necessary) and opened for reading and writing so that files can be modified using adb. adb ignores quit signals; an in- terrupt causes return to the next adb command. To exit adb: use $q or $Q or CONTROL-d. Normally, for portability, adb does a system call to gather information regarding core file relocation addresses. If using adb on a standalone program (such as the kernel, /unix), using the -k flag option skips that part of the adb code. In general, requests to adb are of the form [address] [,count] [command] [;] If address is present, then ``dot'' is set to address. Ini- tially, 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. 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. If the operating system is being debugged either post-mortem or using the special file /dev/kmem to examine interactively and/or modify memory, the maps are set to map the kernel virtual addresses. For further details of address mapping, see ADDRESSES. April, 1990 1
adb(1) adb(1)EXPRESSIONS . The value of dot. + The value of dot, incremented by the current in- crement. ^ The value of dot, decremented by the current in- crement. " The last address typed. integer A number. The prefix 0 (zero) forces interpreta- tion in octal radix; the prefixes 0d and 0D force interpretation in decimal radix; the prefixes 0x and 0X force interpretation in hexadecimal radix. Thus 020 = 0d16 = 0x10 = sixteen. If no prefix appears, then the default radix is used; see the $d command. The default radix is initially hexa- decimal. The hexadecimal digits are 0123456789abcdefABCDEF, with the obvious values. Note that a hexadecimal number the most signifi- cant digit of which would otherwise be an alpha- betic character must have a 0x (or 0X) prefix (or a leading zero, if the default radix is hexade- cimal). 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 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. symbol A symbol is a sequence of upper or lowercase letters, underscores or digits, not starting with a digit. \ may be used to escape other charac- ters. The value of the symbol is taken from the symbol table in objfil. An initial _ or ~ will be prefixed to symbol, if needed. _ symbol In C, the ``true name'' of an external symbol be- gins with _ . It may be necessary to utter this name to distinguish it from internal or hidden variables of a program. 2 April, 1990
adb(1) adb(1)(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 following verbs are available. (The commands ``?'' and ``/'' may be followed by ``*''; see AD- DRESSES for further details.) ?f Locations starting at address in objfil are printed according to the format f. Dot is in- cremented 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 indicated by the format f. (For i for- mat, ``?'' is printed for the parts of the in- struction that reference subsequent words.) April, 1990 3
adb(1) adb(1)A format consists of one or more characters that specify a style of printing. Each format character may be pre- ceded 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. i n Disassemble the addressed instruction. o 2 Print 2 bytes in hex. All octal numbers out- put by adb are preceded by 0. 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 the 32-bit value as a floating point number. F 8 Print double floating point. b 1 Print the addressed byte in octal. c 1 Print the addressed character. C 1 Print the addressed character using the stan- dard escape convention where control charac- ters are printed as ^X and the delete charac- ter is printed as ^?. s n Print the addressed characters until a zero character is reached. S n Print a string using the ^X escape convention (see C above). The n is the length of the string including its zero terminator. Y 4 Print 4 bytes in date format (see ctime(3)). a 0 Print the value of dot in symbolic form. Symbols are checked to ensure that they have an appropriate type as indicated below. / global data symbol ? global text symbol = global absolute symbol p 4 Print the addressed value in symbolic form using the same rules for symbol lookup as a. t 0 When preceded by an integer tabs to the next ap- propriate tab stop. For example, 8t moves to the next 8-space tab stop. r 0 Print a space. n 0 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. 4 April, 1990
adb(1) adb(1)- 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, then dot is unchanged; otherwise, dot is set to the matched location. If mask is omitted, then -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 less than three expressions are given, then the remaining map parameters are left unchanged. If more than 3 expres- sions are given, the values of (b2,e2,f2) (b3,e3,f3) and so on, are changed. If the ``?'' or ``/'' is followed by ``*'', then the first segment (b1,e1,f1) of the mapping is skipped, and the second and subsequent segments are changed instead. (There are as many (bn,en,fn) triples as you have sections in your program.) If the list is terminated by ``?'' or ``/'', then the file (objfil or corfil, respectively) is used for subsequent requests. (So that, for example, ``/m?'' will cause ``/'' to refer to objfil.) > name Dot is assigned to the variable or register named. This command is often used in the form constant > name. This form of the command can be used to enter 96-bit ``IEEE Extended Precision'' numbers into the floating-point data registers fp0-fp7. For example: 0x3FFF00008000000000000000 > fp0 puts the value 1.0 into fp0. When this form of the com- mand is used, only the first 32 vits of the constant are stored in dot. See MC68881 Floating Point Coprocessor User's Manual (available from Motorola Literature Distri- bution Center, part number MC68881UM/AD), section 2.4, ``Extended Real,'' p. 211, for a description of IEEE Ex- tended Precision format. ! A shell is called to read the rest of the line following ``!''. April, 1990 5
adb(1) adb(1)$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 com- mand in f is executed. <<f Similar to < except it can be used in a file of com- mands without causing the file to be closed. Vari- able 9 is saved during the execution of this com- mand, 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 which 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 ad- dressed by pc. Dot is set to pc. f Print the floating point data registers fp0-fp7 in IEEE Extended Precision (see >name, above, for de- finition), and exponential notation, along with the floating-point control registers fpcr, fpsr, and fpiar. 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 a7). If C is used, then the names and (16 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 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 Regard all integers subsequently input as octal. d Reset integer input as described in EXPRESSIONS. q Exit from adb. v Print all nonzero variables in hexadecimal. 6 April, 1990
adb(1) adb(1)m Print the address map. :modifier Manage a subprocess. Available modifiers are: bc Set breakpoint at address. The breakpoint is exe- cuted 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 then the breakpoint causes a stop. d Delete breakpoint at address. r Run objfil as a subprocess. If address is given ex- plicitly 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. cs The subprocess is continued with signal scs (see signal(3)). If address is given, then the subpro- cess is continued at this address. If no signal is specified, then the signal that caused the subpro- cess 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 subpro- cess 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. 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, 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 , 0413). April, 1990 7
adb(1) adb(1)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 n triples (b1, e1, f1), (b2, e2, f2), ... (bn, en, fn), corresponding to the number of sec- tions in your object file, and the file address correspond- ing 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, and so on, otherwise, the requested 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 ? or / is fol- lowed by an *, then the first triple is not used. The initial setting of both mappings is suitable for normal a.out and core files. If either file is not of the kind ex- pected, 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. So that adb may be used on large files, all appropriate values are kept as signed 32-bit integers. EXAMPLES adb obj1 will invoke adb with the executable object obj1. When adb responds with either a.out file ready or a.out (COFF format) a.out a.out ready the request: main,10?ia will cause 16 (10 hex) instructions to be printed in assem- bly code, starting from location main. 8 April, 1990
adb(1) adb(1)FILES /bin/adb a.out core SEE ALSO sdb(1), a.out(4), core(4). DIAGNOSTICS Echoes adb when there is no current command or format. Pro- duces comments about inaccessible files, syntax errors, ab- normal termination of commands, etc. Exit status is 0, un- less last command failed or returned nonzero status. BUGS Use of # for the unary logical negation operator is pecu- liar. There doesn't seem to be any way to clear all breakpoints. In certain cases, disassembled code cannot be used directly as input to as. This is because adb gives more useful in- formation than as accepts. For example, explicit register names are given in the disassembly of movm and fmovm in- structions. April, 1990 9