1ADB(1)                      General Commands Manual                     ADB(1)
2
3
4

NAME

6       adb - debugger
7

SYNOPSIS

9       adb [-w] [ objfil [ corfil ] ]
10

DESCRIPTION

12       Adb  is a general purpose debugging program.  It may be used to examine
13       files and to provide a controlled environment for the execution of UNIX
14       programs.
15
16       Objfil  is normally an executable program file, preferably containing a
17       symbol table; if not then the symbolic features of adb cannot  be  used
18       although  the  file  can  still be examined.  The default for objfil is
19       a.out.  Corfil is assumed to be a core image file produced  after  exe‐
20       cuting objfil; the default for corfil is core.
21
22       Requests  to  adb are read from the standard input and responses are to
23       the standard output.  If the -w flag is present then  both  objfil  and
24       corfil  are  created if necessary and opened for reading and writing so
25       that files can be modified using  adb.   Adb  ignores  QUIT;  INTERRUPT
26       causes return to the next adb command.
27
28       In general requests to adb are of the form
29
30                [address]  [, count] [command] [;]
31
32       If address is present then dot is set to address.  Initially dot is set
33       to 0.  For most commands count specifies how  many  times  the  command
34       will  be  executed.   The  default  count  is 1.  Address and count are
35       expressions.
36
37       The interpretation of an address depends on the context it is used  in.
38       If a subprocess is being debugged then addresses are interpreted in the
39       usual way in the address space of the subprocess.  For further  details
40       of address mapping see ADDRESSES.
41

EXPRESSIONS

