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