Sha256: 53597dcd9c3a5c29a2a31a19476b5c286f59fcbe67ab64ca9109efb83b00d925

Contents?: true

Size: 1.25 KB

Versions: 6795

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require_relative "../command"
require_relative "../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
      <<-DESCRIPTION
        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.
      DESCRIPTION
    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.zero? ? 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

6,795 entries across 6,792 versions & 32 rubygems

Version Path
ory-oathkeeper-client-0.38.19.beta1 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-oathkeeper-client-0.38.18.beta1 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-oathkeeper-client-0.38.17.beta1 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
avalara_sdk-2.4.7 vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha58 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha57 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha56 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha55 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha54 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha53 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha52 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha51 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha50 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha49 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha48 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha47 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha46 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha45 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha44 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb
ory-client-0.0.1.alpha43 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/commands/finish.rb