Sha256: d11e0c426e811d32d185a99cf2a8ad83ea32d36da70191fa1bc61533c23b5206

Contents?: true

Size: 1.6 KB

Versions: 6776

Compression:

Stored size: 1.6 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) }
          return errmsg("No breakpoints found among list given") if breakpoints.empty?
        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.positive?

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

Version data entries

6,776 entries across 6,772 versions & 31 rubygems

Version Path
cybrid_api_bank_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_id_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_organization_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_bank_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_id_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_organization_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_bank_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_organization_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_id_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
ory-client-1.16.2 vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
avalara_sdk-24.12.2 vendor/bundle/ruby/2.7.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_bank_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_organization_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_id_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_bank_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_id_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_organization_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb
cybrid_api_bank_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/commands/info/breakpoints.rb