Aptana Studio ヘルプ > はじめに > RDT (Ruby Development Tools) > Ruby Debugger

Ruby Debug Views

This page gives an overview of the Views in the Ruby Debug perspective.

Contents

Introduction

The debug perspective contains the following views per default:

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.

Image:variableViewShowClassesAndConstants.png

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.

Image:variableViewWithTypes.png

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.

Image:arrayInVariablesView.png

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:

Image:hashInVariablesView.png

Breakpoints View

Use the Breakpoints view to remove ruby breakpoints.

Expressions View

Results of ruby expression evaluation are displayed here. Evaluation takes place:

Image:expressionViewWithInspectResult.png

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):

Image:displayView.png

The Expressions view shows the re-itemized list:

Image:expressionViewWithGlobalVariables.png

Related Topics