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