Sha256: 28d65e9deb29325d6d7e929521091c06949bfa55a8c7b7343ead25c55094a9a4

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

module Trepan

  class ConditionCommand < OldCommand # :nodoc:

    def regexp
      /^\s* cond(?:ition)? (?:\s+(\d+)\s*(.*))?$/ix
    end
    
    def execute
      if not @match[1]
        errmsg "\"condition\" must be followed a breakpoint number and expression\n"
      else
        breakpoints = Debugger.breakpoints.sort_by{|b| b.id }
        largest = breakpoints.inject(0) do |largest, b| 
          largest = b.id if b.id > largest
        end
        if 0 == largest
          print "No breakpoints have been set.\n"
          return
        end
        pos = get_int(@match[1], "Condition", 1, largest)
        return unless pos
        breakpoints.each do |b|
          if b.id == pos 
            b.expr = @match[2].empty? ? nil : @match[2]
            break
          end
        end

      end
    end
    
    class << self
      def help_command
        'condition'
      end

      def help(cmd)
        %{
          Condition breakpoint-number expression
Specify breakpoint number N to break only if COND is true.
N is an integer and COND is an expression to be evaluated whenever 
breakpoint N is reached. If the empty string is used, the condition is removed.
        }
      end
    end
  end

end # module Debugger

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rb8-trepanning-0.1.6 processor/command-ruby-debug/condition.rb
rb8-trepanning-0.1.5 processor/command-ruby-debug/condition.rb
rb8-trepanning-0.1.4 processor/command-ruby-debug/condition.rb
rb8-trepanning-0.1.3 processor/command-ruby-debug/condition.rb
rb8-trepanning-0.1.3-universal-ruby-1.9.2 processor/command-ruby-debug/condition.rb
rb8-trepanning-0.1.3-universal-ruby-1.8.7 processor/command-ruby-debug/condition.rb