Sha256: 9a0a7b587dd51cda089de3e1dff9cf4cf3c7303d765a8904438ea76f39766390

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

# -*- coding: utf-8 -*-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
require_relative 'base/cmd'
require_relative '../../app/condition'
class Trepan::Command::StepICommand < Trepan::Command

  unless defined?(HELP)
    HELP =
"stepi

Step by VM instruction(s).

Examples: 
  stepi        # step 1 instruction
  stepi 1      # same as above

Related and similar is the 'step', 'next' (step over) and 'finish' (step out)
commands.  All of these are slower than running to a breakpoint.

See also the commands:
'skip', 'jump' (there's no 'hop' yet), 'continue', 'return' and
'finish' for other ways to progress execution.
"

    CATEGORY     = 'running'
    NAME         = File.basename(__FILE__, '.rb')
    NEED_RUNNING = true
    SHORT_HELP   = 'Step VM instruction(s)'

  end

  include Trepan::Condition
  # This method runs the command
  def run(args)
    opts = {:stop_events => Set.new(%w(insn))}
    @proc.core.step_events |= Trace::INSN_EVENT_MASK
    condition = nil
    if args.size == 1
      # Form is: "step" which means "step 1"
      step_count = 0
    else
      count_str = args[1]
      int_opts = {
        :msg_on_error => 
        "The 'step' command argument must eval to an integer. Got: %s" % 
        count_str,
        :min_value => 1
      }.merge(opts)
      count = @proc.get_an_int(count_str, int_opts)
      return unless count
      # step 1 is core.step_count = 0 or "stop next event"
      step_count = count - 1  
    end
    @proc.step(step_count, opts, condition)
  end
end

if __FILE__ == $0
  require_relative '../mock'
  name = File.basename(__FILE__, '.rb')
  dbgr, cmd = MockDebugger::setup(name)
  p cmd.run([name])
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trepanning-0.0.9 processor/command/stepi.rb
trepanning-0.0.8 processor/command/stepi.rb
trepanning-0.0.6 processor/command/stepi.rb