xref: /csrg-svn/old/dbx/dbx.1 (revision 43083)
1*43083Scael.\" Copyright (c) 1983, 1990 The Regents of the University of California.
238105Sbostic.\" All rights reserved.
319716Smckusick.\"
4*43083Scael.\" %sccs.include.redist.man%
519716Smckusick.\"
6*43083Scael.\"     @(#)dbx.1	6.4 (Berkeley) 06/11/90
738105Sbostic.\"
8*43083Scael.Dd
9*43083Scael.Dt DBX 1
10*43083Scael.Os BSD 4.2
11*43083Scael.Sh NAME
12*43083Scael.Nm dbx
13*43083Scael.Nd debugger
14*43083Scael.Sh SYNOPSIS
15*43083Scael.Nm Dbx
16*43083Scael.Op Fl r
17*43083Scael.Op Fl i
18*43083Scael.Op Fl k
19*43083Scael.Op Fl I Ar dir
20*43083Scael.Op Fl c Ar file
21*43083Scael.Op Ar objfile Op Ar coredump
22*43083Scael.Sh DESCRIPTION
23*43083Scael.Nm dbx
24*43083Scaelis a tool for source level debugging and execution of
2519716Smckusickprograms under UNIX.
26*43083ScaelThe
27*43083Scael.Ar objfile
28*43083Scaelis an object file produced by a compiler
29*43083Scaelwith the appropriate flag (usually
30*43083Scael.Fl g )
3119716Smckusickspecified to produce symbol information in the object file.
32*43083ScaelCurrently,
33*43083Scael.Xr cc 1 ,
34*43083Scael.Xr f77 1 ,
35*43083Scael.Xr pc 1 ,
36*43083Scaeland the DEC Western
37*43083ScaelResearch Laboratory Modula-2 compiler,
38*43083Scael.Xr mod l ,
3919720Smckusickproduce the appropriate source information.
40*43083ScaelThe machine level facilities of
41*43083Scael.Nm dbx
4219716Smckusickcan be used on any program.
43*43083Scael.Pp
4419720SmckusickThe object file contains a symbol table that includes the name of the
4519716Smckusickall the source files translated by the compiler to create it.
4619716SmckusickThese files are available for perusal while using the debugger.
47*43083Scael.Pp
48*43083ScaelIf a file named ``core''
49*43083Scaelexists in the current directory
50*43083Scaelor a
51*43083Scael.Ar coredump
52*43083Scaelfile is specified,
53*43083Scael.Nm dbx
54*43083Scaelcan be used
5519716Smckusickto examine the state of the program when it faulted.
56*43083Scael.Pp
57*43083ScaelIf the file ``.dbxinit'' exists in the current directory then the
5819716Smckusickdebugger commands in it are executed.
59*43083Scael.Nm Dbx
60*43083Scaelalso checks for a ``.dbxinit'' in the user's home directory
6119716Smckusickif there isn't one in the current directory.
62*43083Scael.Pp
6319716SmckusickThe command line options and their meanings are:
64*43083Scael.Tw Fl
65*43083Scael.Tp Fl r
66*43083ScaelExecute
67*43083Scael.Ar objfile
68*43083Scaelimmediately.
69*43083ScaelIf it terminates successfully
70*43083Scael.Nm dbx
71*43083Scaelexits.
7219716SmckusickOtherwise the reason for termination will be reported
7319716Smckusickand the user offered the option of entering the debugger
7419716Smckusickor letting the program fault.
75*43083Scael.Nm Dbx
76*43083Scaelwill read from ``/dev/tty'' when
77*43083Scael.Fl r
78*43083Scaelis specified
7919716Smckusickand standard input is not a terminal.
80*43083Scael.Tp Fl i
81*43083ScaelForce
82*43083Scael.Nm dbx
83*43083Scaelto act as though standard input is a terminal.
84*43083Scael.Tp Fl k
8519720SmckusickMap memory addresses, useful for kernel debugging.
86*43083Scael.Tp Cx Fl I
87*43083Scael.Cx \&\ \&
88*43083Scael.Ar dir
89*43083Scael.Cx
90*43083ScaelAdd
91*43083Scael.Ar dir
92*43083Scaelto the list of directories
9319716Smckusickthat are searched when looking for a source file.
94*43083ScaelNormally
95*43083Scael.Nm dbx
96*43083Scaellooks for source files in the current directory
97*43083Scaeland in the directory where
98*43083Scael.Ar objfile
99*43083Scaelis located.
100*43083ScaelThe directory search path can also be set with the
101*43083Scael.Ar use
102*43083Scaelcommand.
103*43083Scael.Tp Cx Fl c
104*43083Scael.Cx \&\ \&
105*43083Scael.Ar file
106*43083Scael.Cx
107*43083ScaelExecute the
108*43083Scael.Nm dbx
109*43083Scaelcommands in the
110*43083Scael.Ar file
111*43083Scaelbefore
11219720Smckusickreading from standard input.
113*43083Scael.Tp
114*43083Scael.Pp
115*43083ScaelUnless
116*43083Scael.Fl r
117*43083Scaelis specified,
118*43083Scael.Nm dbx
119*43083Scaeljust prompts and waits for a command.
120*43083Scael.Ss Execution and Tracing Commands
121*43083Scael.Dw Fl
122*43083Scael.Di L
123*43083Scael.Dp Cx Ic run
124*43083Scael.Cx \&\ \&
125*43083Scael.Op Ar args
126*43083Scael.Cx \&\ \&
127*43083Scael.Op Sy < Ar filename
128*43083Scael.Cx \&\ \&
129*43083Scael.Op Sy > Ar filename
130*43083Scael.Cx
131*43083Scael.Dp Cx Ic rerun
132*43083Scael.Cx \&\ \&
133*43083Scael.Op Ar args
134*43083Scael.Cx \&\ \&
135*43083Scael.Op Sy < Ar filename
136*43083Scael.Cx \&\ \&
137*43083Scael.Op Sy > Ar filename
138*43083Scael.Cx
139*43083ScaelStart executing
140*43083Scael.Ar objfile  ,
141*43083Scaelpassing
142*43083Scael.Ar args
143*43083Scaelas command line arguments;
144*43083Scael.Sy <
145*43083Scaelor
146*43083Scael.Sy >
147*43083Scaelcan be used to redirect input or output in the usual manner.
148*43083ScaelWhen
149*43083Scael.Ic rerun
150*43083Scaelis used without any arguments the previous
15119720Smckusickargument list is passed to the program;
152*43083Scaelotherwise it is identical to
153*43083Scael.Ic run .
154*43083ScaelIf
155*43083Scael.Ar objfile
156*43083Scaelhas been written since the last time the symbolic information
157*43083Scaelwas read in,
158*43083Scael.Nm dbx
159*43083Scaelwill read in the new information.
160*43083Scael.Dp Cx Ic trace
161*43083Scael.Cx \&\ \&
162*43083Scael.Op Ic in Ar procedure/function
163*43083Scael.Cx \&\ \&
164*43083Scael.Op Ic if Ar condition
165*43083Scael.Cx
166*43083Scael.Dp Cx Ic trace
167*43083Scael.Cx \&\ \&
168*43083Scael.Ar source-line-number
169*43083Scael.Cx \&\ \&
170*43083Scael.Op Ic if Ar condition
171*43083Scael.Cx
172*43083Scael.Dp Cx Ic trace
173*43083Scael.Cx \&\ \&
174*43083Scael.Ar procedure/function
175*43083Scael.Cx \&\ \&
176*43083Scael.Op Ic in Ar procedure/function
177*43083Scael.Cx \&\ \&
178*43083Scael.Op Ic if Ar condition
179*43083Scael.Cx
180*43083Scael.Dp Cx Ic trace
181*43083Scael.Cx \&\ \&
182*43083Scael.Ar expression
183*43083Scael.Cx \&\ \&
184*43083Scael.Ic at
185*43083Scael.Cx \&\ \&
186*43083Scael.Ar source-line-number
187*43083Scael.Cx \&\ \&
188*43083Scael.Op Ic if Ar condition
189*43083Scael.Cx
190*43083Scael.Dp Cx Ic trace
191*43083Scael.Cx \&\ \&
192*43083Scael.Ar variable
193*43083Scael.Cx \&\ \&
194*43083Scael.Op Ic in Ar procedure/function
195*43083Scael.Cx \&\ \&
196*43083Scael.Op Ic if Ar condition
197*43083Scael.Cx
19819716SmckusickHave tracing information printed when the program is executed.
19919716SmckusickA number is associated with the command that is used
200*43083Scaelto turn the tracing off (see the
201*43083Scael.Ic delete
202*43083Scaelcommand).
203*43083Scael.Pp
20419716SmckusickThe first argument describes what is to be traced.
205*43083ScaelIf it is a
206*43083Scael.Ar source-line-number ,
207*43083Scaelthen the line is printed
20819716Smckusickimmediately prior to being executed.
20919716SmckusickSource line numbers in a file other than the current one
21019716Smckusickmust be preceded by the name of the file in quotes and a colon, e.g.
21119716Smckusick"mumble.p":17.
212*43083Scael.Pp
21319716SmckusickIf the argument is a procedure or function name then
21419716Smckusickevery time it is called, information is printed telling
21519716Smckusickwhat routine called it, from what source line it was called,
21619716Smckusickand what parameters were passed to it.
21719716SmckusickIn addition, its return is noted, and if it's a function
21819716Smckusickthen the value it is returning is also printed.
219*43083Scael.Pp
220*43083ScaelIf the argument is an
221*43083Scael.Ar expression
222*43083Scaelwith an
223*43083Scael.Ic at
224*43083Scaelclause
22519716Smckusickthen the value of the expression is printed whenever the
22619716Smckusickidentified source line is reached.
227*43083Scael.Pp
22819716SmckusickIf the argument is a variable then the name and value of the variable
22919716Smckusickis printed whenever it changes.
23019716SmckusickExecution is substantially slower during this form of tracing.
231*43083Scael.Pp
23219716SmckusickIf no argument is specified then all source lines are printed
23319716Smckusickbefore they are executed.
23419716SmckusickExecution is substantially slower during this form of tracing.
235*43083Scael.Pp
236*43083ScaelThe clause
237*43083Scael.Ic in
238*43083Scael.Ar procedure/function
239*43083Scaelrestricts tracing information
24019716Smckusickto be printed only while executing inside the given procedure
24119716Smckusickor function.
242*43083Scael.Pp
243*43083Scael.Ar Condition
244*43083Scaelis a boolean expression and is
24519716Smckusickevaluated prior to printing the tracing information;
24619716Smckusickif it is false then the information is not printed.
247*43083Scael.Dp Cx Ic stop if
248*43083Scael.Cx \&\ \&
249*43083Scael.Ar condition
250*43083Scael.Cx
251*43083Scael.Dp Cx Ic stop at
252*43083Scael.Cx \&\ \&
253*43083Scael.Ar source-line-number
254*43083Scael.Cx \&\ \&
255*43083Scael.Op Ic if Ar condition
256*43083Scael.Cx
257*43083Scael.Dp Cx Ic stop in
258*43083Scael.Cx \&\ \&
259*43083Scael.Ar source-line-number
260*43083Scael.Cx \&\ \&
261*43083Scael.Op Ic if Ar condition
262*43083Scael.Cx
263*43083Scael.Dp Cx Ic stop
264*43083Scael.Cx \&\ \&
265*43083Scael.Ar variable
266*43083Scael.Cx \&\ \&
267*43083Scael.Op Ic if Ar condition
268*43083Scael.Cx
26919716SmckusickStop execution when the given line is reached, procedure or function
27019716Smckusickcalled, variable changed, or condition true.
271*43083Scael.Dp Cx Ic status
272*43083Scael.Cx \&\ \&
273*43083Scael.Op Ic \&> Ar filename
274*43083Scael.Cx
275*43083ScaelPrint out the currently active
276*43083Scael.Ic trace
277*43083Scaeland
278*43083Scael.Ic stop
279*43083Scaelcommands.
280*43083Scael.Dp Cx Ic delete
281*43083Scael.Cx \&\ \&
282*43083Scael.Ar command-number ...
283*43083Scael.Cx
28419720SmckusickThe traces or stops corresponding to the given numbers are removed.
28519716SmckusickThe numbers associated with traces and stops are printed by
286*43083Scaelthe
287*43083Scael.Ic status
288*43083Scaelcommand.
289*43083Scael.Dp Cx Ic catch
290*43083Scael.Cx \&\ \&
291*43083Scael.Ar number
292*43083Scael.Cx
293*43083Scael.Dp Cx Ic catch
294*43083Scael.Cx \&\ \&
295*43083Scael.Ar signal-name
296*43083Scael.Cx
297*43083Scael.Dp Cx Ic ignore
298*43083Scael.Cx \&\ \&
299*43083Scael.Ar number
300*43083Scael.Cx
301*43083Scael.Dp Cx Ic ignore
302*43083Scael.Cx \&\ \&
303*43083Scael.Ar signal-name
304*43083Scael.Cx
30519720SmckusickStart or stop trapping a signal before it is sent
30619716Smckusickto the program.
30719716SmckusickThis is useful when a program being debugged
30819716Smckusickhandles signals such as interrupts.
30919720SmckusickA signal may be specified by number or by a name
31019720Smckusick(e.g., SIGINT).
31119720SmckusickSignal names are case insensitive and the ``SIG'' prefix is optional.
31219720SmckusickBy default all signals are trapped except SIGCONT, SIGCHILD,
31319716SmckusickSIGALRM and SIGKILL.
314*43083Scael.Dp Cx Ic cont
315*43083Scael.Cx \&\ \&
316*43083Scael.Ar integer
317*43083Scael.Cx
318*43083Scael.Dp Cx Ic cont
319*43083Scael.Cx \&\ \&
320*43083Scael.Ar signal-name
321*43083Scael.Cx
32219716SmckusickContinue execution from where it stopped.
32319720SmckusickIf a signal is specified, the process continues as though
32419720Smckusickit received the signal.
32519720SmckusickOtherwise, the process is continued as though it had not been stopped.
326*43083Scael.Pp
32719716SmckusickExecution cannot be continued if the process has ``finished'',
32819716Smckusickthat is, called the standard procedure ``exit''.
329*43083Scael.Nm Dbx
330*43083Scaeldoes not allow the process to exit, thereby
33119716Smckusickletting the user to examine the program state.
332*43083Scael.Dp Ic step
33319716SmckusickExecute one source line.
334*43083Scael.Dp Ic next
33519716SmckusickExecute up to the next source line.
336*43083ScaelThe difference between this and
337*43083Scael.Ic step
338*43083Scaelis that
33919716Smckusickif the line contains a call to a procedure or function
340*43083Scaelthe
341*43083Scael.Ic step
342*43083Scaelcommand will stop at the beginning of that
343*43083Scaelblock, while the
344*43083Scael.Ic next
345*43083Scaelcommand will not.
346*43083Scael.Dp Cx Ic return
347*43083Scael.Cx \&\ \&
348*43083Scael.Op Ar procedure
349*43083Scael.Cx
350*43083ScaelContinue until a return to
351*43083Scael.Ar procedure
352*43083Scaelis executed, or
35319720Smckusickuntil the current procedure returns if none is specified.
354*43083Scael.Dp Cx Ic call
355*43083Scael.Cx \&\ \&
356*43083Scael.Ar procedure (parameters )
357*43083Scael.Cx
35819720SmckusickExecute the object code associated with the named procedure or function.
359*43083Scael.Dp
360*43083Scael.Ss Printing Variables and Expressions
36119720SmckusickNames are resolved first using the static scope of the current function,
36219720Smckusickthen using the dynamic scope if the name is not defined
36319720Smckusickin the static scope.
36419720SmckusickIf static and dynamic searches do not yield a result,
36519720Smckusickan arbitrary symbol is chosen and
366*43083Scaelthe message
367*43083Scael.Cx ``
368*43083Scael.Op using Ar qualified name
369*43083Scael.Cx \'\'
370*43083Scael.Cx
371*43083Scaelis printed.
37219720SmckusickThe name resolution procedure may be overridden by qualifying an identifier
373*43083Scaelwith a block name, e.g.,
374*43083Scael.Cx ``
375*43083ScaelAr module.variable
376*43083Scael.Cx \'\'.
377*43083Scael.Cx
37819720SmckusickFor C, source files are treated as modules named
37919720Smckusickby the file name without ``.c''.
380*43083Scael.Pp
38119720SmckusickExpressions are specified with an approximately
38219720Smckusickcommon subset of C and Pascal (or equivalently Modula-2) syntax.
38319720SmckusickIndirection can be denoted using either a prefix ``*'' or
38419720Smckusicka postfix ``^'' and
385*43083Scaelarray expressions are subscripted by brackets
386*43083Scael.Cx (``
387*43083Scael.Op
388*43083Scael.Cx \'\').
389*43083Scael.Cx
39019716SmckusickThe field reference operator (``.'') can be used with pointers
391*43083Scaelas well as records, making the C operator ``\->'' unnecessary
39219716Smckusick(although it is supported).
393*43083Scael.Pp
39419720SmckusickTypes of expressions are checked;
39519720Smckusickthe type of an expression may be overridden
396*43083Scaelby using
397*43083Scael.Cx ``
398*43083Scael.Ar type-name (expression)
399*43083Scael.Cx \'\'.
400*43083Scael.Cx
40119720SmckusickWhen there is no corresponding named type
402*43083Scaelthe special constructs
403*43083Scael.Cx ``&
404*43083Scael.Ar type-name
405*43083Scael.Cx \'\'
406*43083Scael.Cx
407*43083Scaeland
408*43083Scael.Cx ``$$
409*43083Scael.Ar tag-name
410*43083Scael.Cx \'\'
411*43083Scael.Cx
41219720Smckusickcan be used to represent a pointer to a named type or C structure tag.
413*43083Scael.Dw Fl
414*43083Scael.Di L
415*43083Scael.Dp Cx Ic assign
416*43083Scael.Cx \&\ \&
417*43083Scael.Ar variable
418*43083Scael.Ic =
419*43083Scael.Ar expression
420*43083Scael.Cx
42119720SmckusickAssign the value of the expression to the variable.
422*43083Scael.Dp Cx Ic dump
423*43083Scael.Cx \&\ \&
424*43083Scael.Op Ar procedure
425*43083Scael.Cx \&\ \&
426*43083Scael.Op Ic > Ar filename
427*43083Scael.Cx
42819720SmckusickPrint the names and values of variables in the given procedure,
42919720Smckusickor the current one if none is specified.
43019720SmckusickIf the procedure given is ``.'', then the all active variables
43119720Smckusickare dumped.
432*43083Scael.Dp Cx Ic print
433*43083Scael.Cx \&\ \&
434*43083Scael.Ar expression
435*43083Scael.Cx \&\ \&
436*43083Scael.Op Ic \&, Ar expression ...
437*43083Scael.Cx
43819720SmckusickPrint out the values of the expressions.
439*43083Scael.Dp Cx Ic whatis
440*43083Scael.Cx \&\ \&
441*43083Scael.Ar name
442*43083Scael.Cx
44319716SmckusickPrint the declaration of the given name, which may be qualified
44419716Smckusickwith block names as above.
445*43083Scael.Dp Cx Ic which
446*43083Scael.Cx \&\ \&
447*43083Scael.Ar identifier
448*43083Scael.Cx
44919716SmckusickPrint the full qualification of the given identifer, i.e.
45019716Smckusickthe outer blocks that the identifier is associated with.
451*43083Scael.Dp Cx Ic up
452*43083Scael.Cx \&\ \&
453*43083Scael.Op Ar count
454*43083Scael.Cx
455*43083Scael.Dp Cx Ic down
456*43083Scael.Cx \&\ \&
457*43083Scael.Op Ar count
458*43083Scael.Cx
45919720SmckusickMove the current function, which is used for resolving names,
460*43083Scaelup or down the stack
461*43083Scael.Ar count
462*43083Scaellevels.
463*43083ScaelThe default
464*43083Scael.Ar count
465*43083Scaelis 1.
466*43083Scael.Dp Ic where
46719720SmckusickPrint out a list of the active procedures and function.
468*43083Scael.Dp Cx Ic whereis
469*43083Scael.Cx \&\ \&
470*43083Scael.Ar identifier
471*43083Scael.Cx
47219716SmckusickPrint the full qualification of all the symbols whose
47319716Smckusickname matches the given identifier.
47419716SmckusickThe order in which the symbols are printed is not meaningful.
475*43083Scael.Ss Accessing Source Files
476*43083Scael.Pp
477*43083Scael.Dp Cx Ar /regular expression
478*43083Scael.Op /
479*43083Scael.Cx
480*43083Scael.Dp Cx Ar ?regular expression
481*43083Scael.Op ?
482*43083Scael.Cx
48319720SmckusickSearch forward or backward in the current source file
48419720Smckusickfor the given pattern.
485*43083Scael.Dp Cx Ic edit
486*43083Scael.Cx \&\ \&
487*43083Scael.Op Ar filename
488*43083Scael.Cx
489*43083Scael.Dp Cx Ic edit
490*43083Scael.Cx \&\ \&
491*43083Scael.Ar procedure/function-name
492*43083Scael.Cx
493*43083ScaelInvoke an editor on
494*43083Scael.Ar filename
495*43083Scaelor the current source file if none
49619716Smckusickis specified.
497*43083ScaelIf a
498*43083Scael.Ar procedure
499*43083Scaelor
500*43083Scael.Ar function
501*43083Scaelname is specified,
50219716Smckusickthe editor is invoked on the file that contains it.
50319716SmckusickWhich editor is invoked by default depends on the installation.
50419716SmckusickThe default can be overridden by setting the environment variable
505*43083Scael.Ev EDITOR
506*43083Scaelto the name of the desired editor.
507*43083Scael.Dp Cx Ic file
508*43083Scael.Cx \&\ \&
509*43083Scael.Op Ar filename
510*43083Scael.Cx
511*43083ScaelChange the current source file name to
512*43083Scael.Ar filename  .
51319716SmckusickIf none is specified then the current source file name is printed.
514*43083Scael.Dp Cx Ic func
515*43083Scael.Cx \&\ \&
516*43083Scael.Op Ar procedure/function
517*43083Scael.Cx
51819716SmckusickChange the current function.
51919716SmckusickIf none is specified then print the current function.
52019716SmckusickChanging the current function implicitly changes the current source file
52119716Smckusickto the one that contains the function; it also changes the current scope
52219716Smckusickused for name resolution.
523*43083Scael.Dp Cx Ic list
524*43083Scael.Cx \&\ \&
525*43083Scael.Op Ar source-line-number Op Ic \&, Ar source-line-number
526*43083Scael.Cx
527*43083Scael.Dp Cx Ic list
528*43083Scael.Cx \&\ \&
529*43083Scael.Ar procedure/function
530*43083Scael.Cx
53119716SmckusickList the lines in the current source file from the first line number to
53219716Smckusickthe second inclusive.
53319716SmckusickIf no lines are specified, the next 10 lines are listed.
53419716SmckusickIf the name of a procedure or function is given
535*43083Scaellines
536*43083Scael.Ar n-k
537*43083Scaelto
538*43083Scael.Ar n +k
539*43083Scaelare listed where
540*43083Scael.Ar n
541*43083Scaelis the first statement
542*43083Scaelin the procedure or function and
543*43083Scael.Ar k
544*43083Scaelis small.
545*43083Scael.Dp Cx Ic use
546*43083Scael.Cx \&\ \&
547*43083Scael.Ar directory-list
548*43083Scael.Cx
54919716SmckusickSet the list of directories to be searched
55019716Smckusickwhen looking for source files.
551*43083Scael.Dp
552*43083Scael.Ss Command Aliases and Variables
553*43083Scael.Dw Fl
554*43083Scael.Di L
555*43083Scael.Dp Cx Ic alias
556*43083Scael.Cx \&\ \&
557*43083Scael.Ar name
558*43083Scael.Cx \&\ \&
559*43083Scael.Ar name
560*43083Scael.Cx
561*43083Scael.Dp Cx Ic alias
562*43083Scael.Cx \&\ \&
563*43083Scael.Ar name
564*43083Scael.Cx \&\ \&
565*43083Scael.Ar string
566*43083Scael.Cx
567*43083Scael.Dp Cx Ic alias
568*43083Scael.Cx \&\ \&
569*43083Scael.Ar name (parameters)
570*43083Scael.Cx \&\ \&
571*43083Scael.Cx ``
572*43083Scael.Ar string
573*43083Scael.Cx \'\'
574*43083Scael.Cx
57519720SmckusickWhen commands are processed,
576*43083Scaeldbx first checks to see if the word
57719720Smckusickis an alias for either a command or a string.
578*43083ScaelIf it is an alias, then dbx treats the input as though
57919720Smckusickthe corresponding string (with values substituted for any parameters)
58019720Smckusickhad been entered.
58119720SmckusickFor example,
58219720Smckusickto define an alias ``rr'' for the command ``rerun'',
58319720Smckusickone can say
584*43083Scael.Pp
585*43083Scael.Dl alias rr rerun
586*43083Scael.Pp
58719720SmckusickTo define an alias called ``b'' that sets a stop at a particular line
58819720Smckusickone can say
589*43083Scael.Pp
590*43083Scael.Dl alias b(x) ``stop at x''
591*43083Scael.Pp
59219720SmckusickSubsequently, the command ``b(12)'' will expand to ``stop at 12''.
593*43083Scael.Pp
594*43083Scael.Dp Cx Ic set
595*43083Scael.Ar name
596*43083Scael.Op \&= Ar expression
597*43083Scael.Cx
598*43083ScaelThe
599*43083Scael.Ic set
600*43083Scaelcommand defines values for debugger variables.
60119720SmckusickThe names of these variables cannot conflict with names in the program
60219720Smckusickbeing debugged, and are expanded to the corresponding expression
60319720Smckusickwithin other commands.
60419720SmckusickThe following variables have a special meaning:
605*43083Scael.Dw Ds
606*43083Scael.Di L
607*43083Scael.Dp Li $frame
608*43083ScaelSetting this variable to an address causes dbx to use the stack frame
60919720Smckusickpointed to by the address for
61019720Smckusickdoing stack traces and accessing local variables.
61119720SmckusickThis facility is of particular use for kernel debugging.
612*43083Scael.Dp Li $hexchars
613*43083Scael.Dp Li $hexints
614*43083Scael.Dp Li $hexoffsets
615*43083Scael.Dp Li $hexstrings
616*43083ScaelWhen set, dbx prints out
61719720Smckusickout characters, integers, offsets from registers, or character pointers
61819720Smckusickrespectively in hexadecimal.
619*43083Scael.Dp Li $listwindow
62019720SmckusickThe value of this variable specifies the number
621*43083Scaelof lines to list around a function or when the
622*43083Scael.Ic list
623*43083Scaelcommand
62419720Smckusickis given without any parameters.
62519720SmckusickIts default value is 10.
626*43083Scael.Dp Li $mapaddrs
627*43083ScaelSetting (unsetting) this variable causes dbx to start (stop)
62819720Smckusickmapping addresses.
62919720SmckusickAs with ``$frame'', this is useful for kernel debugging.
630*43083Scael.Dp Li $unsafecall
631*43083Scael.Dp Li $unsafeassign
63225878SdonnWhen ``$unsafecall'' is set,
63325878Sdonnstrict type checking is turned off for arguments to
634*43083Scaelsubroutine or function calls (
635*43083Scael.Ar e .g .
636*43083Scaelin the
637*43083Scael.Ic call
638*43083Scaelstatement).
63925878SdonnWhen ``$unsafeassign'' is set,
64025878Sdonnstrict type checking between the two sides
641*43083Scaelof an
642*43083Scael.Ic assign
643*43083Scaelstatement is turned off.
64425878SdonnThese variables should be used only with great care,
645*43083Scaelbecause they severely limit dbx's usefulness
64625878Sdonnfor detecting errors.
647*43083Scael.Dp
648*43083Scael.Dp Cx Ic unalias
649*43083Scael.Cx \&\ \&
650*43083Scael.Ar name
651*43083Scael.Cx
65219720SmckusickRemove the alias with the given name.
653*43083Scael.Dp Cx Ic unset
654*43083Scael.Cx \&\ \&
655*43083Scael.Ar name
656*43083Scael.Cx
657*43083ScaelDelete the debugger variable associated with
658*43083Scael.Ar name  .
659*43083Scael.Dp
660*43083Scael.Ss Machine Level Commands
661*43083Scael.Dw Fl
662*43083Scael.Di L
663*43083Scael.Dp Cx Ic tracei
664*43083Scael.Cx \&\ \&
665*43083Scael.Op Ar address
666*43083Scael.Cx \&\ \&
667*43083Scael.Op .Ic if Ar cond
668*43083Scael.Cx
669*43083Scael.Dp Cx Ic tracei
670*43083Scael.Cx \&\ \&
671*43083Scael.Op Ar variable
672*43083Scael.Cx \&\ \&
673*43083Scael.Op Ic at Ar address
674*43083Scael.Cx \&\ \&
675*43083Scael.Op Ic if Ar cond
676*43083Scael.Cx
677*43083Scael.Dp Cx Ic stopi
678*43083Scael.Cx \&\ \&
679*43083Scael.Op Ar address
680*43083Scael.Cx \&\ \&
681*43083Scael.Op Ic if Ar cond
682*43083Scael.Cx
683*43083Scael.Dp Cx Ic stopi
684*43083Scael.Cx \&\ \&
685*43083Scael.Op Ic at
686*43083Scael.Cx \&\ \&
687*43083Scael.Op Ar address
688*43083Scael.Cx \&\ \&
689*43083Scael.Op Ic if Ar cond
690*43083Scael.Cx
69119716SmckusickTurn on tracing or set a stop using a machine instruction address.
692*43083Scael.Dp Ic stepi
693*43083Scael.Dp Ic nexti
694*43083ScaelSingle step as in
695*43083Scael.Ic step
696*43083Scaelor
697*43083Scael.Ic next  ,
698*43083Scaelbut do a single instruction
69919716Smckusickrather than source line.
700*43083Scael.Dp Cx Ar address
701*43083Scael.Cx \&,
702*43083Scael.Ar address
703*43083Scael.Cx \&/
704*43083Scael.Op Ar mode
705*43083Scael.Cx
706*43083Scael.Dp Cx Ar address
707*43083Scael.Cx \&/
708*43083Scael.Op Ar count
709*43083Scael.Op Ar mode
710*43083Scael.Cx
711*43083ScaelPrint the contents of memory starting at the first
712*43083Scael.Ar address
713*43083Scaeland continuing up to the second
714*43083Scael.Ar address
715*43083Scaelor until
716*43083Scael.Ar count
717*43083Scaelitems are printed.
71819720SmckusickIf the address is ``.'', the address following the one
71919716Smckusickprinted most recently is used.
720*43083ScaelThe
721*43083Scael.Ar mode
722*43083Scaelspecifies how memory is to be printed;
72319716Smckusickif it is omitted the previous mode specified is used.
72419716SmckusickThe initial mode is ``X''.
72519716SmckusickThe following modes are supported:
726*43083Scael.Dw Cm
727*43083Scael.Dp Cm i
72819716Smckusickprint the machine instruction
729*43083Scael.Dp Cm d
73019716Smckusickprint a short word in decimal
731*43083Scael.Dp Cm D
73219716Smckusickprint a long word in decimal
733*43083Scael.Dp Cm o
73419716Smckusickprint a short word in octal
735*43083Scael.Dp Cm O
73619716Smckusickprint a long word in octal
737*43083Scael.Dp Cm x
73819716Smckusickprint a short word in hexadecimal
739*43083Scael.Dp Cm X
74019716Smckusickprint a long word in hexadecimal
741*43083Scael.Dp Cm b
74219716Smckusickprint a byte in octal
743*43083Scael.Dp Cm c
74419716Smckusickprint a byte as a character
745*43083Scael.Dp Cm s
74619716Smckusickprint a string of characters terminated by a null byte
747*43083Scael.Dp Cm f
74819716Smckusickprint a single precision real number
749*43083Scael.Dp Cm g
75019716Smckusickprint a double precision real number
751*43083Scael.Dp
752*43083Scael.Pp
75319716SmckusickSymbolic addresses are specified by preceding the name with an ``&''.
75419716SmckusickRegisters are denoted by ``$rN'' where N is the number of the register.
75519716SmckusickAddresses may be expressions made up of other addresses and
75619716Smckusickthe operators ``+'', ``-'', and indirection (unary ``*'').
757*43083Scael.Dp
758*43083Scael.Ss Miscellaneous Commands
759*43083Scael.Tw Ic
760*43083Scael.Tp Ic gripe
761*43083ScaelInvoke a mail program to send a message to the person in charge of
762*43083Scael.Nm dbx  .
763*43083Scael.Tp Ic help
764*43083ScaelPrint out a synopsis of
765*43083Scael.Nm dbx
766*43083Scaelcommands.
767*43083Scael.Tp Ic quit
768*43083ScaelExit
769*43083Scael.Nm dbx  .
770*43083Scael.Tp Cx Ic sh
771*43083Scael.Cx \&\ \&
772*43083Scael.Ar command-line
773*43083Scael.Cx
77419716SmckusickPass the command line to the shell for execution.
77519716SmckusickThe SHELL environment variable determines which shell is used.
776*43083Scael.Tp Cx Ic source
777*43083Scael.Cx \&\ \&
778*43083Scael.Ar filename
779*43083Scael.Cx
780*43083ScaelRead
781*43083Scael.Nm dbx
782*43083Scaelcommands from the given
783*43083Scael.Ar filename  .
784*43083Scael.Tp
785*43083Scael.Sh ENVIRONMENT
786*43083Scael.Nm Dbx
787*43083Scaelchecks these environment variables:
788*43083Scael.Ds I
789*43083ScaelEDITOR
790*43083ScaelHOME
791*43083ScaelPATH
792*43083ScaelSHELL
793*43083Scael.De
794*43083Scael.Sh FILES
795*43083Scael.Dw .dbxinit
796*43083Scael.Di L
797*43083Scael.Dp Pa a.out
79819716Smckusickobject file
799*43083Scael.Dp Pa .dbxinit
80019716Smckusickinitial commands
801*43083Scael.Dp
802*43083Scael.Sh SEE ALSO
803*43083Scael.Xr cc 1 ,
804*43083Scael.Xr mod l ,
805*43083Scael.Xr f77 1 ,
806*43083Scael.Xr pc 1
807*43083Scael.Sh HISTORY
808*43083Scael.Nm Dbx
809*43083Scaelappeared in 4.2 BSD.
810*43083Scael.Sh BUGS
811*43083Scael.Nm Dbx
812*43083Scaelsuffers from the same ``multiple include'' malady as did
813*43083Scael.Nm sdb  .
81419716SmckusickIf you have a program consisting of a number of object files
81519716Smckusickand each is built from source files that include header files,
81619716Smckusickthe symbolic information for the header files is replicated in
81719716Smckusickeach object file.
81819716SmckusickSince about one debugger start-up is done for each link,
819*43083Scaelhaving the linker
820*43083Scael.Xr ld 1
821*43083Scaelre-organize the symbol information
82219720Smckusickwould not save much time, though it would reduce some of the
82319716Smckusickdisk space used.
824*43083Scael.Pp
82519720SmckusickThis problem is an artifact of the unrestricted semantics
82619716Smckusickof #include's in C; for example an include file can contain
82719716Smckusickstatic declarations that are separate entities for each file
82819716Smckusickin which they are included.
82919720SmckusickHowever, even with Modula-2 there is a substantial amount of duplication
83019720Smckusickof symbol information necessary for inter-module type checking.
831*43083Scael.Pp
83225878SdonnSome problems remain with the support for individual languages.
83325878SdonnFortran problems include:
83425878Sdonninability to assign to logical, logical*2, complex
83525878Sdonnand double complex variables;
83625878Sdonninability to represent parameter constants
83725878Sdonnwhich are not type integer or real;
83825878Sdonnpeculiar representation for the values of dummy procedures
83925878Sdonn(the value shown for a dummy procedure is actually
84025878Sdonnthe first few bytes of the procedure text;
84125878Sdonnto find the location of the procedure,
84225878Sdonnuse ``&'' to take the address of the variable).
843