BSD 4_2 development
[unix-history] / usr / man / man1 / dbx.1
CommitLineData
1e18170e
C
1.ds dB dbx
2.ds DB Dbx
3.TH DBX 1 "18 July 1983"
4.UC 4
5.SH NAME
6dbx \- debugger
7.SH SYNOPSIS
8.B dbx
9[
10.B \-r
11] [
12.B \-i
13] [
14.B \-I
15.I dir
16] [
17.I objfile
18[
19.I coredump
20]]
21.SH DESCRIPTION
22\fI\*(DB\fP is a tool for source level debugging and execution of
23programs under UNIX.
24The \fIobjfile\fP is an object file produced by a compiler
25with the appropriate flag (usually ``\-g'')
26specified to produce symbol information in the object file.
27Currently, \fIcc\fP(1) and \fIf77\fP(1) produce the appropriate source
28information
29and it is expected that in the future the Pascal compiler
30will also be able to generate source level information.
31The machine level facilities of \fI\*(dB\fP
32can be used on any program.
33.PP
34If no \fIobjfile\fP is specified, \fI\*(dB\fP looks
35for a file named ``a.out'' in the current directory.
36The object file contains a symbol table which includes the name of the
37all the source files translated by the compiler to create it.
38These files are available for perusal while using the debugger.
39.PP
40If a file named ``core'' exists in the current directory
41or a \fIcoredump\fP file is specified, \fI\*(dB\fP can be used
42to examine the state of the program when it faulted.
43.PP
44If the file ``.\*(dBinit'' exists in the current directory then the
45debugger commands in it are executed.
46\fI\*(DB\fP also checks for a ``.\*(dBinit'' in the user's home directory
47if there isn't one in the current directory.
48.PP
49The command line options and their meanings are:
50.nr In 7
51.in +\n(Inn
52.ta \n(Inn
53.br
54.nr wg 1v
55.ie \n(.h=\n(vk .nr wg -\n(vhu
56.el .nr vh 0
57.if \n(wg>0 \{\
58.sp \n(wgu
59.nr vh +\n(wgu \}
60.nr vk \n(.h
61.ti -\n(Inn
62\&\fB\-r\fP \c
63Execute \fIobjfile\fP immediately.
64If it terminates successfully \fI\*(dB\fP exits.
65Otherwise the reason for termination will be reported
66and the user offered the option of entering the debugger
67or letting the program fault.
68\fI\*(DB\fP will read from ``/dev/tty'' when \fB\-r\fP is specified
69and standard input is not a terminal.
70.br
71.nr wg 1v
72.ie \n(.h=\n(vk .nr wg -\n(vhu
73.el .nr vh 0
74.if \n(wg>0 \{\
75.sp \n(wgu
76.nr vh +\n(wgu \}
77.nr vk \n(.h
78.ti -\n(Inn
79\&\fB\-i\fP \c
80Force \fI\*(dB\fP to act as though standard input is a terminal.
81.br
82.nr wg 1v
83.ie \n(.h=\n(vk .nr wg -\n(vhu
84.el .nr vh 0
85.if \n(wg>0 \{\
86.sp \n(wgu
87.nr vh +\n(wgu \}
88.nr vk \n(.h
89.ti -\n(Inn
90\&\fB\-I\fP \fIdir\fP \c
91Add \fIdir\fP to the list of directories
92that are searched when looking for a source file.
93Normally \fI\*(dB\fP looks for source files in the current directory
94and in the directory where \fIobjfile\fP is located.
95The directory search path can also be set with the \fBuse\fP command.
96.in -\n(Inn
97.br
98.nr wg 1v
99.ie \n(.h=\n(vk .nr wg -\n(vhu
100.el .nr vh 0
101.if \n(wg>0 \{\
102.sp \n(wgu
103.nr vh +\n(wgu \}
104.nr vk \n(.h
105.PP
106Unless \fB\-r\fP is specified, \fI\*(dB\fP just prompts and waits for a command.
107.sp 1
108.ne 8
109.B Execution and Tracing Commands
110.sp 1
111.TP
112\fBrun\fP [\fIargs\fP] [\fB<\fP \fIfilename\fP] [\fB>\fP \fIfilename\fP]
113Start executing \fIobjfile\fP, passing \fIargs\fP as command line arguments;
114\fB<\fP or \fB>\fP can be used to redirect input or output in the usual manner.
115If \fIobjfile\fP has been written since the last time the symbolic information
116was read in, \fI\*(dB\fP will read in the new information.
117.TP
118\fBtrace\fP [\fBin\fP \fIprocedure/function\fP] [\fBif\fP \fIcondition\fP]
119.ns
120.TP
121\fBtrace\fP \fIsource-line-number\fP [\fBif\fP \fIcondition\fP]
122.ns
123.TP
124\fBtrace\fP \fIprocedure/function\fP [\fBin\fP \fIprocedure/function\fP] [\fBif\fP \fIcondition\fP]
125.ns
126.TP
127\fBtrace\fP \fIexpression\fP \fBat\fP \fIsource-line-number\fP [\fBif\fP \fIcondition\fP]
128.ns
129.TP
130\fBtrace\fP \fIvariable\fP [\fBin\fP \fIprocedure/function\fP] [\fBif\fP \fIcondition\fP]
131Have tracing information printed when the program is executed.
132A number is associated with the command that is used
133to turn the tracing off (see the \fBdelete\fP command).
134.sp 1
135The first argument describes what is to be traced.
136If it is a \fIsource-line-number\fP, then the line is printed
137immediately prior to being executed.
138Source line numbers in a file other than the current one
139must be preceded by the name of the file in quotes and a colon, e.g.
140"mumble.p":17.
141.sp 1
142If the argument is a procedure or function name then
143every time it is called, information is printed telling
144what routine called it, from what source line it was called,
145and what parameters were passed to it.
146In addition, its return is noted, and if it's a function
147then the value it is returning is also printed.
148.sp 1
149If the argument is an \fIexpression\fP with an \fBat\fP clause
150then the value of the expression is printed whenever the
151identified source line is reached.
152.sp 1
153If the argument is a variable then the name and value of the variable
154is printed whenever it changes.
155Execution is substantially slower during this form of tracing.
156.sp 1
157If no argument is specified then all source lines are printed
158before they are executed.
159Execution is substantially slower during this form of tracing.
160.sp 1
161The clause ``\fBin\fP \fIprocedure/function\fP'' restricts tracing information
162to be printed only while executing inside the given procedure
163or function.
164.sp 1
165\fICondition\fP is a boolean expression and is
166evaluated prior to printing the tracing information;
167if it is false then the information is not printed.
168.br
169.ne 10
170.IP "\fBstop\fP \fBif\fP \fIcondition\fP"
171.ns
172.IP "\fBstop\fP \fBat\fP \fIsource-line-number\fP [\fBif\fP \fIcondition\fP]"
173.ns
174.IP "\fBstop\fP \fBin\fP \fIprocedure/function\fP [\fBif\fP \fIcondition\fP]"
175.ns
176.IP "\fBstop\fP \fIvariable\fP [\fBif\fP \fIcondition\fP]"
177Stop execution when the given line is reached, procedure or function
178called, variable changed, or condition true.
179.IP "\fBstatus\fP [\fB>\fP \fIfilename\fP]"
180Print out the currently active \fBtrace\fP and \fBstop\fP commands.
181.IP "\fBdelete\fP \fIcommand-number\fP"
182The trace or stop corresponding to the given number is removed.
183The numbers associated with traces and stops are printed by
184the \fBstatus\fP command.
185.IP "\fBcatch\fP \fInumber\fP"
186.ns
187.IP "\fBignore\fP \fInumber\fP"
188Start or stop trapping signal \fInumber\fP before it is sent
189to the program.
190This is useful when a program being debugged
191handles signals such as interrupts.
192Initially all signals are trapped except SIGCONT, SIGCHILD,
193SIGALRM and SIGKILL.
194.IP \fBcont\fP
195Continue execution from where it stopped.
196Execution cannot be continued if the process has ``finished'',
197that is, called the standard procedure ``exit''.
198\fI\*(DB\fP does not allow the process to exit, thereby
199letting the user to examine the program state.
200.IP \fBstep\fP
201Execute one source line.
202.IP \fBnext\fP
203Execute up to the next source line.
204The difference between this and \fBstep\fP is that
205if the line contains a call to a procedure or function
206the \fBstep\fP command will stop at the beginning of that
207block, while the \fBnext\fP command will not.
208.sp 1
209.br
210.ne 8v
211.PP
212.B Displaying and Naming Data
213.sp 1
214.IP "\fBprint\fP \fIexpression\fP [\fB,\fP \fIexpression\fP ...]"
215Print out the values of the expressions.
216Array expressions are always subscripted by brackets (``[ ]'').
217Variables having the same identifier as one in the current block may be
218referenced as ``\fIblock-name\fP\ \fB.\fP\ \fIvariable\fP''.
219The field reference operator (``.'') can be used with pointers
220as well as records, making the C operator ``->'' unnecessary
221(although it is supported).
222The construct \fItypename\fP(\fIexpression\fP) can be used to print
223the \fIexpression\fP out in the format of the named \fItype\fP.
224.IP "\fBwhatis\fP \fIname\fP"
225Print the declaration of the given name, which may be qualified
226with block names as above.
227.IP "\fBwhich\fP \fIidentifier\fP"
228Print the full qualification of the given identifer, i.e.
229the outer blocks that the identifier is associated with.
230.IP "\fBwhereis\fP \fIidentifier\fP"
231Print the full qualification of all the symbols whose
232name matches the given identifier.
233The order in which the symbols are printed is not meaningful.
234.IP "\fBassign\fP \fIvariable\fP \fB=\fP \fIexpression\fP"
235.ns
236.IP "\fBset\fP \fIvariable\fP \fB=\fP \fIexpression\fP"
237Assign the value of the expression to the variable.
238.IP "\fBcall\fP \fIprocedure(parameters)\fP"
239Execute the object code associated with the named procedure or function.
240Currently, calls to a procedure with a variable number of arguments
241are not possible.
242Also, string parameters are not passed properly for C.
243.IP \fBwhere\fP
244Print out a list of the active procedures and function.
245.IP "\fBdump\fP [\fB>\fP \fIfilename\fP]"
246Print the names and values of all active variables.
247.sp 1
248.br
249.ne 8v
250.PP
251.B Accessing Source Files
252.sp 1
253.IP "\fBedit\fP [\fIfilename\fP]"
254.ns
255.IP "\fBedit\fP \fIprocedure/function-name\fP"
256Invoke an editor on \fIfilename\fP or the current source file if none
257is specified.
258If a \fIprocedure\fP or \fIfunction\fP name is specified,
259the editor is invoked on the file that contains it.
260Which editor is invoked by default depends on the installation.
261The default can be overridden by setting the environment variable
262EDITOR to the name of the desired editor.
263.IP "\fBfile\fP [\fIfilename\fP]"
264Change the current source file name to \fIfilename\fP.
265If none is specified then the current source file name is printed.
266.IP "\fBfunc\fP [\fIprocedure/function\fP]"
267Change the current function.
268If none is specified then print the current function.
269Changing the current function implicitly changes the current source file
270to the one that contains the function; it also changes the current scope
271used for name resolution.
272.IP "\fBlist\fP [\fIsource-line-number\fP [\fB,\fP \fIsource-line-number\fP]]"
273.ns
274.IP "\fBlist\fP \fIprocedure/function\fP"
275List the lines in the current source file from the first line number to
276the second inclusive.
277If no lines are specified, the next 10 lines are listed.
278If the name of a procedure or function is given
279lines \fIn-k\fP to \fIn+k\fP are listed where \fIn\fP is the first statement
280in the procedure or function and \fIk\fP is small.
281.IP "\fBuse\fP \fIdirectory-list\fP"
282Set the list of directories to be searched
283when looking for source files.
284.sp 1
285.br
286.ne 8v
287.PP
288.B Machine Level Commands
289.sp 1
290.TP
291\fBtracei\fP [\fIaddress\fP] [\fBif\fP \fIcond\fP]
292.ns
293.TP
294\fBtracei\fP [\fIvariable\fP] [\fBat\fP \fIaddress\fP] [\fBif\fP \fIcond\fP]
295.ns
296.TP
297\fBstopi\fP [\fIaddress\fP] [\fBif\fP \fIcond\fP]
298.ns
299.TP
300\fBstopi\fP [\fBat\fP] [\fIaddress\fP] [\fBif\fP \fIcond\fP]
301Turn on tracing or set a stop using a machine instruction address.
302.TP
303\fBstepi\fP
304.ns
305.TP
306\fBnexti\fP
307Single step as in \fBstep\fP or \fBnext\fP, but do a single instruction
308rather than source line.
309.TP
310\fIaddress\fP \fB,\fP\fIaddress\fP\fB/\fP [\fImode\fP]
311.ns
312.TP
313[\fIaddress\fP] \fB/\fP [\fIcount\fP] [\fImode\fP]
314Print the contents of memory starting at the first \fIaddress\fP
315and continuing up to the second \fIaddress\fP or until \fIcount\fP items are printed.
316If no address is specified, the address following the one
317printed most recently is used.
318The \fImode\fP specifies how memory is to be printed;
319if it is omitted the previous mode specified is used.
320The initial mode is ``X''.
321The following modes are supported:
322.nr In 5
323.in +\n(Inn
324.ta \n(Inn
325.br
326.nr wg 1v
327.ie \n(.h=\n(vk .nr wg -\n(vhu
328.el .nr vh 0
329.if \n(wg>0 \{\
330.sp \n(wgu
331.nr vh +\n(wgu \}
332.nr vk \n(.h
333.ti -\n(Inn
334\&\fBi\fP \c
335print the machine instruction
336.br
337.nr wg 0v
338.ie \n(.h=\n(vk .nr wg -\n(vhu
339.el .nr vh 0
340.if \n(wg>0 \{\
341.sp \n(wgu
342.nr vh +\n(wgu \}
343.nr vk \n(.h
344.ti -\n(Inn
345\&\fBd\fP \c
346print a short word in decimal
347.br
348.nr wg 0v
349.ie \n(.h=\n(vk .nr wg -\n(vhu
350.el .nr vh 0
351.if \n(wg>0 \{\
352.sp \n(wgu
353.nr vh +\n(wgu \}
354.nr vk \n(.h
355.ti -\n(Inn
356\&\fBD\fP \c
357print a long word in decimal
358.br
359.nr wg 0v
360.ie \n(.h=\n(vk .nr wg -\n(vhu
361.el .nr vh 0
362.if \n(wg>0 \{\
363.sp \n(wgu
364.nr vh +\n(wgu \}
365.nr vk \n(.h
366.ti -\n(Inn
367\&\fBo\fP \c
368print a short word in octal
369.br
370.nr wg 0v
371.ie \n(.h=\n(vk .nr wg -\n(vhu
372.el .nr vh 0
373.if \n(wg>0 \{\
374.sp \n(wgu
375.nr vh +\n(wgu \}
376.nr vk \n(.h
377.ti -\n(Inn
378\&\fBO\fP \c
379print a long word in octal
380.br
381.nr wg 0v
382.ie \n(.h=\n(vk .nr wg -\n(vhu
383.el .nr vh 0
384.if \n(wg>0 \{\
385.sp \n(wgu
386.nr vh +\n(wgu \}
387.nr vk \n(.h
388.ti -\n(Inn
389\&\fBx\fP \c
390print a short word in hexadecimal
391.br
392.nr wg 0v
393.ie \n(.h=\n(vk .nr wg -\n(vhu
394.el .nr vh 0
395.if \n(wg>0 \{\
396.sp \n(wgu
397.nr vh +\n(wgu \}
398.nr vk \n(.h
399.ti -\n(Inn
400\&\fBX\fP \c
401print a long word in hexadecimal
402.br
403.nr wg 0v
404.ie \n(.h=\n(vk .nr wg -\n(vhu
405.el .nr vh 0
406.if \n(wg>0 \{\
407.sp \n(wgu
408.nr vh +\n(wgu \}
409.nr vk \n(.h
410.ti -\n(Inn
411\&\fBb\fP \c
412print a byte in octal
413.br
414.nr wg 0v
415.ie \n(.h=\n(vk .nr wg -\n(vhu
416.el .nr vh 0
417.if \n(wg>0 \{\
418.sp \n(wgu
419.nr vh +\n(wgu \}
420.nr vk \n(.h
421.ti -\n(Inn
422\&\fBc\fP \c
423print a byte as a character
424.br
425.nr wg 0v
426.ie \n(.h=\n(vk .nr wg -\n(vhu
427.el .nr vh 0
428.if \n(wg>0 \{\
429.sp \n(wgu
430.nr vh +\n(wgu \}
431.nr vk \n(.h
432.ti -\n(Inn
433\&\fBs\fP \c
434print a string of characters terminated by a null byte
435.br
436.nr wg 0v
437.ie \n(.h=\n(vk .nr wg -\n(vhu
438.el .nr vh 0
439.if \n(wg>0 \{\
440.sp \n(wgu
441.nr vh +\n(wgu \}
442.nr vk \n(.h
443.ti -\n(Inn
444\&\fBf\fP \c
445print a single precision real number
446.br
447.nr wg 0v
448.ie \n(.h=\n(vk .nr wg -\n(vhu
449.el .nr vh 0
450.if \n(wg>0 \{\
451.sp \n(wgu
452.nr vh +\n(wgu \}
453.nr vk \n(.h
454.ti -\n(Inn
455\&\fBg\fP \c
456print a double precision real number
457.in -\n(Inn
458.br
459.nr wg 1v
460.ie \n(.h=\n(vk .nr wg -\n(vhu
461.el .nr vh 0
462.if \n(wg>0 \{\
463.sp \n(wgu
464.nr vh +\n(wgu \}
465.nr vk \n(.h
466.PP
467Symbolic addresses are specified by preceding the name with an ``&''.
468Registers are denoted by ``$rN'' where N is the number of the register.
469Addresses may be expressions made up of other addresses and
470the operators ``+'', ``-'', and indirection (unary ``*'').
471.sp 1
472.br
473.ne 8v
474.PP
475.B Miscellaneous Commands
476.sp 1
477.IP "\fBsh\fP \fIcommand-line\fP"
478Pass the command line to the shell for execution.
479The SHELL environment variable determines which shell is used.
480.IP "\fBalias\fP \fInew-command-name\fP \fIold-command-name\fP"
481Respond to \fInew-command-name\fP
482as though it were \fIold-command-name\fP.
483.IP \fBhelp\fP
484Print out a synopsis of \fI\*(dB\fP commands.
485.IP \fBgripe\fP
486Invoke a mail program to send a message to the person in charge of \fI\*(dB\fP.
487.TP
488\fBsource\fP \fIfilename\fP
489Read \fI\*(dB\fP commands from the given \fIfilename\fP.
490Especially useful when the \fIfilename\fP has been created by redirecting
491a \fBstatus\fP command from an earlier debugging session.
492.IP "\fBquit\fP"
493Exit \fI\*(dB\fP.
494.SH FILES
495.nr In 20
496.in +\n(Inn
497.ta \n(Inn
498.br
499.nr wg 1v
500.ie \n(.h=\n(vk .nr wg -\n(vhu
501.el .nr vh 0
502.if \n(wg>0 \{\
503.sp \n(wgu
504.nr vh +\n(wgu \}
505.nr vk \n(.h
506.ti -\n(Inn
507\&a.out \c
508object file
509.br
510.nr wg 0v
511.ie \n(.h=\n(vk .nr wg -\n(vhu
512.el .nr vh 0
513.if \n(wg>0 \{\
514.sp \n(wgu
515.nr vh +\n(wgu \}
516.nr vk \n(.h
517.ti -\n(Inn
518\&\&.\*(dBinit \c
519initial commands
520.br
521.nr wg 0v
522.ie \n(.h=\n(vk .nr wg -\n(vhu
523.el .nr vh 0
524.if \n(wg>0 \{\
525.sp \n(wgu
526.nr vh +\n(wgu \}
527.nr vk \n(.h
528.SH SEE ALSO
529cc(1), f77(1), pc(1)
530.SH COMMENTS
531Non-local gotos can cause some trace/stops to be missed.
532Most of the command names are too long.
533The alias facility helps, but is really quite weak.
534A \fIcsh\fP-like history capability would improve the situation.
535But then, who wants to duplicate the c-shell in a debugger?
536.PP
537\fI\*(DB\fP suffers from the same ``multiple include'' malady as does sdb.
538If you have a program consisting of a number of object files
539and each is built from source files that include header files,
540the symbolic information for the header files is replicated in
541each object file.
542Since about one debugger start-up is done for each link,
543having the linker (ld) re-organize the symbol information
544won't save much time, though it would reduce some of the
545disk space used.
546The problem is an artifact of the unrestricted semantics
547of #include's in C; for example an include file can contain
548static declarations that are separate entities for each file
549in which they are included.