Previous Next Contents Index Doc Set Home

Modifying a Program State


This chapter focuses on dbx usage and commands that change your program or change the behavior of your program as compared to running it without dbx. It is important to understand which commands might make modifications to your program.

The chapter is divided into the following sections:

Basic Concepts

page 229

Using Commands

page 230

Basic Concepts

Your application might behave differently when run under dbx. Although dbx strives to minimize its impact on the child, you should be aware of the following:

Otherwise, see if running with adb or truss causes the same problems.

Also, dbx should impose minimal perturbation when it attaches to a running process.

Using Commands


The dbx assign command assigns a value to the exp to var. Using it in dbx permanently alters the value of var, which could modify your program.

assign var = exp


The dbx pop command pops a frame or frames from the stack:

Pop current frame

Pop num frames

Pop frames until specified frame number

pop num
pop -f num 

Any calls popped are reexecuted upon resumption, which may result in undesirable program changes. pop also calls destructors for objects local to the popped functions.


When you use the call command in dbx you call a procedure, and the procedure performs as specified:

call proc([params]) 

The procedure could modify something in your program.; dbx is actually making the call as if you had written it into your program source.


To print the value of the expression(s):

print exp, ...     

If an expression has a function call, the same considerations apply as with the call command. With C++, you should also be careful of unexpected side effects caused by overloaded operators.


The when command has a general syntax as follows:

when event-specification [modifier] {cmd ... ;}

When the event occurs, the cmds are executed.

When you get to a line or to a procedure, a command is performed. Depending upon which command is issued, this could alter your program state.


You can use fix to make on-the-fly changes to your program:


It is a very useful tool, but remember that fix recompiles modified source files and dynamically links the modified functions into the application.

Make sure to check the restrictions for fix and continue. See Chapter 10, "Using fix and continue."

cont at

This dbx command alters the order in which the program runs. Execution is continued at line line. id is required if the program is multithreaded.

cont at line id

This could change the outcome of the program.

Previous Next Contents Index Doc Set Home