This page gives an overview of the Views in the Ruby Debug perspective.
Contents |
Introduction
The debug perspective contains the following views per default:
- Debug
- Variables
- Breakpoints
- Editor
- Outline
- Console
- Tasks
In addition to these there are two more view for the debug perspective: the Expression and Display view. The Expression view will be opened for displaying the results of inspect commands (runtime evaluation). The Display view allows to enter arbitrary ruby commands for evaluation.
Variables View
The Variables View shows the variables available in the stack trace which is selected in the Debug view.
Show Constants and Classes
Check Show Constants to display constants, check Show Class Variables to display class variables.
If you compare the default variable view with the screenshot above you will notice that there are a lot more menu commands available. They are for java debug targets. You can customize the variable view to show ruby debug commands only: Go to Window > Preferences > General > Capabilities and deselect Development. It is a little bewildering to switch off Development here, but it means only to disable Java development and not Ruby development.
In the above screenshot there is a variable barney of type person. The object is represented by the return value of the to_s method, in this case "#<Person:0x2ae7d20>". There is one instance variable @name of type String and value "Barney".
Arrays
Assume the following code:
class Person def initialize(name) @name = name end def to_s() return @name.to_s end end persons = [] persons << Person.new('Barney') persons << Person.new('Moe')
After the last assignment the variable view shows the content of the array. Note that the name appears as description for the object, because to_s is overriden.
Hashes
In order to show how hashes are presented in the variables view, a hash is created:
persons = Hash[ Person.new('Lisa') => Person.new('Marge'), Person.new('Maggie') => Person.new('Marge')]
The view shows the name of the hash with the number of elements in the first place. If you expand the item, there will be a line for every key/value pair in the hash. Expanding a key/value pair will show the content of the value. If you want to know more about the key, select "Inspect key" from the context menu:
Breakpoints View
Use the Breakpoints view to remove ruby breakpoints.
Expressions View
Results of ruby expression evaluation are displayed here. Evaluation takes place:
- If you select text in the editor, open the context menu and run "Inspect" or a quick inspect expression with "Inspect..."
- If you use the display view to enter ruby expressions
- If you select "inspect key" in the context menu of a hash value in the variable view
Display View
Enter your text in the Display view and run "Ruby inspect" from the context menu. The Expression view will open and show the re-itemized list of the expression. The expression is evaluated in the context of the selected stack frame in the Launch view.
The following example shows an expression which creates a hash with all global variables mapped to their values (the "Content Assist" menu entry is only valid in the context of a java program):
The Expressions view shows the re-itemized list: