Basic dbx Commands

dbx is a debugger that allows you to step through a program viewing lines of code as they are executed and variable values as they change.

Preparing to use dbx

bullet Compile your program using the –g option of CC
bullet Example:

CC myfile.cpp –g

bullet This instructs the compiler to include debug information in your a.out file.
bullet From the directory where your source filess are found, enter: dbx a.out
bullet You will see a bunch of text with new features of dbx and finally you will get the (dbx) prompt.
bullet To get rid of this stuff when you start dbx, create a file (using vi, for instance) in your home directory called .dbxrc that contains the one line:

dbxenv suppress_startup_message 4.0

Basic dbx commands

****Command**** **********What it does************
list Displays a chunk of your program listing.
list + Displays the next chunk of your listing
list – Displays the previous chunk of the listing
list n,m List lines n through m
run This causes dbx to reset your program and run it from the beginning. It will continue until the end of the program or until it reaches a breakpoint
stop at n This sets a breakpoint at line n in a program, i.e. a point where execution of the program pauses and waits for action from you.
clear Clears the breakpoint (if any) at the current line
delete –all Clears all breakpoints
next Executes the current line of the program stepping over any function calls in the statement
step Executes the current line of the program stepping into any function calls
cont Continues execution of a program until the next breakpoint
dump Shows the current value of all local variables
print var Shows the current value of var
quit Exit the debugger
help command Gives detailed information on the purpose and syntax of a dbx command
commands Gives one-line description of all dbx commands (there are a lot)
check -leaks Helps detect memory leaks due to improper memory management.

 

02/13/02