|
|
1.1 root 1: .\" Copyright (c) 1980 Regents of the University of California.
2: .\" All rights reserved. The Berkeley software License Agreement
3: .\" specifies the terms and conditions for redistribution.
4: .\"
5: .\" @(#)adb.1 6.1 (Berkeley) 4/29/85
6: .\"
7: .TH ADB 1 "April 29, 1985"
8: .UC 4
9: .SH NAME
10: adb \- debugger
11: .SH SYNOPSIS
12: .B adb
13: [\fB\-w\fR] [ \fB\-k\fR ] [ \fB-I\fRdir ] [ objfil [ corfil ] ]
14: .ds TW \v'.25m'\s+2~\s-2\v'-.25m'
15: .ds ST *
16: .ds IM \v'.1m'=\v'-.1m'\s-2\h'-.1m'>\h'.1m'\s+2
17: .ds LE \(<=
18: .ds LT \s-2<\s+2
19: .ds GT \s-2>\s+2
20: .SH DESCRIPTION
21: .I Adb
22: is a general purpose debugging program.
23: It may be used to examine files and to provide
24: a controlled environment for the execution of UNIX programs.
25: .PP
26: .I Objfil
27: is normally an executable program file, preferably
28: containing a symbol table; if not then the symbolic features of
29: .I adb
30: cannot be used although the file can still be examined.
31: The default for
32: .I objfil
33: is
34: .B a.out.
35: .I Corfil
36: is assumed to be a core image file produced after executing
37: .IR objfil ;
38: the default for
39: .I corfil
40: is
41: .B core.
42: .PP
43: Requests to
44: .I adb
45: are read from the standard input and responses are to the standard output.
46: If the
47: .B \-w
48: flag is present then both
49: .I objfil
50: and
51: .I corfil
52: are created if necessary and opened for reading and writing
53: so that files can be modified using
54: .IR adb .
55: .PP
56: The \fB\-k\fP option makes \fIadb\fP do UNIX kernel memory
57: mapping; it should be used when \fIcore\fP is a UNIX crash dump
58: or \fI/dev/mem\fP.
59: .PP
60: The \fB\-I\fP option specifies a directory where files to be read
61: with $< or $<< (see below) will be sought; the default is
62: .IR /usr/lib/adb .
63: .PP
64: .I Adb
65: ignores QUIT; INTERRUPT causes return to the next
66: .I adb
67: command.
68: .PP
69: In general requests to
70: .I adb
71: are of the form
72: .PP
73: .if n .ti 16
74: .if t .ti 1.6i
75: [\|\fIaddress\fR\|] [\|,
76: .IR count \|]
77: [\|\fIcommand\fR\|] [\|;\|]
78: .PP
79: If
80: .I address
81: is present then
82: .I dot
83: is set to
84: .IR address .
85: Initially
86: .I dot
87: is set to 0. For most commands
88: .I count
89: specifies how many times the command will be executed. The default
90: .I count
91: is 1.
92: .I Address
93: and
94: .I count
95: are expressions.
96: .PP
97: The interpretation of an address depends on the context it is used in.
98: If a subprocess is being debugged then addresses are interpreted
99: in the usual way in the address space of the subprocess.
100: If the operating system is being debugged either post-mortem or using
101: the special file
102: .I /dev/mem
103: to interactive examine and/or modify memory the maps are set to map
104: the kernel virtual addresses which start at 0x80000000 (on the VAX).
105: .SM ADDRESSES.
106: .SH EXPRESSIONS
107: .TP 7.2n
108: .B .
109: The value of
110: .IR dot .
111: .TP 7.2n
112: +
113: The value of
114: .I dot
115: incremented by the current increment.
116: .TP 7.2n
117: ^
118: The value of
119: .I dot
120: decremented by the current increment.
121: .TP 7.2n
122: "
123: The last
124: .I address
125: typed.
126: .TP 7.2n
127: .I integer
128: A number. The prefixes 0o and 0O (\*(lqzero oh\*(rq) force interpretation
129: in octal radix; the prefixes 0t and 0T force interpretation in
130: decimal radix; the prefixes 0x and 0X force interpretation in
131: hexadecimal radix. Thus 0o20 = 0t16 = 0x10 = sixteen.
132: If no prefix appears, then the
133: .I default\ radix
134: is used; see the $d command. The default radix is initially hexadecimal.
135: The hexadecimal digits are 0123456789abcdefABCDEF with the obvious
136: values. Note that a hexadecimal number whose most significant
137: digit would otherwise be an alphabetic character must have a 0x
138: (or 0X) prefix (or a leading zero if the default radix is hexadecimal).
139: .TP 7.2n
140: .IB integer . fraction
141: A 32 bit floating point number.
142: .TP 7.2n
143: .I \'cccc\|\'
144: The ASCII value of up to 4 characters.
145: \e may be used to escape a \'.
146: .TP 7.2n
147: .I \*(LT name
148: The value of
149: .IR name ,
150: which is either a variable name or a register name.
151: .I Adb
152: maintains a number of variables (see
153: .SM VARIABLES\*S)
154: named by single letters or digits.
155: If
156: .I name
157: is a register name then the value of the register is obtained from
158: the system header in
159: .IR corfil .
160: The register names are those printed by the $r command.
161: .TP 7.2n
162: .I symbol
163: A
164: .I symbol
165: is a sequence of upper or lower case letters, underscores or
166: digits, not starting with a digit. The backslash character
167: .B \e
168: may be used to escape other characters. The value of the
169: .I symbol
170: is taken from the symbol table in
171: .IR objfil .
172: An initial \_ will be prepended to
173: .I symbol
174: if needed.
175: .TP
176: .I _ symbol
177: In C, the `true name' of an external symbol begins with _.
178: It may be necessary to utter this name to distinguish it
179: from internal or hidden variables of a program.
180: .TP 7.2n
181: .IB routine . name
182: The address of the variable
183: .I name
184: in the specified C routine. Both
185: .I routine
186: and
187: .I name
188: are
189: .IR symbols .
190: If
191: .I name
192: is omitted the value is the address of the most recently activated C stack frame
193: corresponding to
194: .IR routine .
195: (This form is currently broken on the VAX; local variables can be examined
196: only with
197: .IR dbx (1).)
198: .TP 7.2n
199: .RI ( exp \|)
200: The value of the expression
201: .IR exp .
202: .LP
203: .SM
204: .B "Monadic\ operators"
205: .TP 7.2n
206: .RI \*(ST exp
207: The contents of the location addressed by
208: .I exp
209: in
210: .IR corfil .
211: .TP 7.2n
212: .RI @ exp
213: The contents of the location addressed by
214: .I exp
215: in
216: .IR objfil .
217: .TP 7.2n
218: .RI \- exp
219: Integer negation.
220: .TP 7.2n
221: .RI \*(TW exp
222: Bitwise complement.
223: .TP 7.2n
224: .RI # exp
225: Logical negation.
226: .LP
227: .tr ''
228: .B "Dyadic\ operators"
229: are left associative and are less binding than monadic operators.
230: .TP 7.2n
231: .IR e1 + e2
232: Integer addition.
233: .TP 7.2n
234: .IR e1 \- e2
235: Integer subtraction.
236: .TP 7.2n
237: .IR e1 \*(ST e2
238: Integer multiplication.
239: .TP 7.2n
240: .IR e1 % e2
241: Integer division.
242: .TP 7.2n
243: .IR e1 & e2
244: Bitwise conjunction.
245: .TP 7.2n
246: .IR e1 \(bv e2
247: Bitwise disjunction.
248: .TP 7.2n
249: .IR e1 # e2
250: .I E1
251: rounded up to the next multiple of
252: .IR e2 .
253: .DT
254: .SH COMMANDS
255: Most commands consist of a verb followed by a modifier or list of modifiers.
256: The following verbs are available.
257: (The commands `?' and `/' may be followed by `\*(ST'; see
258: .SM ADDRESSES
259: for further details.)
260: .TP .5i
261: .RI ? f
262: Locations starting at
263: .I address
264: in
265: .I objfil
266: are printed according to the format
267: .IR f .
268: .I dot
269: is incremented by the sum of the increments for each format letter (q.v.).
270: .TP
271: .RI / f
272: Locations starting at
273: .I address
274: in
275: .I corfil
276: are printed according to the format
277: .I f
278: and
279: .I dot
280: is incremented as for `?'.
281: .TP
282: .RI = f
283: The value of
284: .I address
285: itself is printed in the styles indicated by the format
286: .IR f .
287: (For
288: .B i
289: format `?' is printed for the parts of the instruction that reference
290: subsequent words.)
291: .PP
292: A
293: .I format
294: consists of one or more characters that specify a style of printing.
295: Each format character may be preceded by a decimal integer
296: that is a repeat count for the format character.
297: While stepping through a format
298: .I dot
299: is incremented by the amount given for each format letter.
300: If no format is given then the last format is used.
301: The format letters available are as follows.
302: .ta 2.5n .5i
303: .RS
304: .TP
305: .BR o " 2"
306: Print 2 bytes in octal. All octal numbers output by
307: .I adb
308: are preceded by 0.
309: .br
310: .ns
311: .TP
312: .BR O " 4"
313: Print 4 bytes in octal.
314: .br
315: .ns
316: .TP
317: .BR q " 2"
318: Print in signed octal.
319: .br
320: .ns
321: .TP
322: .BR Q " 4"
323: Print long signed octal.
324: .br
325: .ns
326: .TP
327: .BR d " 2"
328: Print in decimal.
329: .br
330: .ns
331: .TP
332: .BR D " 4"
333: Print long decimal.
334: .br
335: .ns
336: .TP
337: .BR x " 2"
338: Print 2 bytes in hexadecimal.
339: .br
340: .ns
341: .TP
342: .BR X " 4"
343: Print 4 bytes in hexadecimal.
344: .br
345: .ns
346: .TP
347: .BR u " 2"
348: Print as an unsigned decimal number.
349: .br
350: .ns
351: .TP
352: .BR U " 4"
353: Print long unsigned decimal.
354: .br
355: .ns
356: .TP
357: .BR f " 4"
358: Print the 32 bit value as a floating point number.
359: .br
360: .ns
361: .TP
362: .BR F " 8"
363: Print double floating point.
364: .br
365: .ns
366: .TP
367: .BR b " 1"
368: Print the addressed byte in octal.
369: .br
370: .ns
371: .TP
372: .BR c " 1"
373: Print the addressed character.
374: .br
375: .ns
376: .TP
377: .BR C " 1"
378: Print the addressed character using
379: the standard escape convention where control characters
380: are printed as ^X and the delete character is printed as ^?.
381: .br
382: .ns
383: .TP
384: .BI s " n"
385: Print the addressed characters until a zero character is reached.
386: .br
387: .ns
388: .TP
389: .BI S " n"
390: Print a string using the ^\fIX\fR escape convention (see \fBC\fR above).
391: .I n
392: is the length of the string including its zero terminator.
393: .br
394: .ns
395: .TP
396: .BR Y " 4"
397: Print 4 bytes in date format (see
398: .IR ctime (3)).
399: .br
400: .ns
401: .TP
402: .BR i " n"
403: Print as machine instructions.
404: .I n
405: is the number of bytes occupied by the instruction.
406: This style of printing causes variables 1 and 2 to be set
407: to the offset parts of the source and destination respectively.
408: .br
409: .ns
410: .TP
411: .BR a " 0"
412: Print the value of
413: .I dot
414: in symbolic form.
415: Symbols are checked to ensure that they have an appropriate
416: type as indicated below.
417: .LP
418: / local or global data symbol
419: .br
420: ? local or global text symbol
421: .br
422: = local or global absolute symbol
423: .TP
424: .BR p " 4"
425: Print the addressed value in symbolic form using
426: the same rules for symbol lookup as
427: .BR a .
428: .br
429: .tr ''
430: .ns
431: .TP
432: .BR t " 0"
433: When preceded by an integer tabs to the next appropriate tab stop.
434: For example,
435: .B 8t
436: moves to the next 8-space tab stop.
437: .br
438: .ns
439: .TP
440: .BR r " 0"
441: Print a space.
442: .br
443: .ns
444: .TP
445: .BR n " 0"
446: Print a newline.
447: .br
448: .ns
449: .tr '"
450: .TP
451: .BR '...' " 0"
452: Print the enclosed string.
453: .br
454: .tr ''
455: .br
456: .ns
457: .TP
458: .B ^
459: .I Dot
460: is decremented by the current increment. Nothing is printed.
461: .br
462: .ns
463: .TP
464: +
465: .I Dot
466: is incremented by 1. Nothing is printed.
467: .br
468: .ns
469: .TP
470: \-
471: .I Dot
472: is decremented by 1. Nothing is printed.
473: .RE
474: .TP
475: newline
476: Repeat the previous command with a
477: .I count
478: of 1.
479: .TP
480: .RB [ ?/ ] l "\fI value mask\fR"
481: Words starting at
482: .I dot
483: are masked with
484: .I mask
485: and compared with
486: .I value
487: until a match is found.
488: If
489: .B L
490: is used then the match is for 4 bytes at a time instead of 2.
491: If no match is found then
492: .I dot
493: is unchanged; otherwise
494: .I dot
495: is set to the matched location.
496: If
497: .I mask
498: is omitted then \-1 is used.
499: .TP
500: .RB [ ?/ ] w "\fI value ...\fR"
501: Write the 2-byte
502: .I value
503: into the addressed location. If the command is
504: .BR W ,
505: write 4 bytes.
506: Odd addresses are not allowed when writing to the subprocess address space.
507: .TP
508: [\fB?/\fR]\fBm\fI b1 e1 f1\fR[\fB?/\fR]
509: .br
510: New values for
511: .RI ( b1,\ e1,\ f1 )
512: are recorded. If less than three expressions are given then
513: the remaining map parameters are left unchanged.
514: If the `?' or `/' is followed by `\*(ST' then
515: the second segment (\fIb2\fR\|,\|\fIe2\fR\|,\|\fIf2\fR)
516: of the mapping is changed.
517: If the list is terminated by `?' or `/' then the file (\fIobjfil\fR or
518: .I corfil
519: respectively) is used for subsequent requests.
520: (So that, for example, `/m?' will cause `/' to refer to
521: .IR objfil .)
522: .TP
523: .BI \*(GT name
524: .I Dot
525: is assigned to the variable or register named.
526: .TP
527: .B !
528: A shell (/bin/sh) is called to read the rest of the line following `!'.
529: .TP
530: .RI $ modifier
531: Miscellaneous commands. The available
532: .I modifiers
533: are:
534: .RS
535: .TP
536: .BI < f
537: Read commands from the file
538: .IR f .
539: If this command is executed in a file, further commands
540: in the file are not seen.
541: If
542: .I f
543: is omitted, the current input stream is terminated. If a
544: .I count
545: is given, and is zero, the command will be ignored.
546: The value of the count will be placed in variable
547: .I 9
548: before the first command in
549: .I f
550: is executed.
551: .br
552: .ns
553: .TP
554: .BI << f
555: Similar to
556: .B <
557: except it can be used in a file of commands without
558: causing the file to be closed. Variable
559: .I 9
560: is saved during the execution of this command, and restored when it completes.
561: There is a (small) finite limit to the number of
562: .B <<
563: files that can be open at once.
564: .br
565: .ns
566: .TP
567: .BI > f
568: Append output to the file
569: .IR f ,
570: which is created if it does not exist. If
571: .I f
572: is omitted, output is returned to the terminal.
573: .br
574: .ns
575: .TP
576: .B ?
577: Print process id, the signal which caused stoppage or termination,
578: as well as the registers as \fB$r\fR. This is the default if
579: \fImodifier\fR is omitted.
580: .br
581: .ns
582: .TP
583: .B r
584: Print the general registers and the instruction addressed by
585: .BR pc .
586: .I Dot
587: is set to \fBpc\fR.
588: .br
589: .ns
590: .TP
591: .B b
592: Print all breakpoints and their associated counts and commands.
593: .br
594: .ns
595: .TP
596: .B c
597: C stack backtrace. If
598: .I address
599: is given then it is taken as the address of the current frame
600: instead of the contents of the frame\-pointer register. If
601: .B C
602: is used then the names and (32 bit) values of all automatic
603: and static variables are printed for each active function. (broken
604: on the VAX). If
605: .I count
606: is given then only the first
607: .I count
608: frames are printed.
609: .br
610: .ns
611: .TP
612: .B d
613: Set the default radix to
614: .I address
615: and report the new value. Note that
616: .I address
617: is interpreted in the (old) current radix.
618: Thus \*(lq10$d\*(rq never changes the default radix.
619: To make decimal the default radix, use \*(lq0t10$d\*(rq.
620: .br
621: .ns
622: .TP
623: .B e
624: The names and values of external variables are printed.
625: .br
626: .ns
627: .TP
628: .B w
629: Set the page width for output to
630: .I address
631: (default 80).
632: .br
633: .ns
634: .TP
635: .B s
636: Set the limit for symbol matches to
637: .I address
638: (default 255).
639: .br
640: .ns
641: .TP
642: .B o
643: All integers input are regarded as octal.
644: .br
645: .ns
646: .TP
647: .B q
648: Exit from
649: .IR adb .
650: .br
651: .ns
652: .TP
653: .B v
654: Print all non zero variables in octal.
655: .br
656: .ns
657: .TP
658: .B m
659: Print the address map.
660: .br
661: .ns
662: .TP
663: .B p
664: .RI ( "Kernel debugging" )
665: Change the current kernel memory mapping to map the designated
666: .B "user structure"
667: to the address given by the symbol
668: .I "_u."
669: The
670: .I address
671: argument is the address of the user's user page table entries (on
672: the VAX).
673: .RE
674: .TP
675: .BI : modifier
676: Manage a subprocess. Available modifiers are:
677: .RS
678: .TP
679: .BI b c
680: Set breakpoint at
681: .IR address .
682: The breakpoint is executed
683: .IR count \-1
684: times before causing a stop.
685: Each time the breakpoint is encountered the command
686: .I c
687: is executed. If this command is omitted or sets
688: .I dot
689: to zero then the breakpoint causes a stop.
690: .TP
691: .B d
692: Delete breakpoint at
693: .IR address .
694: .TP
695: .B r
696: Run
697: .I objfil
698: as a subprocess. If
699: .I address
700: is given explicitly then the program is entered at this point; otherwise
701: the program is entered at its standard entry point.
702: .I count
703: specifies how many breakpoints are to be ignored before stopping.
704: Arguments to the subprocess may be supplied on the same line as the command.
705: An argument starting with < or > causes the standard
706: input or output to be established for the command.
707: .TP
708: .BI c s
709: The subprocess is continued with signal
710: .I s,
711: see
712: .IR sigvec (2).
713: If
714: .I address
715: is given then the subprocess is continued at this address.
716: If no signal is specified then the signal
717: that caused the subprocess to stop is sent.
718: Breakpoint skipping is the same as for
719: .BR r .
720: .TP
721: .BI s s
722: As for
723: .B c
724: except that the subprocess is single stepped
725: .I count
726: times. If there is no current subprocess then
727: .I objfil
728: is run as a subprocess as for
729: .BR r .
730: In this case no signal can be sent; the remainder of the line
731: is treated as arguments to the subprocess.
732: .TP
733: .B k
734: The current subprocess, if any, is terminated.
735: .RE
736: .SH VARIABLES
737: .I Adb
738: provides a number of variables.
739: Named variables are set initially by
740: .I adb
741: but are not used subsequently.
742: Numbered variables are reserved for communication as follows.
743: .TP
744: 0
745: The last value printed.
746: .br
747: .ns
748: .TP
749: 1
750: The last offset part of an instruction source.
751: .br
752: .ns
753: .TP
754: 2
755: The previous value of variable 1.
756: .br
757: .ns
758: .TP
759: 9
760: The count on the last $< or $<< command.
761: .PP
762: On entry the following are set from the system header in the
763: .IR corfil .
764: If
765: .I corfil
766: does not appear to be a
767: .B core
768: file then these values are set from
769: .IR objfil .
770: .TP
771: b
772: The base address of the data segment.
773: .br
774: .ns
775: .TP
776: d
777: The data segment size.
778: .br
779: .ns
780: .TP
781: e
782: The entry point.
783: .br
784: .ns
785: .TP
786: m
787: The `magic' number (0407, 0410 or 0413).
788: .br
789: .ns
790: .TP
791: s
792: The stack segment size.
793: .br
794: .ns
795: .TP
796: t
797: The text segment size.
798: .SH ADDRESSES
799: The address in a file associated with
800: a written address is determined by a mapping associated with that file.
801: Each mapping is represented by two triples
802: .RI ( "b1, e1, f1" )
803: and
804: .RI ( "b2, e2, f2" )
805: and the
806: .I file address
807: corresponding to a written
808: .I address
809: is calculated as follows.
810: .PP
811: .if t .ti 1.5i
812: .if n .ti 8
813: .IR b1 \*(LE address < e1
814: \*(IM
815: .IR "file address" = address + f1\-b1,
816: otherwise,
817: .PP
818: .if t .ti 1.5i
819: .if n .ti 8
820: .IR b2 \*(LE address < e2
821: \*(IM
822: .IR "file address" = address + f2\-b2,
823: .PP
824: otherwise, the requested
825: .I address
826: is not legal. In some cases (e.g. for programs with separated I and D
827: space) the two segments for a file may overlap. If a
828: .B ?
829: or
830: .B /
831: is followed by an
832: .B \*(ST
833: then only the second triple is used.
834: .PP
835: The initial setting of both mappings is suitable for normal
836: .B a.out
837: and
838: .B core
839: files. If either file is not of the kind expected then, for that file,
840: .I b1
841: is set to 0,
842: .I e1
843: is set to the maximum file size and
844: .I f1
845: is set to 0; in this way the whole
846: file can be examined with no address translation.
847: .PP
848: .SH FILES
849: a.out
850: .br
851: core
852: .SH SEE\ ALSO
853: cc(1),
854: dbx(1),
855: ptrace(2),
856: a.out(5),
857: core(5)
858: .SH DIAGNOSTICS
859: `Adb' when there is no current command or format.
860: Comments about inaccessible files, syntax errors,
861: abnormal termination of commands, etc.
862: Exit status is 0, unless last command failed or returned nonzero status.
863: .SH BUGS
864: Since no shell is invoked to interpret the arguments of the
865: .B :r
866: command, the customary wild-card and variable expansions cannot occur.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.