DebuggerVariables67

Variables and Evaluation in NetBeans Debugger (Draft)

This document summarizes the problems associated with the current concept of local variables, watches and evaluator in NetBeans 6.5 and suggests a possible solution in NetBeans 7.0.

Contents


Problem Description

  • Complicated to add a watch via dialog, not possible to add watch in-place or use D&D.
  • Not possible to see both Local Variables and Watches together in the default configuration.
  • Complicated to find and use Evaluator. Necessity to run from menu and then shuffle around with a floating window.
  • Watches are shared among all debugging sessions and all languages. This clutters the view.
  • Inability to navigate to variable type source class.
  • Detect if variables information is not available, users do not get a suggestion to compile with -g.
  • Display of object ID does not bring much value, users would usually like to see the toString() by default.
  • There is no indication whether displayed variable values are still up-to-date or not. When steps take a long time, display of old data can be confusing.
  • Displaying of error messages quoted in "><" might be confusing. Some more standard approach should be used like red text, etc.
  • Some kind of search/navigate functionality would be appreciated.
  • Symbolic references in watches
  • Expression evaluation should suggest the content of clipboard.

Possible Solution

  • Implement Drag-n-Drop of selected expressions from Editor into Watches
  • Add an empty line that can be used to add new watch expression in-place
  • Add ability to edit watches in-place
  • Add a new mode for variables/watches display in the form <name> = <value> without the table columns
  • Put Evaluator window in the Navigator mode as another tab.
  • Add a logging mode into the Evaluator
  • Add formatters, that can be customized in options, or customizers can be opened from views.
  • Add search navigation (like in Project tab).
  • Add ability to turn on/off watches, group watches by languages, allow custom groups
  • Error messages display in red color. Suggest compilation with -g when no variable info is available.
  • In Local variables distinguish method parameters from local variables.
  • Allow symbolic names to expressions in watches and add ability to use them as references
  • toString() display by default. There are several ways how to accomplish this. For instance:
  • Add a default mode when toString() is displayed (if differs from Object.toString()) in the value column.
  • Or show toString() column by default instead of Value column.
  • Or introduce an option that would determine what to display in the Value column and remove the toString() column completely. Such an option can have three modes:
  • [ ]
    <class-name>@<ID>
  • [X]
    toString() call
  • [ ]
    Formatters
  • Table Columns can be following:
  • [X]
    Name
  • [ ]
    Declared Type
  • [X]
    Actual Type
  • [X]
    Value
  • [ ]
    Instance ID

UI Specification

Watches

Watches window have always one empty line at the end, which can be used to write a new watch expression in-place. The empty text-field is followed by a drop-down button, which shows a menu with last expressions. When en expression is entered, a watch is created from it on that row and a new empty row is created with a new editable field. When "Insert" is pressed having focus in the Watches window, focus is moved into that empty field. Drag-n-Drop of String expressions into Watches window can be used as an alternative method to add a new watch. Also, any expression can be edited directly in-place.

 '''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_'''___
|                         Watches                          |
|----------------------------------------------------------|
|           Expression             |  Type  |    Value     |
|----------------------------------|--------|--------------|
| + myVariable.methodToWatch()     |MyObject| myValue      |
|   [[<writeANewWatchHere>  |  <write a new watch here> ]][V]|        |              |
|'''_''''''_''''''_''''''_''''''_''''''_'''''''''|''''''_'''_|'''_''''''_''''''__|

By default, all submitted watches are listed in the Watches window. However, when submitting a watch, it's associated with the current project and file's MIME type. Watches window have contextual actions:

Show ->
All Watches
Watches of the Current Project
Watches of the Current File Type.

Optional feature: every watch can be prepended with a check-box turning the watch on/off.

Variables

This window (formerly known as "Local Variables") displays "this" value, static fields, arguments to current operation, operation return values and a list of local variables. In case there is no debug information about variables available, this window can still contain "this" and arguments passed to the current method. However, it should also indicate that local variables are not known. Displayed arguments are followed by a red error line "Variable information is not available, source compiled without -g option". If possible, the error line should be span across all columns.

This window can optionally inherit the content of "Watches" window and "Evaluation Result" window. The evaluation result, if any, is displayed on the first line. Individual watches are copied to the beginning of the Local Variables window after the evaluation result. They are distinguished just by the different icon.

Left column of the window will contain following buttons (options):

  • Include Watches (toggle button) ON by default
 When set on, Watches window is closed (if opened) and individual watches are copied to the beginning of this window.
When set off, Watches window is opened and individual watches are removed from this window.
  • Include Evaluation Result (toggle button) ON by default
 When set on, Evaluation Result window is closed (if opened) and the result of the evaluation (if any) is available on the first line of this window.
When set off, Evaluation Result window is opened and the evaluation result line is removed from this window.
  • Create Watch (button always enabled)
 If watches are included in this window, a new empty line is added after the last watch, the line is made editable and the focus is moved there. If some variable was selected, that variable name is copied into the line.
