Contained WithinFind More DocumentationFeatured Support Resources | Download this book in PDF (2163 KB)
Appendix A Modifying a Program StateThis appendix focuses on dbx usage and commands that change your program or change the behavior of your program when you run it under dbx, 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: Impacts of Running a Program Under dbxYou use dbx to observe a process, and the observation should not perturb the process. However, on occasion, you might drastically modify the state of the process. And sometimes plain observation can perturb execution and cause bug symptoms to come and go mysteriously. Your application might behave differently when run under dbx. Although dbx strives to minimize its impact on the program being debugged, you should be aware of the following:
Otherwise, determine whether running with adb or truss causes the same problems. To minimize perturbations imposed by dbx, try attaching to the application while it is running in its natural environment. Commands That Alter the State of the ProgramThe following commands might make modifications to your program: assign CommandThe assign command assigns the value of the expression to variable. Using it in dbx permanently alters the value of variable.
pop CommandThe pop command pops a frame or frames from the stack:
Any calls popped are re-executed upon resumption, which might result in unwanted program changes. pop also calls destructors for objects local to the popped functions. For more information, see pop Command. call CommandWhen you use the call command in dbx, you call a procedure and the procedure performs as specified:
The procedure could modify something in your program. dbx is making the call as if you had written it into your program source. For more information, see call Command. print CommandTo print the value of the expressions, type:
If an expression has a function call, the same considerations apply as with the call Command command. With C++, you should also be careful of unexpected side effects caused by overloaded operators. For more information, see print Command. when CommandThe when command has a general syntax as follows:
When the event occurs, the commands 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. For more information, see when Command. fix CommandYou can use the fix command to make immediate changes to your program:
Although it is a very useful tool, the fix command recompiles modified source files and dynamically links the modified functions into the application. Make sure to check the restrictions for fix and continue. See Memory Leak (mel) Error. For more information, see fix Command. cont at CommandThe cont at command alters the order in which the program runs. Execution is continued at line line. id is required if the program is multithreaded.
This could change the outcome of the program. |
||||||