The following sections describe how you can customize the adb debug program.
You can give more than one command on a line by separating the commands with a ; (semicolon). The commands are performed one at a time, starting at the left. Changes to the current address and format carry over to the next command. If an error occurs, the remaining commands are ignored. For example, the following sequence displays both the adb variables and then the active subroutines at one point in the adbsamp2 program:
$v;$c variables b = 10000000 d = ec e = 10000038 m = 108 t = 2f8. f(0,0) .main+26. main(0,0,0) start+fa
You can direct the adb debug program to read commands from a text file instead of from the keyboard by redirecting the standard input file when you start the adb program. To redirect standard input, use the input redirection symbol, < (less than), and supply a file name. For example, use the following command to read commands from the file script:
adb sample <script
The file must contain valid adb subcommands. Use the adb program script files when the same set of commands can be used for several different object files. Scripts can display the contents of core files after a program error. The following example shows a file containing commands that display information about a program error. When that file is used as input to the adb program using the following command to debug the adbsamp2 file, the specified output is produced.
120$w 4095$s. f:b: r =1n"======= adb Variables =======" $v =1n"======= Address Map =======" $m =1n"======= C Stack Backtrace =======" $C =1n"======= C External Variables =======" $e =1n"======= Registers =======" $r 0$s =1n"======= Data Segment ======="< b,10/8xna
$ adb adbsamp2 <script
adbsamp2: running breakpoint .f: b .f+24 ======= adb Variables ======= variables 0 = TBD 1 = TBD 2 = TBD 9 = TBD b = 10000000 d = ec e = 10000038 m = 108 t = 2f8 ======= Address Map ======= [0]? map .adbsamp2. b1 = 10000000 e1 = 100002f8 f1 = 0 b2 = 200002f8 e2 = 200003e4 f2 = 2f8 [0]/ map .-. b1 = 0 e1 = 0 f1 = 0 b2 = 0 e2 = 0 f2 = 0 ======= C Stack Backtrace =======. f(0,0) .main+26. main(0,0,0) start+fa ======= C External Variables =======Full word. errno: 0. environ: 3fffe6bc. NLinit: 10000238. main: 100001ea. exit: 1000028c. fcnt: 0
.loop .count: 1. f: 100001b4. NLgetfile: 10000280. write: 100002e0. NLinit. .X: 10000238 . NLgetfile. .X: 10000280 . cleanup: 100002bc. exit: 100002c8 . exit . .X: 1000028c . . cleanup . .X: 100002bc
======= Registers ======= mq 20003a24 .errno+3634 cs 100000 gt ics 1000004 pc 100001b4 .f r15 10000210 .main+26 r14 20000388 .main r13 200003ec .loop .count r12 3fffe3d0 r11 3fffe44c r10 0 r9 20004bcc r8 200041d8 .errno+3de8 r7 0 r6 200030bc .errno+2ccc r5 1 r4 200003ec .loop .count r3 f4240 r2 1 r1 3fffe678 r0 20000380 .f. f: b .f+24
======= Data Segment ======= 10000000: 103 5313 3800 0 0 2f8 0 ec 10000010: 0 10 1000 38 0 0 0 1f0 10000020: 0 0 0 0 1000 0 2000 2f8 10000030: 0 0 0 0 4 6000 0 6000 10000040: 6e10 61d0 9430 a67 6730 6820 c82e 8 10000050: 8df0 94 cd0e 60 6520 a424 a432 c84e 10000060: 8 8df0 77 cd0e 64 6270 8df0 86 10000070: cd0e 60 6520 a424 a432 6470 8df0 6a 10000080: cd0e 64 c82e 19 8df0 78 cd0e 60 10000090: 6520 a424 a432 c84e 19 8df0 5b cd0e 100000a0: 64 cd2e 5c 7022 d408 64 911 c82e 100000b0: 2e 8df0 63 cd0e 60 6520 a424 a432 100000c0: c84e 2e 8df0 46 cd0e 64 15 6280 100000d0: 8df0 60 cd0e 68 c82e 3f 8df0 4e 100000e0: cd0e 60 6520 a424 a432 c84e 3f 8df0 100000f0: 31 cd0e 64 c820 14 8df0 2b cd0e 10000100:
Use the $w subcommand to set the maximum width (in characters) of each line of output created by the adb program. The command has the form:
Width$w
In this format, the Width parameter is an integer that specifies the width in characters of the display. You can give any width convenient for your display device. When the adb program is first invoked, the default width is 80 characters.
This command can be used when redirecting output to a line printer or special output device. For example, the following command sets the display width to 120 characters, a common maximum width for line printers:
120$w
The adb debug program normally displays memory and file addresses as the sum of a symbol and an offset. This format helps to associate the instructions and data on the display with a particular function or variable. When the adb program starts up, it sets the maximum offset to 255, so that symbolic addresses are assigned only to instructions or data that occur less than 256 bytes from the start of the function or variable. Instructions or data beyond that point are given numeric addresses.
In many programs, the size of a function or variable is actually larger than 255 bytes. For this reason the adb program lets you change the maximum offset to accommodate larger programs. You can change the maximum offset by using the $s subcommand.
Offset$s
In this format, the Offset parameter is an integer that specifies the new offset. For example, the following command increases the maximum possible offset to 4095:
4095$s
All instructions and data that are less than 4096 bytes away are given symbolic addresses. You can disable all symbolic addressing by setting the maximum offset to zero. All addresses are given numeric values instead.
To alter the default format for numbers used in commands, use the $d or $o (octal) subcommands. The default format tells the adb debug program how to interpret numbers that do not begin with 0 (octal) or 0x (hexadecimal), and how to display numbers when no specific format is given. Use these commands to work with a combination of decimal, octal, and hexadecimal numbers.
The $o subcommand sets the radix to 8 and thus sets the default format for numbers used in commands to octal. After you enter that subcommand, the adb program displays all numbers in octal format except those specified in some other format.
The format for the $d subcommand is the Radix$d command, where the Radix parameter is the new value of the radix. If the Radix parameter is not specified, the $d subcommand sets the radix to a default value of 16. When you first start the adb program, the default format is hexadecimal. If you change the default format, you can restore it as necessary by entering the $d subcommand by itself:
$d
To set the default format to decimal, use the following command:
0xa$d
Use the $i and $n subcommands to force the adb debug program to disassemble instructions using the specified instruction set and mnemonics. The $i subcommand specifies the instruction set to be used for disassembly. The $n subcommand specifies the mnemonics to be used in disassembly.
If no value is entered, these commands display the current settings.
The $i subcommand accepts the following values:
The $n subcommand accepts the following values:
pwr | Specifies the mnemonics for the POWER implementation of the POWER architecture. |
ppc | Specifies the mnemonics for the PowerPC architecture. |
Computing Numbers and Displaying Text.
Displaying and Manipulating the Source File with the adb Program.
adb Debug Program Subcommands.
The adb command.