[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
General Programming Concepts: Writing and Debugging Programs

Customizing the dbx Debugging Environment

You can customize the debugging environment by creating subcommand aliases and by specifying options in the .dbxinit file. You can read dbx subcommands from a file using the -c flag. The following sections contain more information about customization options.

Defining a New dbx Prompt

The dbx prompt is normally the name used to start the dbx program. If you specified /usr/ucb/dbx a.out on the command line, then the prompt is /usr/ucb/dbx.

You can change the prompt with the prompt subcommand, or by specifying a different prompt in the prompt line of the .dbxinit file. Changing the prompt in the .dbxinit file causes your prompt to be used instead of the default each time you initialize the dbx program.

For example, to initialize the dbx program with the debug prompt debug-->, enter the following line in your .dbxinit file:

prompt "debug-->"

Creating dbx Subcommand Aliases

You can build your own commands from the dbx primitive subcommand set. The following commands allow you to build a user alias from the arguments specified. All commands in the replacement string for the alias must be dbx primitive subcommands. You can then use your aliases in place of the dbx primitives.

The alias subcommand with no arguments displays the current aliases in effect; with one argument the command displays the replacement string associated with that alias.

alias [AliasName[ CommandName] ]

alias AliasName "CommandString"

alias AliasName (Parameter1, Parameter2, . . . ) "CommandString"

The first two forms of the alias subcommand are used to substitute the replacement string for the alias each time it is used. The third form of aliasing is a limited macro facility. Each parameter specified in the alias subcommand is substituted in the replacement string.

The following aliases and associated subcommand names are defaults:

attr attribute
bfth stop (in given thread at specified function)
blth stop (in given thread at specified source line)
c cont
cv condition
d delete
e edit
h help
j status
l list
m map
mu mutex
n next
p print
q quit
r run
s step
st stop
t where
th thread
x registers

You can remove an alias with the unalias command.

Using the .dbxinit File

Each time you begin a debugging session, the dbx program searches for special initialization files named .dbxinit, which contain lists of dbx subcommands to execute. These subcommands are executed before the dbx program begins to read subcommands from standard input. When the dbx command is started, it checks for a .dbxinit file in the user's current directory and in the user's $HOME directory. If a .dbxinit file exists, its subcommands run at the beginning of the debug session. If a .dbxinit file exists in both the home and current directories, then both are read in that order. Because the current directory .dbxinit file is read last, its subcommands can supercede those in the home directory.

Normally, the .dbxinit file contains alias subcommands, but it can contain any valid dbx subcommands. For example:

$ cat .dbxinit
alias si "stop in"
prompt "dbg-->"
$ dbx a.out
dbx version 3.1
Type 'help' for help.
reading symbolic information . . . 
dbg--> alias
si   stop in
t    where . . . 
dbg-->

Reading dbx Subcommands from a File

The -c invocation option and .dbxinit file provide mechanisms for executing dbx subcommands before reading from standard input. When the -c option is specified, the dbx program does not search for a .dbxinit file. Use the source subcommand to read dbx subcommands from a file once the debugging session has begun.

After executing the list of commands in the cmdfile file, the dbx program displays a prompt and waits for input.

You can also use the -c option to specify a list of subcommands to be executed when initially starting the dbx program.

Related Information

The dbx Symbolic Debug Program Overview

Using the dbx Debug Program

Displaying and Manipulating the Source File with the dbx debug Program

Examining Program Data

Debugging at the Machine Level with dbx


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]