Sha256: 89fc4d084562c7d16959819cdb0c7a2b8dfa88f3c6da25c5ebe1bff71b416c3d

Contents?: true

Size: 1.5 KB

Versions: 7

Compression:

Stored size: 1.5 KB

Contents

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
        <<-EOD
          inf[o] b[reakpoints]

          #{short_description}
        EOD
      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)
        expr = brkpt.expr.nil? ? '' : " if #{brkpt.expr}"
        y_n = brkpt.enabled? ? 'y' : 'n'
        interp = format('%-3d %-3s at %s:%s%s',
                        brkpt.id, y_n, brkpt.source, brkpt.pos, 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

7 entries across 6 versions & 3 rubygems

Version Path
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/byebug-9.1.0/lib/byebug/commands/info/breakpoints.rb
tdiary-5.0.6 vendor/bundle/gems/byebug-9.1.0/lib/byebug/commands/info/breakpoints.rb
byebug-9.1.0 lib/byebug/commands/info/breakpoints.rb
tdiary-5.0.5 vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/info/breakpoints.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/info/breakpoints.rb
tdiary-5.0.4 vendor/bundle/gems/byebug-9.0.6/lib/byebug/commands/info/breakpoints.rb
byebug-9.0.6 lib/byebug/commands/info/breakpoints.rb