Class: Debugger::UpCommand

Inherits:
Command
  • Object
show all
Includes:
FrameFunctions
Defined in:
lib/ruby-debug/commands/frame.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FrameFunctions

#format_frame

Methods inherited from Command

commands, inherited, #initialize, load_commands, #match, method_missing, options

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/ruby-debug/commands/frame.rb', line 81

def help(cmd)
  if cmd == 'up'
    %{
      up[ nn]\tmove to higher frame
    }
  else
    %{
      f[rame] n\tselect nth frame
    }
  end
end

.help_commandObject



77
78
79
# File 'lib/ruby-debug/commands/frame.rb', line 77

def help_command
  %w|up frame|
end

Instance Method Details

#executeObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ruby-debug/commands/frame.rb', line 54

def execute
  if @match[1]
    cmd, arg = @match.captures
  else
    cmd, arg = @match.captures[2..-1]
  end
  @state.previous_line = nil
  if cmd == 'f'
    @state.frame_pos = arg.to_i - 1
  else
    @state.frame_pos += (arg ? arg.to_i : 1)
  end
  @state.frame_pos = 0 if @state.frame_pos < 0
  if @state.frame_pos >= @state.frames.size
    @state.frame_pos = @state.frames.size - 1
    print "At toplevel\n"
  end
  frame = @state.frames[@state.frame_pos]
  @state.binding, @state.file, @state.line = frame.binding, frame.file, frame.line
  print format_frame(frame, @state.frame_pos)
end

#regexpObject



50
51
52
# File 'lib/ruby-debug/commands/frame.rb', line 50

def regexp
  /^\s*(?:(up)(?:\s+(\d+))?|(f)(?:rame)?(?:\s+(\d+)))\s*$/
end