Class: Rubinius::Debugger::Command::NextInstruction

Inherits:
Next show all
Defined in:
lib/rubinius/debugger/commands.rb

Instance Method Summary collapse

Methods inherited from Next

#goto_between, #next_interesting, #set_breakpoints_between, #step_over_by, #step_to_parent

Methods inherited from Rubinius::Debugger::Command

commands, #current_frame, #current_method, descriptor, ext_help, help, #initialize, #listen, match?, pattern, #run_code, #variables

Methods included from Display

#ask, #crit, #display, #error, #info, #section

Constructor Details

This class inherits a constructor from Rubinius::Debugger::Command

Instance Method Details

#is_a_goto(exec, ip) ⇒ Object



399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/rubinius/debugger/commands.rb', line 399

def is_a_goto(exec, ip)
  goto = Rubinius::InstructionSet.opcodes_map[:goto]
  git  = Rubinius::InstructionSet.opcodes_map[:goto_if_true]
  gif  = Rubinius::InstructionSet.opcodes_map[:goto_if_false]

  i = exec.iseq[ip]

  case i
  when goto, git, gif
    return true
  end

  return false
end

#run(args) ⇒ Object



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/rubinius/debugger/commands.rb', line 372

def run(args)
  if args and !args.empty?
    step = args.to_i
  else
    step = 1
  end

  exec = current_method
  insn = Rubinius::InstructionSet[exec.iseq[current_frame.ip]]

  next_ip = current_frame.ip + insn.width

  if next_ip >= exec.iseq.size
    step_to_parent
  elsif is_a_goto(exec, current_frame.ip)
    set_breakpoints_between(exec, current_frame.ip, next_ip)
  else
    line = exec.line_from_ip(next_ip)

    bp = BreakPoint.for_ip(exec, next_ip)
    bp.for_step!(current_frame.variables)
    bp.activate
  end

  listen
end