Sha256: 8a47513ed90cf6e8bc62fea9034103a23f3cbb4ff4d0cab4e014b4188d4bb5a9

Contents?: true

Size: 1.21 KB

Versions: 28

Compression:

Stored size: 1.21 KB

Contents

module Debugger

  class ConditionCommand < Command # :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

28 entries across 28 versions & 8 rubygems

Version Path
ruby-debug-0.11.0 cli/ruby-debug/commands/condition.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/ruby-debug-0.10.6/cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.6 cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.5.rc9 cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.5.rc8 cli/ruby-debug/commands/condition.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.5.rc7 cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.5.rc5 cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.5.rc4 cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.5.rc3 cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.5.rc2 cli/ruby-debug/commands/condition.rb
ruby-debug193-0.0.1 cli/ruby-debug/commands/condition.rb
ruby-debug-0.10.5.rc1 cli/ruby-debug/commands/condition.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/ruby-debug19-0.11.6/cli/ruby-debug/commands/condition.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/condition.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/condition.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/condition.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/condition.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/condition.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/condition.rb