Saturday, October 31, 2009

7.7. Expressions View











 < Day Day Up > 







7.7. Expressions View





The Expressions view (in the Debug perspective) shows a list of expressions and their values in the debugger. Use it to examine program states persistently as you step through your code, and to set breakpoints when fields are accessed or modified. This view is similar to the Variables view (described later in Part VII) except that the Expressions view shows only expressions that you have explicitly added. Table 16 describes the Expressions view's toolbar.



Table 7-8. Expressions view toolbar

Icon

Description

Show full type names (toggle).

Show logical structure (toggle).

Collapse all the expanded trees in the view.

Remove the current expression from the view.

Remove all expressions in the view.




There are three ways of looking at any expression in the Eclipse IDE; this is true for both the Expressions view and the Variables view:






Literal mode







The fields, and nothing but the fields








Logical mode







The way you normally think about the object








Details pane







The string representation (as returned by the toString() method)







Consider a java.lang.LinkedList object. If you look at it literally (as in Figure 26), you'll see it contains some internal data structures, such as the number of items and a reference to the first item. But if you look at it logically (Figure 27), it simply contains a list of objects.





Figure 7-1. Literal mode shows an object's internal data structures.









Figure 7-2. Logical mode shows what the object really means.







Additionally, the Expressions and Variables views support an optional text area called the Details pane. This pane shows the string representation of the selected item (see Figure 28). Use the view menu to arrange the panes horizontally or vertically, or to disable the Details pane altogether.





Figure 7-3. The Details pane shows an object's string representation.








Tip: You can create your own ways of looking at expressions by defining new Logical Structures and Detail Formatters in the debugger preferences (Window Preferences Java Debug).














     < Day Day Up > 



    No comments: