| Debugging a Program With dbx |
Modifying a Program State
This appendix focuses on
dbxusage and commands that change your program or change the behavior of your programwhen you run it underdbx, as compared to running it withoutdbx. 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
dbxYour application might behave differently when run under
dbx. Althoughdbxstrives to minimize its impact on the program being debugged, you should be aware of the following:
- You might have forgotten to take out a
-Cor disable RTC. Having the RTC support librarylibrtc.soloaded into a program can cause the program to behave differently.- Your
dbxinitialization scripts might have some environment variables set that you've forgotten about. The stack base starts at a different address when running underdbx. This is also different based on your environment and the contents ofargv[], forcing local variables to be allocated differently. If they're not initialized, they will get different random numbers. This problem can be detected using runtime checking.- The program does not initialize memory allocated with
malloc()before use; a situation similar to the previous one. This problem can be detected using runtime checking.dbxhas to catch LWP creation anddlopenevents, which might affect timing-sensitive multithreaded applications.dbxdoes context switching on signals, so if your application makes heavy use of signals, things might work differently.- Your program might be expecting that
mmap()always returns the same base address for mapped segments. Running underdbxperturbs the address space sufficiently to make it unlikely thatmmap()returns the same address as when the program is run withoutdbx. To determine if this is a problem, look at all uses ofmmap()and ensure that the address returned is used by the program, rather than a hard-coded address.- If the program is multithreaded, it might contain data races or be otherwise dependent upon thread scheduling. Running under
dbxperturbs thread scheduling and may cause the program to execute threads in a different order than normal. To detect such conditions, uselock_lint.Otherwise, determine whether running with
adbortrusscauses 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 Program
assignCommandThe
assigncommand assigns a value of the expression to variable. Using it indbxpermanently alters the value of var.
assignvariable=expression
popCommandThe
popcommand pops a frame or frames from the stack:
popPop current frame. popnumberPop number frames. pop -fnumberPop frames until specified frame number.
Any calls popped are re-executed upon resumption, which might result in unwanted program changes.
popalso calls destructors for objects local to the popped functions.
callCommandWhen you use the
callcommand indbx, you call a procedure and the procedure performs as specified:
callproc([params])The procedure could modify something in your program.
dbxis making the call as if you had written it into your program source.
To print the value of the expression(s), type:
print expression, ...If an expression has a function call, the same considerations apply as with the
callcommand. With C++, you should also be careful of unexpected side effects caused by overloaded operators.
whenCommandThe
whencommand has a general syntax as follows:
whenevent-specification[modifier] {command... ;}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.
fixCommandYou can use the
fixcommand to make immediate changes to your program:
fixAlthough is a very useful tool, the
fixcommand 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 11.
contatCommandThe
cont atcommand alters the order in which the program runs. Execution is continued at line line. id is required if the program is multithreaded.
cont atlineid
|
Sun Microsystems, Inc. Copyright information. All rights reserved. Feedback |
Library | Contents | Previous | Next | Index |