Class: Debugger::FinishCommand

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

Overview

Implements the debugger ‘finish’ command.

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ruby-debug/commands/finish.rb', line 29

def help(cmd)
  %{
    fin[ish] [frame-number]\tExecute until selected stack frame returns.

If no frame number is given, we run until the currently selected frame
returns.  The currently selected frame starts out the most-recent
frame or 0 if no frame positioning (e.g "up", "down" or "frame") has
been performed. If a frame number is given we run until that frame
returns.
  }
end

.help_commandObject



25
26
27
# File 'lib/ruby-debug/commands/finish.rb', line 25

def help_command
  'finish'
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ruby-debug/commands/finish.rb', line 11

def execute
  max_frame = @state.context.stack_size - @state.frame_pos
  if !@match[1] or @match[1].empty?
    frame_pos = @state.frame_pos
  else
    frame_pos = get_int(@match[1], "Finish", 0, max_frame-1, 0)
    return nil unless frame_pos
  end
  @state.context.stop_frame = frame_pos
  @state.frame_pos = 0
  @state.proceed
end

#regexpObject



7
8
9
# File 'lib/ruby-debug/commands/finish.rb', line 7

def regexp
  /^\s*fin(?:ish)? (?:\s+(.*))?$/x
end