If watches are not included in this window, Watches window is opened (if it's not yet), and focus is moved into the last editable line. If some variable was selected, that variable name is copied into the line.
  • Show as a Table (toggle button) ON by default
 Switches between "table" view and "list" view.
  • Show String Value (toggle button) OFF by default
 Switches between formatted and plain values.
  • Formatters (button navigating to Debugger Options)


Evaluator

Evaluator is split across two windows. One window, named "Evaluate Code", is placed in the bottom Editor area. It consists of a large text area with scroll bars and a column of buttons on the left and right side of the window. The second window, named "Evaluation Result", is placed between Watches and Local Variables windows and contains a table with the structured result with a column of buttons on the left side.

The buttons on the left side are two toggle buttons in a button group (one is toggled at a time):

  • [[[E | [E]] - When toggled, evaluator area is displayed. This is on by default.
  • [[[H | [H]] - When toggled historical results are displayed. The evaluator is switched into the read-only mode displaying the evaluation history.

The buttons on the right side are following:

  • [[[V | [V]] - recently evaluated code - pushing that button opens a popup menu with last 15 unique code snippets that were entered into the text area.
    This button has smaller height than other buttons. There is also a bigger vertical gap between this button and the rest.
  • [[[Evaluate | [Evaluate]] - interprets the piece of code written in the text area and displays the result in the "Evaluation Result" window.
|-------------------------------------------------------------------------------------------------|
| Evaluate Code                                                                                 X |
|-------------------------------------------------------------------------------------------------|
| [[E | E]] |                                                                       | ^ |  [   V     ] |
| [H] |                                                                       |   |               |
|     |                                                                       |   |               |
|     |                                                                       |   |               |
|     |                                                                       | v |  [Evaluate ] |
|'''_'''|'''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_'''_|
|-------------------------------------------------------------------------------------------------|
| Watches           | Evaluation Result | Local Variables   | Breakpoints      | Output           |
|-------------------|                   |---------------------------------------------------------|
|            Name            |         Type        |                   Value                      |
|----------------------------|---------------------|----------------------------------------------|
|                            |                     |                                              |
|                            |                     |                                              |
|                            |                     |                                              |
|                            |                     |                                              |
|                            |                     |                                              |
|'''_''''''_''''''_''''''_''''''_''''''_|''''''_''''''_''''''_'''''''''|''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''__|


A logging mode is added into Evaluator. The log is visible after [[[History | [History]] button in the upper window is pressed. The editable pane is changed to a non-editable pane with grey background. That pane is populated with historical expressions and their returned values (in the form of how they were displayed in "Value" column). Next to the return value there is a link/button "open result". Individual expressions, including the value, are selectable. When an expression is selected, the corresponding value is displayed in the structured way in "Evaluation Result" window. When the "open result" link/button is clicked, the corresponding value is displayed in the structured way in a newly opened "Evaluation Result <n>" window. When the result window is selected, the appropriate evaluated expression is selected in the history window.

|-------------------------------------------------------------------------------------------------|
| Evaluate Code                                                                                 X |
|-------------------------------------------------------------------------------------------------|
| [E] | < expression 1 >                                                                      | ^ |
| [H] |          < returned value >                                             _open result_ |   |
|     | < expression 2 >                                                                      |   |
|     |          < returned value >                                             _open result_ | v |
|'''_'''|'''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_'''_|
|-------------------------------------------------------------------------------------------------|
| Watches           | Evaluation Result | Local Variables   | Breakpoints      | Output           |
|-------------------|                   |---------------------------------------------------------|
|            Name            |         Type        |                   Value                      |
|----------------------------|---------------------|----------------------------------------------|
|                            |                     |                                              |
|                            |                     |                                              |
|                            |                     |                                              |
|                            |                     |                                              |
|                            |                     |                                              |
|'''_''''''_''''''_''''''_''''''_''''''_|''''''_''''''_''''''_'''''''''|''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''_''''''__|


The historical items have grey background, they are not editable and nodes can be expanded only to the levels that are remembered from the expansion state of the original tree. The log is persistent for a debug session only. The history is limited to 1000 items. When a historical item is double-clicked, the historical expression is copied into the editable Evaluator area and the UI is also switched into the editable area.

Left column of the "Evaluation Result" window will contain following buttons (options):

  • Create Watch
  • Create Fixed Watch
  • Show as a Table (toggle button)
  • Show String Value (toggle button)
  • Formatters (button navigating to Debugger Options)


All Windows Displaying Variables

All three windows displaying variables (Watches, Local Variables and Evaluator) will have an option to display the values in a table, like in NetBeans 6.5, and in a single row in the form of <name> = <value>. "Show as a Table" option determines the display style. All windows have following set of columns (the checked columns are displayed by default):

  • [X]
    Name
  • [X]
    Type
  • [ ]
    Declared Type
  • [ ]
    Declared In
  • [X]
    Value
  • [ ]
    Instance ID
There is an option controlling what is displayed in the Value column: "Show String Value". That switches between plain value and toString() or formatted value. Plain value displays String value for primitive types, "
actual_class (#instanceID)
" for class objects and "{<array_type>[<size>]}" for arrays.

The current "Inherited" and "Static" sub-nodes are not nice. They might be considered to be removed and inherited nodes added to the first level.

Context menu on every type contains "Go To Source" item on class types.
Context menu on every value contains "Show References" item.
Search feature is implemented like in Projects tab.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo