Watched Expressions

See Also

The Watches view shows the values of expressions as evaluated within the current debugging context (combination of current thread and stack frame). You can add new expressions to the view by right-clicking and selecting Add Watch from the context menu. Simply enter any Java expression (with some restrictions, see the evaluator link below) and it will be evaluated each time the debuggee is suspended (when a breakpoint is hit, and while single-stepping).

Removing watched expressions is as easy as creating them, just right-click on the watch node and select "Delete" from the context menu.

Fixed Watches

The Add Watch dialog has a checkbox to create a fixed watch. A fixed watch is very different from a normal watch. While a normal watch expression is evaluated each time the debuggee suspends, the fixed watch expression is evaluated just one time, and it must refer to an object. This object is then stored as a reference such that the same object is shown every time the debuggee suspends. This can be quite useful if you are only interested in how a single object changes during the lifetime of your application.

Fixed watches will self-destruct when the debugger disconnects from the debuggee. This is necessary because the object references are only valid during a single debugging session.

Display Modifiers

When creating a new watch, you can append the value with one of several flags, which controls how the value is displayed. Currently this is only effective for primitive values (e.g. byte, integer, char). For example, if the expression nvalue referred to an int value, you could enter the expression as nvalue,x to see the value in hexadecimal format. Below is a table of the supported modifiers.

Modifier Meaning
,b Binary
,o Octal
,s String
,u Unicode
,x Hexadecimal

For primitive types where the given modifier does not make sense, the evaluated value will be returned unmodified (e.g. if you were to use x on a boolean).

Sorting

The Watches view, like other tree-structured views, will attempt to keep the expanded branches open while stepping through code. If, however, you have clicked on a column header in the view in order to sort the display, the tree will always collapse when it is updated. This is apparently a feature the tree-table component in the NetBeans Platform.

See Also


Legal Notices