Adding a Watch
Go Up to Debugging Applications Index
Add a watch to track the values of program variables or expressions as you step over or trace into code. Each time program execution pauses, the debugger evaluates all the items listed on the Active tab (or ActiveWatchGroup) in the Watch List window and updates their displayed values.
You can organize watches into groups. When you add a watch group, a new tab is added to the Watch List window and all watches associated with that group are shown on that tab. When a group tab is displayed, only the watches in that group are evaluated during debugging. By grouping watches, you can also prevent out-of-scope expressions from slowing down stepping.
To add a watch
- Choose Run > Add Watch to display the Watch Properties dialog box.
- In the Expression field, enter the expression you want to watch.An expression consists of constants, variables, and values contained in data structures, combined with language operators. Almost anything you can use as the right side of an assignment operator can be used as a debugging expression, except for variables not accessible from the current execution point.
- Optionally, enter a name in the Group Name field to create the watch in a new group, or select a group name from the list of previously defined groups.
- Specify other options as needed (click Help on the Watch Properties dialog for a description of the options). For example, you can request the debugger to evaluate the watch, even if doing so causes function calls, by selecting the Allow Function Calls option.
- Click OK. The watch is added to the Watch List window.
To persist watches from session to session
If you set the Autosave Project desktop option, watches and breakpoints that you set for a project will persist from session to session.
- Set the watches (and breakpoints) that you want to keep from session to session.
- Choose Tools > Options > Environment Options.
- Enable Autosave Project desktop. When you exit the product or close your project, your desktop settings are saved to a .dsk file. When you reopen your project, the product reads the .dsk file and restores your saved desktop, breakpoints, watches, and open files.
You need to delete the .dsk file when you no longer want the saved set of breakpoints to persist in your project (or any other items controlled by the Autosave Project desktop option).