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