Sha256: 463fa2b9d2598591ce83de125cfcc256fafa03bd0a45e19b42c2e77f46ffbe3e

Contents?: true

Size: 1.62 KB

Versions: 12

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

module Byebug
  #
  # Reopens the +info+ command to define the +breakpoints+ subcommand
  #
  class InfoCommand < Command
    #
    # Information about current breakpoints
    #
    class BreakpointsCommand < Command
      self.allow_in_post_mortem = true

      def self.regexp
        /^\s* b(?:reakpoints)? (?:\s+ (.+))? \s*$/x
      end

      def self.description
        <<-DESCRIPTION
          inf[o] b[reakpoints]

          #{short_description}
        DESCRIPTION
      end

      def self.short_description
        "Status of user settable breakpoints"
      end

      def execute
        return puts("No breakpoints.") if Byebug.breakpoints.empty?

        breakpoints = Byebug.breakpoints.sort_by(&:id)

        if @match[1]
          indices = @match[1].split(/ +/).map(&:to_i)
          breakpoints = breakpoints.select { |b| indices.member?(b.id) }
          if breakpoints.empty?
            return errmsg("No breakpoints found among list given")
          end
        end

        puts "Num Enb What"
        breakpoints.each { |b| info_breakpoint(b) }
      end

      private

      def info_breakpoint(brkpt)
        interp = format(
          "%-<id>3d %-<status>3s at %<file>s:%<line>s%<expression>s",
          id: brkpt.id,
          status: brkpt.enabled? ? "y" : "n",
          file: brkpt.source,
          line: brkpt.pos,
          expression: brkpt.expr.nil? ? "" : " if #{brkpt.expr}"
        )
        puts interp
        hits = brkpt.hit_count
        return unless hits > 0

        s = hits > 1 ? "s" : ""
        puts "  breakpoint already hit #{hits} time#{s}"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 5 rubygems

Version Path
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/byebug-10.0.2/lib/byebug/commands/info/breakpoints.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/commands/info/breakpoints.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/commands/info/breakpoints.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/byebug-10.0.2/lib/byebug/commands/info/breakpoints.rb
jets-0.5.5 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/info/breakpoints.rb
jets-0.5.4 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/info/breakpoints.rb
jets-0.5.3 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/info/breakpoints.rb
jets-0.5.2 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/info/breakpoints.rb
jets-0.5.1 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/commands/info/breakpoints.rb
byebug-10.0.2 lib/byebug/commands/info/breakpoints.rb
byebug-10.0.1 lib/byebug/commands/info/breakpoints.rb
byebug-10.0.0 lib/byebug/commands/info/breakpoints.rb