Sha256: 033f62884257b714477e8c784999881c96715001fd3da1a392ff8c0ffb71ad4c

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
module Registers
  def register_array_index(name, arg, max_value=nil)
    if !arg or arg.empty?
      # Form is: "info xx" which means "info xx 0"
      lookup_pos = position = 0
    else
      opts = {
        :msg_on_error => 
        "The 'info registers %s' command argument must eval to an integer. Got: %s" % [name, arg],
        :min_value => -10,
        :max_value => max_value + 10
      }
      position = @proc.get_an_int(arg, opts)
      return nil unless position
    end
    lookup_pos = 
      if 'lfp' == name
        max_value + 1 - position 
      elsif 'sp' == name && 'CFUNC' == @proc.frame.type 
        # && @proc.frame.next.type == 'IFUNC" # ? 

        # FIXME: In C frames there seems to be some vm_push_frame's
        # via perhaps vm_yield_with_cfunc along with sp adjustments.
        # I am not sure if this is under what conditions this
        # *doesn't* happen so until I can figure out the better thing
        # to do, possibly in the Ruby 1.9 interpeter, we'll handle
        # this here.  It is also conceivable to handle this in
        # thread_frame's sp handling.
        position + 3
      else
        position
      end
    msg("VM %s(%d) = %s" % [name, position, 
                            @proc.frame.send(name, lookup_pos).inspect])
    return position
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trepanning-1.93.35 processor/command/info_subcmd/registers_subcmd/helper.rb
trepanning-1.93.32 processor/command/info_subcmd/registers_subcmd/helper.rb
trepanning-0.1.6 processor/command/info_subcmd/registers_subcmd/helper.rb
trepanning-0.1.4 processor/command/info_subcmd/registers_subcmd/helper.rb
trepanning-0.1.3 processor/command/info_subcmd/registers_subcmd/helper.rb