Class: WebTools::Support::Debugger::Frame

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/web_tools/support/debugger.rb

Defined Under Namespace

Classes: Context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Frame

Returns a new instance of Frame.



162
163
164
165
166
167
# File 'lib/web_tools/support/debugger.rb', line 162

def initialize(params)
  @gsmethod = params[:method]
  @thread = params[:thread]
  @index = params[:index]
  initialize_frame_info
end

Instance Attribute Details

#block_nestingObject (readonly)

Returns the value of attribute block_nesting.



159
160
161
# File 'lib/web_tools/support/debugger.rb', line 159

def block_nesting
  @block_nesting
end

#debug_infoObject (readonly)

Returns the value of attribute debug_info.



159
160
161
# File 'lib/web_tools/support/debugger.rb', line 159

def debug_info
  @debug_info
end

#defining_classObject (readonly)

Returns the value of attribute defining_class.



159
160
161
# File 'lib/web_tools/support/debugger.rb', line 159

def defining_class
  @defining_class
end

#gsmethodObject (readonly)

Returns the value of attribute gsmethod.



159
160
161
# File 'lib/web_tools/support/debugger.rb', line 159

def gsmethod
  @gsmethod
end

#indexObject (readonly)

Returns the value of attribute index.



159
160
161
# File 'lib/web_tools/support/debugger.rb', line 159

def index
  @index
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



159
160
161
# File 'lib/web_tools/support/debugger.rb', line 159

def method_name
  @method_name
end

#threadObject (readonly)

Returns the value of attribute thread.



159
160
161
# File 'lib/web_tools/support/debugger.rb', line 159

def thread
  @thread
end

Instance Method Details

#context_eval(str) ⇒ Object



188
189
190
# File 'lib/web_tools/support/debugger.rb', line 188

def context_eval(str)
  context_object.instance_eval(str)
end

#context_objectObject



192
193
194
195
196
# File 'lib/web_tools/support/debugger.rb', line 192

def context_object
  @context ||= Context.create_for(self,
                                  debug_info![:self],
                                  debug_info![:context])
end

#debug_info!Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/web_tools/support/debugger.rb', line 215

def debug_info!
  @debug_info ||=
    begin
      ary = @thread.__gsi_debugger_detailed_report_at(@index)
      context = {}
      # First the named temps, matched to values
      ary[6].each_with_index {|name,idx| context[name] = ary[7][idx] }
      # Then the remaining scope values with temporary names
      ary[7][ary[6].size..-1].each_with_index {|v,i| context[:'t#{i}'] = v}
      context[:'(receiver)'] = ary[1]
      context[:'(class)'] = ary[1].class
      context[:'(self)'] = ary[2]
      { :gsMethod => ary[0],
      :receiver => ary[1],
      :self => ary[2],
      :method => ary[3],
      :stepOffset => ary[4],
      :stepPoints => ary[5],
      :source => ary[8],
      :context => context }
    end
end

#deleteObject

Pop frame off the stack, effectively restarting it



170
171
172
# File 'lib/web_tools/support/debugger.rb', line 170

def delete
  @thread.__trim_stack_to_level(@index)
end

#initialize_frame_infoObject



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/web_tools/support/debugger.rb', line 198

def initialize_frame_info
  label = @gsmethod.__name
  @block_nesting = 0
  m = @gsmethod
  while label.nil?
    m = m.__home_method
    label = m.__name
    @block_nesting += 1
  end
  @defining_class = m.__in_class
  @class = @gsmethod.__in_class
  @method_name = label
  if @gsmethod.__source_location
    @source_location = @gsmethod.__source_location.join(":")
  end
end

#step(symbol = :over) ⇒ Object

Step. The manner of stepping defaults to :over, but :into or the number of steps can be passed as arguments

Raises:

  • (RuntimeError)


176
177
178
179
180
181
182
183
184
185
186
# File 'lib/web_tools/support/debugger.rb', line 176

def step(symbol = :over)
  raise RuntimeError, "can only step top frame" unless @index === 1
  case symbol
  when :into
    @thread.__step_over_in_frame(0)
  when :over
    @thread.__step_over_in_frame(1)
  when Fixnum
    @thread.__step_over_in_frame(arg)
  end
end

#to_hashObject



238
239
240
241
242
243
244
245
246
# File 'lib/web_tools/support/debugger.rb', line 238

def to_hash
  { :method_name => @method_name,
    :class => @class,
    :index => @index,
    :defining_class => @defining_class,
    :source_location => @source_location,
    :block_nesting => @block_nesting,
    :debug_info => @debug_info }
end