Wing can watch debug data values using a variety of techniques for tracking the value over time. In most cases, watching a value is initiated by right-clicking a value within a Stack Data view and selecting one of the Watch menu items. The value is then added to the list in the Watch tool and tracked by one of the following methods:
- By Symbolic Path - The debugger looks at the symbolic path from locals() or globals() for the currently selected stack frame, and tries to re-evaluate that path whenever the value may have changed. For example, if you define a dictionary variable called testdict in a function and set a value testdict = 'test', the watched value for testdict would show any value for that slot of testdict, even if you delete testdict and recreate it. In other words, value tracking is independent of the life of any object instances in the data path.
- By Direct Object Reference - The debugger uses the object reference to the selected value to track it. If you use this mode with testdict as a whole, it would track the contents of that dictionary as long as it exists. If you were to reassign the variable testdict to another value, your zoomed out display would still show the contents of the original dictionary instance (if it still exists), rather than the new value of the variable testdict. In other words, the symbolic path to the value is completely disregarded and only instance identity is used to track the value. Because it's meaningless to track immutable types this way, this option is disabled or enabled according to the values you select to zoom out into a separate window.
- By Parent Reference and Slot - The debugger uses the object reference to the parent of the selected data slot and uses a symbolic representation of the slot within the parent in order to determine where to look for any value updates. This means that reassignment of the variable that points to the parent does not alter what is displayed in the zoomed-out view; only reassignment of the selected slot changes what is displayed by the debugger.
- By Module Slot - This is only available for values within a module, such as string, sys.path, or os.environ. The debugger uses the module name to look up the module in sys.modules and references the value by symbolic path. Any change in the value, even across module reloads, is reflected in the Watch view.
For any of these, if the value cannot be evaluated because it does not exist, the debugger displays <undefined>. This happens when the last object reference to a reference-tracked value is discarded, or if a selected symbolic path is undefined or cannot be evaluated.
The Watch tool will remember watch points across debug sessions, except those that make use of an object reference, which do not survive the debug process.