mv more tahoe stuff to machdep; clk_enable was dup;
[unix-history] / usr / src / old / sdb / sdb.1
CommitLineData
9023b93d
KM
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.\"
7e5e5e65 5.\" @(#)sdb.1 6.1 (Berkeley) %G%
9023b93d 6.\"
7e5e5e65 7.TH SDB 1 "%G%"
9023b93d
KM
8.UC 4
9.SH NAME
10sdb \- symbolic debugger
11.SH SYNOPSIS
12.B sdb
13[ objfil [ corfil [ directory ] ] ]
14.SH DESCRIPTION
15.I Sdb
16is a symbolic debugger which can be used with C, PASCAL, and F77 programs.
17It may be used to examine their files and to provide
18a controlled environment for their execution.
19.PP
20.I Objfil
21is an executable program file
22which has been compiled with the \-g (debug) option.
23The default for
24.I objfil
25is
26.B a.out.
27.I Corfil
28is assumed to be a core image file produced after
29executing
30.IR objfil ;
31the default for
32.I corfil
33is
34.B core.
35The core file need not be present.
36.PP
37It is useful to know that at any time there is a
38.I "current line"
39and
40.I "current file."
41If
42.I corfil
43exists then they are initially set to the line and file
44containing the source statement at which the process terminated or stopped.
45Otherwise, they are set to the first line in main.
46The current line and file may be changed with the source file
47examination commands.
48.PP
49Names of variables are written just as they are in C, PASCAL, or F77.
50Variables local to a procedure may be accessed using the form
51`procedure:variable'.
52If no procedure name is given, the procedure containing the
53current line is used by default.
54It is also possible to refer to structure members as `variable.member',
55pointers to structure members as `variable\(mi>member' and array elements
56as `variable[number]'.
57Combinations of these forms may also be used.
58.PP
59It is also possible to specify a variable by its address.
60All forms of integer constants which are valid in C may be used, so that
61addresses may be input in decimal, octal or hexadecimal.
62.PP
63Line numbers in the source program are referred to as `filename:number'
64or `procedure:number'.
65In either case the number is relative to the beginning of the file.
66If no procedure or file name is given,
67the current file is used by default.
68If no number is given,
69the first line of the named procedure or file is used.
70.sp 1
71.PP
72The commands for examining data in the program are:
73.TP 5
74.B t
75Print a stack trace of the terminated or stopped program.
76.TP 5
77.B T
78Print the top line of the stack trace.
79.TP 5
80variable/\fIlm\fP
81Print the value of variable according to
82length
83.I l
84and format
85.I m.
86If
87.I l
88and
89.I m
90are omitted,
91sdb chooses a length and format suitable for the variable's type
92as declared in the program.
93The length specifiers are:
94.RS
95.TP
96.BI b
97one byte
98.br
99.ns
100.TP
101.BI h
102two bytes (half word)
103.br
104.ns
105.TP
106.BI l
107four bytes (long word)
108.br
109.ns
110.TP
111number
112string length for formats
113.B s
114and
115.B a
116.RE
117.TP 5
118\
119Legal values for
120.I m
121are:
122.RS
123.TP
124.BI c
125character
126.br
127.ns
128.TP
129.BI d
130decimal
131.br
132.ns
133.TP
134.BI u
135decimal, unsigned
136.br
137.ns
138.TP
139.BI o
140octal
141.br
142.ns
143.TP
144.BI x
145hexadecimal
146.br
147.ns
148.TP
149.BI f
15032 bit single precision floating point
151.br
152.ns
153.TP
154.BI g
15564 bit double precision floating point
156.br
157.ns
158.TP
159.BI s
160Assume variable is a string pointer and print characters until a null is
161reached.
162.br
163.ns
164.TP
165.BI a
166Print characters starting at the variable's address until a null
167is reached.
168.br
169.ns
170.TP
171.BI p
172pointer to procedure
173.RE
174.TP 5
175\
176The length specifiers are only effective with the formats
177\fBd\fP, \fBu\fP, \fBo\fP and \fBx\fP.
178If
179one of these formats
180is specified and
181.I l
182is omitted,
183the length
184defaults to the word length of the host machine;
1854 for the DEC VAX/11-780.
186The last variable may be redisplayed with the command `./'.
187.sp
188The sh(1) metacharacters
189.B *
190and
191.B ?
192may be used within procedure and variable names,
193providing a limited form of pattern matching.
194If no procedure name is given, both variables local to the current
195procedure and global (common for F77) variables are matched,
196while if a procedure name is specified then
197only variables local to that procedure and matched.
198To match only global variables (or blank common for F77),
199the form `:pattern' is used.
200The name of a common block may be specified instead of a procedure name
201for F77 programs.
202.RE
203.TP 5
204variable\fB=\fP\fIlm\fP
205.br
206.ns
207.TP 5
208linenumber\fB=\fP\fIlm\fP
209.br
210.ns
211.TP 5
212number\fB=\fP\fIlm\fP
213Print the address of the variable or line number or the value of the number
214in the specified format.
215If no format is given, then `lx' is used.
216The last variant of this command provides a convenient way to convert
217between decimal, octal and hexadecimal.
218.TP 5
219variable\fB!\fPvalue
220Set the variable to the given value.
221The value may be a number, character constant or a variable.
222If the variable is of type float or double,
223the value may also be a floating constant.
224.sp 1
225.PP
226The commands for examining source files are
227.TP 5
228\fBe\fP procedure
229.br
230.ns
231.TP 5
232\fBe\fP filename.c
233Set the current file to
234the file containing the named procedure
235or the named filename.
236Set the current line to the first line in the named
237procedure or file.
238All source files are assumed to be in
239.I directory.
240The default for
241.I directory
242is the working directory.
243If no procedure or file name is given, the current procedure and file names
244are reported.
245.TP 5
246\fB/\fPregular expression\fB/\fP
247Search forward from the current line for a line containing
248a string matching the regular expression as in ed(1).
249The trailing `/' may be elided.
250.TP 5
251\fB?\fPregular expression\fB?\fP
252Search backward from the current line for a line containing
253a string matching the regular expression as in ed(1).
254The trailing `?' may be elided.
255.TP 5
256.B p
257Print the current line.
258.TP 5
259.B z
260Print the current line followed by the next 9 lines.
261Set the current line to the last line printed.
262.TP 5
263.B control-D
264Scroll.
265Print the next 10 lines.
266Set the current line to the last line printed.
267.TP 5
268.B w
269Window.
270Print the 10 lines around the current line.
271.TP 5
272number
273Set the current line to the given line number.
274Print the new current line.
275.TP 5
276\fIcount\fB +\fR
277Advance the current line by \fIcount\fP lines.
278Print the new current line.
279.TP 5
280\fIcount\fB \(mi\fR
281Retreat the current line by \fIcount\fP lines.
282Print the new current line.
283.sp 1
284.PP
285The commands for controlling the execution of the source program are:
286.TP 5
287\fIcount\fB r \fIargs\fR
288.br
289.ns
290.TP 5
291\fIcount\fB R
292Run the program with the given arguments.
293The \fBr\fP command with no arguments reuses the previous arguments
294to the program while the \fBR\fP command
295runs the program with no arguments.
296An argument beginning with `<' or `>' causes redirection for the
297standard input or output respectively.
298If \fIcount\fP is given,
299it specifies the number of breakpoints to be ignored.
300.TP 5
301\fIlinenumber\fB c\fI count\fR
302.br
303.ns
304.TP 5
305\fIlinenumber\fB C\fI count\fR
306Continue after a breakpoint or interrupt.
307If \fIcount\fP is given,
308it specifies the number of breakpoints to be ignored.
309\fBC\fP continues with the signal which caused the program to stop and
310\fBc\fP ignores it.
311.sp 0.5
312If a linenumber is specified
313then a temporary breakpoint is placed at the line
314and execution is continued.
315The breakpoint is deleted when the command finishes.
316.TP 5
317\fIcount\fB s\fR
318Single step.
319Run the program through \fIcount\fP lines.
320If no count is given then the program is run for one line.
321.TP 5
322\fIcount\fB S\fR
323Single step, but step through subroutine calls.
324.TP 5
325.B k
326Kill the debugged program.
327.TP 5
328procedure\fB(\fParg1,arg2,...\fB)\fP
329.br
330.ns
331.TP 5
332procedure\fB(\fParg1,arg2,...\fB)/\fP\fIm\fP
333Execute the named procedure with the given arguments.
334Arguments can be integer, character or string constants
335or names of variables accessible from the current procedure.
336The second form causes the value returned by the procedure to be
337printed according to format \fIm\fP.
338If no format is given, it defaults to `d'.
339.TP 5
340\fIlinenumber\fB b\fR \fIcommands\fR
341Set a breakpoint at the given line.
342If a procedure name without a line number is given (e.g. `proc:'),
343a breakpoint is placed at the first line in the procedure
344even if it was not compiled with the debug flag.
345If no \fIlinenumber\fP is given,
346a breakpoint is placed at the current line.
347.sp 0.5
348If no
349.I commands
350are given then execution stops just before the breakpoint
351and control is returned to sdb.
352Otherwise
353the
354.I commands
355are executed when the breakpoint is
356encountered and execution continues.
357Multiple commands are specified by separating them with semicolons.
358.TP 5
359\fIlinenumber\fB d\fR
360Delete a breakpoint at the given line.
361If no \fIlinenumber\fP is given then the breakpoints are deleted interactively:
362Each breakpoint location is printed and a line is read from the standard input.
363If the line begins with a `y' or `d' then the breakpoint is deleted.
364.TP 5
365.B B
366Print a list of the currently active breakpoints.
367.TP 5
368.B D
369Delete all breakpoints.
370.TP 5
371l
372Print the last executed line.
373.TP 5
374\fIlinenumber\fB a\fR
375Announce.
376If \fIlinenumber\fR is of the form `proc:number', the command
377effectively does a `linenumber b l'.
378If \fIlinenumber\fR is of the form `proc:', the command
379effectively does a `proc: b T'.
380.sp 1
381.PP
382Miscellaneous commands.
383.TP 5
384\fB! \fIcommand\fR
385The command is interpreted by sh(1).
386.TP 5
387.B newline
388If the previous command printed a source line then
389advance the current line by 1 line and
390print the new current line.
391If the previous command displayed a core location then
392display the next core location.
393.TP 5
394\fB"\fI string\fR
395Print the given string.
396.TP 5
397.B q
398Exit the debugger.
399.sp 1
400.PP
401The following commands also exist and are intended only for
402debugging the debugger.
403.TP 5
404.B V
405Print the version number.
406.TP 5
407.B X
408Print a list of procedures and files being debugged.
409.TP 5
410.B Y
411Toggle debug output.
412.SH FILES
413a.out
414.br
415core
416.SH SEE\ ALSO
417adb(1)
418.SH DIAGNOSTICS
419Error reports are either identical to those of adb(1) or are
420self-explanatory.
421.SH BUGS
422If a procedure is called when the program is
423.I not
424stopped at a breakpoint
425(such as when a core image is being debugged),
426all variables are initialized before the procedure is started.
427This makes it impossible to use a procedure which formats
428data from a core image.
429.PP
430Arrays must be of one dimension and of zero origin to be correctly
431addressed by sdb.
432.PP
433The default type for printing F77 parameters is incorrect.
434Their address is printed instead of their value.
435.PP
436Tracebacks containing F77 subprograms with multiple entry points
437may print too many arguments in the wrong order, but their values
438are correct.
439.PP
440Sdb understands Pascal, but not its types.