Sha256: e1636cd2c4576d90af0ef15333319b273f62f5d4f7d420f3e6623cdca15d83f9

Contents?: true

Size: 1.19 KB

Versions: 19

Compression:

Stored size: 1.19 KB

Contents

require 'byebug/command'
require 'byebug/helpers/parse'

module Byebug
  #
  # Implements the finish functionality.
  #
  # Allows the user to continue execution until certain frames are finished.
  #
  class FinishCommand < Command
    include Helpers::ParseHelper

    self.allow_in_post_mortem = false

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

    def self.description
      <<-EOD
        fin[ish][ n_frames]

        #{short_description}

        If no number is given, we run until the current frame returns. If a
        number of frames `n_frames` is given, then we run until `n_frames`
        return from the current position.
      EOD
    end

    def self.short_description
      'Runs the program until frame returns'
    end

    def execute
      if @match[1]
        n_frames, err = get_int(@match[1], 'finish', 0, max_frames - 1)
        return errmsg(err) unless n_frames
      else
        n_frames = 1
      end

      force = n_frames == 0 ? true : false
      context.step_out(context.frame.pos + n_frames, force)
      context.frame = 0
      processor.proceed!
    end

    private

    def max_frames
      context.stack_size - context.frame.pos
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
byebug-9.0.5 lib/byebug/commands/finish.rb
byebug-9.0.4 lib/byebug/commands/finish.rb
byebug-9.0.3 lib/byebug/commands/finish.rb
byebug-9.0.2 lib/byebug/commands/finish.rb
byebug-9.0.1 lib/byebug/commands/finish.rb
byebug-9.0.0 lib/byebug/commands/finish.rb
byebug-8.2.5 lib/byebug/commands/finish.rb
byebug-8.2.4 lib/byebug/commands/finish.rb
byebug-8.2.3 lib/byebug/commands/finish.rb
byebug-8.2.2 lib/byebug/commands/finish.rb
byebug-8.2.1 lib/byebug/commands/finish.rb
byebug-8.2.0 lib/byebug/commands/finish.rb
byebug-8.1.0 lib/byebug/commands/finish.rb
byebug-8.0.1 lib/byebug/commands/finish.rb
byebug-8.0.0 lib/byebug/commands/finish.rb
byebug-7.0.0 lib/byebug/commands/finish.rb
byebug-6.0.2 lib/byebug/commands/finish.rb
byebug-6.0.1 lib/byebug/commands/finish.rb
byebug-6.0.0 lib/byebug/commands/finish.rb