All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the University of California, Berkeley. The name of the
University may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
@(#)dbx.1 6.3 (Berkeley) 05/23/89
The object file contains a symbol table that includes the name of the all the source files translated by the compiler to create it. These files are available for perusal while using the debugger.
If a file named ``core'' exists in the current directory or a coredump file is specified, \*(dB can be used to examine the state of the program when it faulted.
If the file ``.\*(dBinit'' exists in the current directory then the debugger commands in it are executed. \*(DB also checks for a ``.\*(dBinit'' in the user's home directory if there isn't one in the current directory.
The command line options and their meanings are: .nr In 8 \fB-r \c Execute objfile immediately. If it terminates successfully \*(dB exits. Otherwise the reason for termination will be reported and the user offered the option of entering the debugger or letting the program fault. \*(DB will read from ``/dev/tty'' when -r is specified and standard input is not a terminal. \fB-i \c Force \*(dB to act as though standard input is a terminal. \fB-k \c Map memory addresses, useful for kernel debugging. \fB-I dir \c Add dir to the list of directories that are searched when looking for a source file. Normally \*(dB looks for source files in the current directory and in the directory where objfile is located. The directory search path can also be set with the use command. \fB-c file \c Execute the \*(dB commands in the file before reading from standard input.
Unless -r is specified, \*(dB just prompts and waits for a command. Execution and Tracing Commands
run [args] [< filename] [> filename] .ns
rerun [args] [< filename] [> filename] Start executing objfile, passing args as command line arguments; < or > can be used to redirect input or output in the usual manner. When rerun is used without any arguments the previous argument list is passed to the program; otherwise it is identical to run. If objfile has been written since the last time the symbolic information was read in, \*(dB will read in the new information.
trace [in procedure/function] [if condition] .ns
trace source-line-number [if condition] .ns
trace procedure/function [in procedure/function] [if condition] .ns
trace expression at source-line-number [if condition] .ns
trace variable [in procedure/function] [if condition] Have tracing information printed when the program is executed. A number is associated with the command that is used to turn the tracing off (see the delete command). The first argument describes what is to be traced. If it is a source-line-number, then the line is printed immediately prior to being executed. Source line numbers in a file other than the current one must be preceded by the name of the file in quotes and a colon, e.g. "mumble.p":17. If the argument is a procedure or function name then every time it is called, information is printed telling what routine called it, from what source line it was called, and what parameters were passed to it. In addition, its return is noted, and if it's a function then the value it is returning is also printed. If the argument is an expression with an at clause then the value of the expression is printed whenever the identified source line is reached. If the argument is a variable then the name and value of the variable is printed whenever it changes. Execution is substantially slower during this form of tracing. If no argument is specified then all source lines are printed before they are executed. Execution is substantially slower during this form of tracing. The clause ``in procedure/function'' restricts tracing information to be printed only while executing inside the given procedure or function. Condition is a boolean expression and is evaluated prior to printing the tracing information; if it is false then the information is not printed.
Execution cannot be continued if the process has ``finished'', that is, called the standard procedure ``exit''. \*(DB does not allow the process to exit, thereby letting the user to examine the program state.
Printing Variables and Expressions
Names are resolved first using the static scope of the current function, then using the dynamic scope if the name is not defined in the static scope. If static and dynamic searches do not yield a result, an arbitrary symbol is chosen and the message ``[using qualified name]'' is printed. The name resolution procedure may be overridden by qualifying an identifier with a block name, e.g., ``module.variable''. For C, source files are treated as modules named by the file name without ``.c''.
Expressions are specified with an approximately common subset of C and Pascal (or equivalently Modula-2) syntax. Indirection can be denoted using either a prefix ``*'' or a postfix ``^'' and array expressions are subscripted by brackets (``[ ]''). The field reference operator (``.'') can be used with pointers as well as records, making the C operator ``->'' unnecessary (although it is supported).
Types of expressions are checked; the type of an expression may be overridden by using ``type-name(expression)''. When there is no corresponding named type the special constructs ``&type-name'' and ``$$tag-name'' can be used to represent a pointer to a named type or C structure tag.
Accessing Source Files
Command Aliases and Variables
alias name name .ns
alias name ``string'' .ns
alias name (parameters) ``string'' When commands are processed, \*(dB first checks to see if the word is an alias for either a command or a string. If it is an alias, then \*(dB treats the input as though the corresponding string (with values substituted for any parameters) had been entered. For example, to define an alias ``rr'' for the command ``rerun'', one can say alias rr rerun To define an alias called ``b'' that sets a stop at a particular line one can say alias b(x) ``stop at x'' Subsequently, the command ``b(12)'' will expand to ``stop at 12''.
set name [= expression] The set command defines values for debugger variables. The names of these variables cannot conflict with names in the program being debugged, and are expanded to the corresponding expression within other commands. The following variables have a special meaning: $frame
Setting this variable to an address causes \*(dB to use the stack frame pointed to by the address for doing stack traces and accessing local variables. This facility is of particular use for kernel debugging. $hexchars $hexints $hexoffsets $hexstrings
When set, \*(dB prints out out characters, integers, offsets from registers, or character pointers respectively in hexadecimal. $listwindow
The value of this variable specifies the number of lines to list around a function or when the list command is given without any parameters. Its default value is 10. $mapaddrs
Setting (unsetting) this variable causes \*(dB to start (stop) mapping addresses. As with ``$frame'', this is useful for kernel debugging. $unsafecall $unsafeassign
When ``$unsafecall'' is set, strict type checking is turned off for arguments to subroutine or function calls (e.g. in the call statement). When ``$unsafeassign'' is set, strict type checking between the two sides of an assign statement is turned off. These variables should be used only with great care, because they severely limit \*(dB's usefulness for detecting errors.
unalias name Remove the alias with the given name.
unset name Delete the debugger variable associated with name.
Machine Level Commands
tracei [address] [if cond] .ns
tracei [variable] [at address] [if cond] .ns
stopi [address] [if cond] .ns
stopi [at] [address] [if cond] Turn on tracing or set a stop using a machine instruction address.
stepi .ns
nexti Single step as in step or next, but do a single instruction rather than source line.
address ,address/ [mode] .ns
address / [count] [mode] Print the contents of memory starting at the first address and continuing up to the second address or until count items are printed. If the address is ``.'', the address following the one printed most recently is used. The mode specifies how memory is to be printed; if it is omitted the previous mode specified is used. The initial mode is ``X''. The following modes are supported: .nr In 5 \fBi \c print the machine instruction \fBd \c print a short word in decimal \fBD \c print a long word in decimal \fBo \c print a short word in octal \fBO \c print a long word in octal \fBx \c print a short word in hexadecimal \fBX \c print a long word in hexadecimal \fBb \c print a byte in octal \fBc \c print a byte as a character \fBs \c print a string of characters terminated by a null byte \fBf \c print a single precision real number \fBg \c print a double precision real number
Symbolic addresses are specified by preceding the name with an ``&''. Registers are denoted by ``$rN'' where N is the number of the register. Addresses may be expressions made up of other addresses and the operators ``+'', ``-'', and indirection (unary ``*'').
Miscellaneous Commands
source filename Read \*(dB commands from the given filename.
This problem is an artifact of the unrestricted semantics of #include's in C; for example an include file can contain static declarations that are separate entities for each file in which they are included. However, even with Modula-2 there is a substantial amount of duplication of symbol information necessary for inter-module type checking.
Some problems remain with the support for individual languages. Fortran problems include: inability to assign to logical, logical*2, complex and double complex variables; inability to represent parameter constants which are not type integer or real; peculiar representation for the values of dummy procedures (the value shown for a dummy procedure is actually the first few bytes of the procedure text; to find the location of the procedure, use ``&'' to take the address of the variable).