Using SoftBench Debugger

Setting and Using Watchpoints

Setting and Using Watchpoints

Watchpoints allow you to monitor the value of an expression, or the contents of a range of memory, while your program executes. SoftBench Debugger checks the value (as often as specified in the watchpoint definition), notifies you when it changes, and pauses your program.

This can be extremely useful when searching for "mystery" errors. For example, suppose at some unknown time your program corrupts an important area in memory. Without watchpoints, it would be very difficult to determine exactly when the corruption occurred. Using watchpoints, you can quickly find when the corruption happens, which gives you a good idea of what caused it.

When you create a watchpoint, you specify the expression or address range to monitor, and an option to specify "granularity". Granularity specifies how often the value of interest should be monitored:

At every procedure entry

At every procedure exit

At the entry and exit of every procedure

Every statement

Every assembly instruction

whenever the program stops and returns control to the debugger

The Watchpoint dialog setting defaults to "Stop". This default allows you to monitor the current values of some data items when debugging a program.

Be certain you specify an appropriate granularity. If you want SoftBench Debugger to watch a variable while your program runs, you should not have the "Stop" radio button active in the "Set At" area. This setting only checks your watchpoints when your program reaches a breakpoint or is interrupted for another reason. You should specify a procedure- or statement-level granularity so SoftBench Debugger checks the variable while your program runs. You can also use the "Modification" radio button to identify when an address or variable is unexpectedly being changed. This button issues a default DDE watchpoint command on the contents of the "()" input box. This same feature can also be accessed from the menu under "Watch: Set at Modification".

Chapter 7

199

Page 199
Image 199
HP UX SoftBench Software manual Setting and Using Watchpoints