43       .      The value of dot.
44
45       +      The value of dot incremented by the current increment.
46
47       ^      The value of dot decremented by the current increment.
48
49       "      The last address typed.
50
51       integer
52              An octal number if integer begins with a 0; a hexadecimal number
53              if preceded by #; otherwise a decimal number.
54
55       integer.fraction
56              A 32 bit floating point number.
57
58       ´cccc´ The ASCII value of up to 4 characters.  \ may be used to  escape
59              a ´.
60
61       < name The value of name, which is either a variable name or a register
62              name.  Adb maintains a number of variables (see VARIABLES) named
63              by  single  letters  or digits.  If name is a register name then
64              the value of the register is obtained from the system header  in
65              corfil.  The register names are r0 ... r5 sp pc ps.
66
67       symbol A  symbol  is  a sequence of upper or lower case letters, under‐
68              scores or digits, not starting with a digit.  \f[R] may be  used
69              to  escape  other  characters.  The value of the symbol is taken
70              from the symbol table in objfil.  An initial  _  or  ~  will  be
71              prepended to symbol if needed.
72
73       _ symbol
74              In  C,  the `true name' of an external symbol begins with _.  It
75              may be necessary to utter this name to disinguish it from inter‐
76              nal or hidden variables of a program.
77
78       routine.name
79              The  address  of  the  variable name in the specified C routine.
80              Both routine and name are symbols.  If name is omitted the value
81              is the address of the most recently activated C stack frame cor‐
82              responding to routine.
83
84       (exp)  The value of the expression exp.
85
86       Monadic operators
87
88       *exp   The contents of the location addressed by exp in corfil.
89
90       @exp   The contents of the location addressed by exp in objfil.
91
92       -exp   Integer negation.
93
94       ~exp   Bitwise complement.
95
96       Dyadic operators are left associative and are less binding than monadic
97       operators.
98
99       e1+e2  Integer addition.
100
101       e1-e2  Integer subtraction.
102
103       e1*e2  Integer multiplication.
104
105       e1%e2  Integer division.
106
107       e1&e2  Bitwise conjunction.
108
109       e1e2  Bitwise disjunction.
110
111       e1#e2  E1 rounded up to the next multiple of e2.
112

COMMANDS

114       Most commands consist of a verb followed by a modifier or list of modi‐
115       fiers.  The following verbs are available.  (The commands `?'  and  `/'
116       may be followed by `*'; see ADDRESSES for further details.)
117
118       ?f   Locations  starting  at address in objfil are printed according to
119            the format f.
120
121       /f   Locations starting at address in corfil are printed  according  to
122            the format f.
123
124       =f   The  value of address itself is printed in the styles indicated by
125            the format f.  (For i format `?' is printed for the parts  of  the
126            instruction that reference subsequent words.)
127
128       A  format  consists  of  one or more characters that specify a style of
129       printing.  Each format character may be preceded by a  decimal  integer
130       that  is  a  repeat  count  for  the  format character.  While stepping
131       through a format dot is incremented temporarily by the amount given for
132       each  format  letter.   If  no  format is given then the last format is
133       used.  The format letters available are as follows.
134
135              o 2    Print 2 bytes in octal.  All octal numbers output by  adb
136                     are preceded by 0.
137              O 4    Print 4 bytes in octal.
138              q 2    Print in signed octal.
139              Q 4    Print long signed octal.
140              d 2    Print in decimal.
141              D 4    Print long decimal.
142              x 2    Print 2 bytes in hexadecimal.
143              X 4    Print 4 bytes in hexadecimal.
144              u 2    Print as an unsigned decimal number.
145              U 4    Print long unsigned decimal.
146              f 4    Print the 32 bit value as a floating point number.
147              F 8    Print double floating point.
148              b 1    Print the addressed byte in octal.
149              c 1    Print the addressed character.
150              C 1    Print  the addressed character using the following escape
151                     convention.  Character values 000 to 040 are printed as @
152                     followed by the corresponding character in the range 0100
153                     to 0140.  The character @ is printed as @@.
154              s n    Print the addressed characters until a zero character  is
155                     reached.
156              S n    Print  a  string using the @ escape convention.  n is the
157                     length of the string including its zero terminator.
158              Y 4    Print 4 bytes in date format (see ctime(3)).
159              i n    Print as PDP11 instructions.  n is the  number  of  bytes
160                     occupied  by  the  instruction.   This  style of printing
161                     causes variables 1 and 2 to be set to the offset parts of
162                     the source and destination respectively.
163              a 0    Print  the  value  of  dot in symbolic form.  Symbols are
164                     checked to ensure that they have an appropriate  type  as
165                     indicated below.
166
167                /  local or global data symbol
168                ?  local or global text symbol
169                =  local or global absolute symbol
170
171              p 2    Print the addressed value in symbolic form using the same
172                     rules for symbol lookup as a.
173              t 0    When preceded by an integer tabs to the next  appropriate
174                     tab  stop.  For example, 8t moves to the next 8-space tab
175                     stop.
176              r 0    Print a space.
177              n 0    Print a newline.
178              "..." 0
179                     Print the enclosed string.
180              ^      Dot is decremented by the current increment.  Nothing  is
181                     printed.
182              +      Dot is incremented by 1.  Nothing is printed.
183              -      Dot is decremented by 1.  Nothing is printed.
184
185       newline
186              If  the  previous  command temporarily incremented dot, make the
187              increment permanent.  Repeat the previous command with  a  count
188              of 1.
189
190       [?/]l value mask
191              Words  starting  at  dot  are masked with mask and compared with
192              value until a match is found.  If L is used then  the  match  is
193              for  4  bytes at a time instead of 2.  If no match is found then
194              dot is unchanged; otherwise dot is set to the matched  location.
195              If mask is omitted then -1 is used.
196
197       [?/]w value ...
198              Write the 2-byte value into the addressed location.  If the com‐
199              mand is W, write 4 bytes.  Odd addresses are  not  allowed  when
200              writing to the subprocess address space.
201
202       [?/]m b1 e1 f1[?/]
203              New  values  for  (b1, e1, f1) are recorded.  If less than three
204              expressions are given then the remaining map parameters are left
205              unchanged.  If the `?' or `/' is followed by `*' then the second
206              segment (b2,e2,f2) of the mapping is changed.  If  the  list  is
207              terminated by `?' or `/' then the file (objfil or corfil respec‐
208              tively) is used for subsequent requests.  (So that, for example,
209              `/m?' will cause `/' to refer to objfil.)
210
211       >name  Dot is assigned to the variable or register named.
212
213       !      A shell is called to read the rest of the line following `!'.
214
215       $modifier
216              Miscellaneous commands.  The available modifiers are:
217
218              <f     Read commands from the file f and return.
219              >f     Send  output  to  the file f, which is created if it does
220                     not exist.
221              r      Print the general registers and the instruction addressed
222                     by pc.  Dot is set to pc.
223              f      Print  the floating registers in single or double length.
224                     If the floating point status of ps is set to double (0200
225                     bit) then double length is used anyway.
226              b      Print  all  breakpoints  and  their associated counts and
227                     commands.
228              a      ALGOL 68 stack backtrace.  If address is given then it is
229                     taken  to be the address of the current frame (instead of
230                     r4).  If count is given then only the first count  frames
231                     are printed.
232              c      C  stack backtrace.  If address is given then it is taken
233                     as the address of the current frame (instead of r5).   If
234                     C is used then the names and (16 bit) values of all auto‐
235                     matic and static variables are printed  for  each  active
236                     function.   If  count  is given then only the first count
237                     frames are printed.
238              e      The names and values of external variables are printed.
239              w      Set the page width for output to address (default 80).
240              s      Set the limit for  symbol  matches  to  address  (default
241                     255).
242              o      All integers input are regarded as octal.
243              d      Reset integer input as described in EXPRESSIONS.
244              q      Exit from adb.
245              v      Print all non zero variables in octal.
246              m      Print the address map.
247
248       :modifier
249              Manage a subprocess.  Available modifiers are:
250
251              bc     Set  breakpoint  at  address.  The breakpoint is executed
252                     count-1 times before  causing  a  stop.   Each  time  the
253                     breakpoint  is encountered the command c is executed.  If
254                     this command sets dot to zero then the breakpoint  causes
255                     a stop.
256
257              d      Delete breakpoint at address.
258
259              r      Run  objfil as a subprocess.  If address is given explic‐
260                     itly then the program is entered at this point; otherwise
261                     the  program  is  entered  at  its  standard entry point.
262                     count specifies how many breakpoints are  to  be  ignored
263                     before stopping.  Arguments to the subprocess may be sup‐
264                     plied on the same  line  as  the  command.   An  argument
265                     starting  with < or > causes the standard input or output
266                     to be established  for  the  command.   All  signals  are
267                     turned on on entry to the subprocess.
268
269              cs     The  subprocess  is continued with signal s c s, see sig‐
270                     nal(2).  If address is given then the subprocess is  con‐
271                     tinued  at  this address.  If no signal is specified then
272                     the signal that caused the subprocess to  stop  is  sent.
273                     Breakpoint skipping is the same as for r.
274
275              ss     As  for  c  except  that the subprocess is single stepped
276                     count times.  If there is no current subprocess then obj‐
277                     fil  is  run  as  a subprocess as for r.  In this case no
278                     signal can be sent; the remainder of the line is  treated
279                     as arguments to the subprocess.
280
281              k      The current subprocess, if any, is terminated.
282

VARIABLES

284       Adb  provides a number of variables.  Named variables are set initially
285       by adb but are not used subsequently.  Numbered variables are  reserved
286       for communication as follows.
287
288       0      The last value printed.
289       1      The last offset part of an instruction source.
290       2      The previous value of variable 1.
291
292       On  entry  the  following are set from the system header in the corfil.
293       If corfil does not appear to be a core file then these values  are  set
294       from objfil.
295
296       b      The base address of the data segment.
297       d      The data segment size.
298       e      The entry point.
299       m      The `magic' number (0405, 0407, 0410 or 0411).
300       s      The stack segment size.
301       t      The text segment size.
302

ADDRESSES

304       The  address  in a file associated with a written address is determined
305       by a mapping associated with that file.  Each mapping is represented by
306       two  triples  (b1, e1, f1) and (b2, e2, f2) and the file address corre‐
307       sponding to a written address is calculated as follows.
308
309        b1address<e1 => file address=address+f1-b1, otherwise,
310
311        b2address<e2 => file address=address+f2-b2,
312
313       otherwise, the requested address is not legal.  In some cases (e.g. for
314       programs  with separated I and D space) the two segments for a file may
315       overlap.  If a ?  or / is followed by an * then only the second  triple
316       is used.
317
318       The  initial  setting of both mappings is suitable for normal a.out and
319       core files.  If either file is not of the kind expected then, for  that
320       file,  b1 is set to 0, e1 is set to the maximum file size and f1 is set
321       to 0; in this way the whole file can be examined with no address trans‐
322       lation.
323
324       So  that adb may be used on large files all appropriate values are kept
325       as signed 32 bit integers.
326

FILES

328       /dev/mem
329       /dev/swap
330       a.out
331       core
332

SEE ALSO

334       ptrace(2), a.out(5), core(5)
335

DIAGNOSTICS

337       `Adb' when there is no current command or format.  Comments about inac‐
338       cessible  files,  syntax errors, abnormal termination of commands, etc.
339       Exit status is 0, unless last command failed or returned  nonzero  sta‐
340       tus.
341

BUGS

343       A  breakpoint  set at the entry point is not effective on initial entry
344       to the program.
345       When single stepping, system calls do not count as an executed instruc‐
346       tion.
347       Local  variables  whose  names are the same as an external variable may
348       foul up the accessing of the external.
349
350
351
352                                                                        ADB(1)
Impressum