DBX(1) — Unix Programmer’s Manual
NAME
dbx − debugger
SYNOPSIS
dbx [ options ] [ objfile [ coredump ] ]
DESCRIPTION
Dbx is a tool for source level debugging and execution of programs under UNIX. The objfile is an object file produced by a compiler, with the appropriate flag (usually −g) specified to produce symbol information in the object file. Currently, cc(1) and f77(1) produce the appropriate source information. In the future the Pascal compiler may also be able to generate source level information. The machine level facilities of dbx can be used on any program.
If no objfile is specified, dbx looks for a file named “a.out” in the current directory. The object file contains a symbol table which includes the names of 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, dbx can be used to examine the state of the program when it faulted.
If the file “.dbxinit” exists in the current directory, then the debugger commands in it are executed. Dbx also checks for “.dbxinit” in the user’s home directory if such a file does not exist in the current directory.
OPTIONS
−i Forces dbx to act as though standard input were a terminal.
−I dir Adds dir to the list of directories that are searched when looking for a source file. Normally dbx 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.
−r Execute objfile immediately. If it terminates successfully, dbx exits. Otherwise, the reason for termination will be reported and the user will be offered the option of entering the debugger or letting the program fault. Dbx will read from /dev/tty when −r is specified and standard input is not a terminal.
Unless −r is specified, dbx just prompts and waits for a command.
EXECUTION & TRACING COMMANDS
run [args] [< filename] [> filename]
Starts executing objfile, passing args as command line arguments; < or > can be used to redirect input or output in the usual manner. If objfile has been written since the last time the symbolic information was read in, dbx will read in the new information.
trace [in procedure/function] [if condition]
trace source-line-number [if condition]
trace procedure/function [in procedure/function] [if condition]
trace expression at source-line-number [if condition]
trace variable [in procedure/function] [if condition]
Prints tracing information 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., "filename.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. If it is 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.
stop if condition
stop at source-line-number [if condition]
stop in procedure/function [if condition]
stop variable [if condition]
Stops execution when the given line is reached, procedure or function is called, variable is changed, or condition is true.
status [> filename]
Prints out the currently active trace and stop commands.
delete command-number
Removes the trace or stop corresponding to the given number. The numbers associated with traces and stops are printed by the status command.
catch number
ignore number
Starts or stops trapping signal number before it is sent to the program. This is useful when a program being debugged handles signals such as interrupts. Initially all signals are trapped except SIGCONT, SIGCHILD, SIGALRM and SIGKILL.
contContinues execution from where it stopped. Execution cannot be continued if the process has “finished,” that is, called the standard procedure “exit.” Dbx does not allow the process to exit, thereby letting the user examine the program state.
stepExecute one source line.
nextExecute up to the next source line. The difference between this and step is as follows: if the line contains a call to a procedure or function, the step command will stop at the beginning of that block; the next command will not.
DISPLAYING & NAMING DATA
print expression [, expression ...]
Prints out the values of the expressions. Array expressions are always subscripted by brackets ( [ ] ). Variables having the same identifier as one in the current block may be referenced as block-name . variable . The field reference operator ( . ) can be used with pointers as well as records, making the C operator ( −> ) unnecessary (although it is supported). The construct typename(expression) can be used to print the expression out in the format of the named type.
whatis name
Prints the declaration of the given name, which may be qualified with block names as above.
which identifier
Prints the full qualification of the given identifier; i.e., the outer blocks with which the identifier is associated.
whereis identifier
Prints the full qualification of all the symbols whose name matches the given identifier. The order in which the symbols are printed is not meaningful.
assign variable = expression
set variable = expression
Assigns the value of the expression to the variable.
call procedure(parameters)
Executes the object code associated with the named procedure or function. Currently, calls to a procedure with a variable number of arguments are not possible. Also, string parameters are not passed properly for C.
Note: Not currently implemented.
where
Prints out a list of the active procedures and function.
dump [> filename]
Prints the names and values of all active variables.
ACCESSING SOURCE FILES
edit [filename]
edit procedure/function-name
Invokes an editor on filename or the current source file, if none is specified. If a procedure or function name is specified, the editor is invoked on the file that contains it. The default editor depends upon the installation. The default can be overridden by setting the environment variable EDITOR to the name of the desired editor.
file [filename]
Changes the current source file name to filename. If none is specified then the current source file name is printed.
func [procedure/function]
Changes the current function. If none is specified then prints the current function. Changing the current function implicitly changes the current source file to the one that contains the function. It also changes the current scope used for name resolution.
list [source-line-number [, source-line-number]]
list procedure/function
Lists the lines in the current source file from the first line number to the second, inclusive. If no lines are specified, the next ten lines are listed. If the name of a procedure or function is given, lines n−k to n+k are listed, where n is the first statement in the procedure or function and k is small.
use directory-list
Sets the list of directories to be searched when looking for source files.
MACHINE LEVEL COMMANDS
tracei [address] [if cond]
tracei [variable] [at address] [if cond]
stopi [address] [if cond]
stopi [at] [address] [if cond]
Turns on tracing or sets a stop using a machine instruction address.
stepi
nexti Single steps as in step or next, but does a single instruction rather than source line.
address ,address/ [mode]
[address] / [count] [mode]
Prints the contents of memory starting at the first address and continuing up to the second address or until count items are printed. If no address is specified, 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:
bPrints a byte in octal
cPrints a byte as a character
dPrints a short word in decimal
DPrints a long word in decimal
fPrints a single precision real number
gPrints a double precision real number
iPrints the machine instruction
oPrints a short word in octal
OPrints a long word in octal
sPrints a string of characters terminated by a null byte
xPrints a short word in hexadecimal
XPrints a long word in hexadecimal
Symbolic addresses are specified by preceding the name with & . Registers are denoted by $rN, in which N is the number of the register. Addresses may be expressions made up of other addresses and the operators + , - , and indirection (unary ∗).
MISCELLANEOUS COMMANDS
sh command-line
Passes the command line to the shell for execution. The SHELL environment variable determines which shell is used.
alias new-command-name old-command-name
Responds to new-command-name as though it were old-command-name.
helpPrints out a synopsis of dbx commands.
gripeInvokes a mail program to send a message to the person in charge of dbx.
source filename
Reads dbx commands from the given filename. Especially useful when the filename has been created by redirecting a status command from an earlier debugging session.
quitExit dbx.
FILES
a.out object file
.dbxinit initial commands
SEE ALSO
BUGS
Non-local gotos can cause some trace/stops to be missed. Most of the command names are too long. The alias facility helps, but is really quite weak. A history capability similar to that in csh would improve the situation.
Dbx suffers from the same “multiple include” malady as does sdb. If a program consists of a number of object files and each is built from source files that include header files, the symbolic information for the header files is replicated in each object file. Since roughly one debugger startup is done for each link, having the linker (ld) reorganize the symbol information would not save much time, though it would reduce some of the disk space used. The problem is an artifact of the unrestricted semantics of #includes in C. For example, an include file can contain static declarations that are separate entities for each file in which they are included.
4th Berkeley Distribution — 1 August 1985