HP/DDE Debugger User's Guide: HP 9000 Series 700/800 Computers > Chapter 3 Using Monitors (Breakpoints,
Watchpoints, Traces, and Intercepts) Setting Watchpoints |
|
Use watchpoints to monitor the value of a variable or memory range. (See “Examining Registers ” for information on monitoring registers.) Values are displayed in the Data Watchpoint dialog box as well as in the debugger output area. When you create a watchpoint, you specify the expression or address range to monitor, and a granularity. The granularity specifies how often the value should be reported: on procedure entry, on procedure exit, on procedure entry and exit, at every statement, at every machine instruction, or whenever the program stops and returns control to the debugger. The default granularity is to stop and report value changes only when the target program itself stops and returns control to the debugger. If you needed to monitor a variable more closely, you could specify a instruction- or statement-level granularity. At instruction-level granularity, for example, the value of a variable is checked after every assembly instruction executes. Execution of the target program stops when the value changes. For performance purposes, you should set the granularity as coarsely as possible. For example, if you only need to know the value of the monitored expression each time you enter a procedure, there is no sense in monitoring it after every assembly instruction. Typically you would locate a problem by using a granularity of procedure entry/exit to narrow the source of the problem down to one procedure. Once the problem is localized, use a finer granularity (such as instruction or statement) but limit it to a particular procedure by entering the procedure name in the When In input box in the Data Watchpoint Set/Change dialog box. The following sections describe some of the methods for setting watchpoints. When you set a watchpoint by any method, the Data Watchpoints dialog box is displayed (you can also invoke it by selecting Watch:Values Display). See Figure 3-3 “The Data Watchpoints Dialog Box ”. The Data Watchpoints dialog box shows detailed information on each watchpoint and it allows you to manipulate both the watchpoints and the display itself. Each watchpoint displays the variables or memory area it is attached to. The data display highlights when the data being watched is modified. Complete watchpoints can be hidden by selecting the down arrow button next to the watchpoint. Select the button again (which is now the ėėright arrow button) to redisplay the watchpoint. Individual elements in a watchpoint (such as some elements in an array) can be hidden by selecting them and selecting Selected -> Hide. Select Watchpoint -> Show All Hidden Values to redisplay them. Compound objects (such as arrays or structures) can be collapsed to simplify the display, either by double-clicking the beginning of the compound object, or by selecting it and choosing Selected -> Collapse. Double-click the collapsed object, or choose Selected -> Expand, to display the entire object. To modify the watchpoint, choose Watchpoint -> Change. The Data Watchpoints dialog box is displayed, allowing you to modify all editable attributes of the watchpoint. To change the Active/Suspend status of a watchpoint, use the Data Watchpoints dialog box. You can also activate or suspend all watchpoints by selecting the Activate All or Suspend All buttons in the Data Watchpoints window, or by choosing the Watch: Suspend ALL or Watch: Activate ALL menu selections. Use Watchpoint -> Delete to eliminate a watchpoint. The following buttons are located below the source file display area: An easy way to enter tokens in the ( ): input box is to use the mouse to highlight expressions in the source display. Highlight by dragging with the left mouse button depressed. When you release the left mouse button, the expression appears in the ( ): input box. Use Options:User Configurable Buttons to modify the default behavior of the command buttons. A variety of watchpoint commands are available from the Watch menu. Many entries on the Watch menu allow you to set a watchpoint associated with an expression entered in the ( ): input box. As Figure 3-4 “The Watch Menu ” shows, the Watch menu is a Tear-off Menu. When you click on the dashed line at the top of the Watch menu, the menu is displayed in its own window. The menu persists so that you can invoke commands from it without having to redisplay it. You can also move the menu to a convenient place in your workspace. The Data Watchpoint Set/Change dialog box allows you to specify all aspects of a watchpoint. Invoke it by selecting Watch:Set. The dialog box in Figure 3-5 “The Data Watchpoint Set/Change Dialog Box ” appears. From the Data Watchpoint Set/Change dialog box, you can:
To see a listing of watchpoints, select Watch:Show. The following command sets a watchpoint on the variable idx. By default, the watchpoint is in effect at every statement in the program; that is, the debugger checks the value of idx after each program statement executes, and it stops program execution if the value of idx changes.
See Monitoring Memory Ranges in the online help for information on monitoring addresses with the watchpoint command. |