dbx - source-level debugger
dbx [ -c dbx cmd ] [ -e ] [ -Idir ] [ -kbd ] [ -q ] [ -r ] [ -s startup ] [ -sr startup ] [ execfile [ corefile | process-id ] ] [ -C ] [ -notempl ]
Description
bx is a utility for source-level debugging and execution of programs
written in C++, ANSI C, FORTRAN , and Pascal. dbx accepts the same
commands as debugger(1), but uses a standard terminal (tty) interface.
For a full overview of dbx and Debugger features see the Debugging a
Program user guide.
execfile is an executable file, produced by a
compiler, with the -g option to include a symbol table. This symbol
table contains the names of all the source files used to create the
execfile (all of which may be browsed), as well as wide range of
debugging information. Debugging support is limited for any parts of
a program not compiled with the -g option.
Initially, symbol
table information is stored piecemeal in each of the object files the
compiler creates. (If compilation does not create an object file, all
debugging information is stored in the execfile . ) Distributing the
debugging information in the object files allows dbx to read and load
debugging information as it is needed. This feature is called
Auto-Read. If you need to move object files from their original
location, make sure that dbx knows where to find them. (See the use
and pathmap commands.) If it is not feasible to keep program .o files
around, you can disable Auto-Read by compiling using the - xs option.
-xs instructs the compiler to have the linker place all debugging
information in the program executable.
If, when starting dbx , no
execfile is specified, use the debug command to specify a program to
be debugged. If you know a process ID but not the execfile , you can
use the (dash) as the execfile and give the process ID option to
attach the process to dbx .
If a corefile argument is specified, you can use dbx to examine the
state of the program when the core file was produced.
dbx
executes commands in the .dbxinit file immediately before it reads the
symbol table. dbx first searches for .dbxinit in the current
directory. If .dbxinit does not exist in the current directory, dbx
looks in the user's home directory.
Runtime Checking (RTC) is a fully integrated feature of
the dbx ; it uses the full capabilities of the dbx including setting
breakpoints and examining variables. With RTC , you can automatically
detect runtime errors in an application during the development
phase. Compiling with the -g flag provides source
line number correlation in the error messages. RTC can check programs
compiled with the optimization - O flag. You do not have to recompile,
relink, or modify the makefile to use RTC.
For proper operation, RTC requires dynamic linking with libc , use of
the standard libc malloc/free/realloc , and does not support
attachment to a running process.
To use RTC , start dbx with the
-C option or either set the environment variable SW_RTC or specify the
-C option each time you start dbx.
Options
Some of the "useful" options are the following:
- -c dbx cmd Execute dbx cmd after initialization. For more than
one dbx cmd , use double quotes around the string of commands,
separating each with a semi-colon.
- -I dir Add dir to the list of directories in which to search for
a source file. dbx normally searches the current directory and the
directory where execfile is located. The directory search path can be
reset with the use command.
- -s startup Read initialization commands from the file named
startup instead of from .dbxinit.
- -sr startup Read initialization commands from the temporary file
named startup, instead of from .dbxinit and then remove startup.
Basic commands
The basic commands to know are: run, to run the program being debugged; where, to obtain a stack trace with line numbers; print, to display variables; and stop, to set breakpoints.
Other commands are the following:
- !! Execute previous command.
- ! num Execute command number num.
- ! - num Execute current command-number minus num
- ! str Execute most recent command starting with str
- assign var = exp
Assign the value of the exp to var
- debug -r | -clone
The -r option, if present, causes dbx to
retain all display's, trace's, when's, and stop's. If no -r option is
given, an implicit delete all and undisplay 0 is performed. The clone
option, if present, causes another dbx to begin execution, and thus
permits debugging more than one process at a time. -clone is valid
only if running under Debugger.
- debug -clone
Starts another dbx debugging nothing. Valid
only if running under Debugger.
Environment
dbx checks the environment variable
EDITOR for the name of the text editor to use with the edit
command.
See also