Class: Debugger::ConditionCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/commands/condition.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Command

Debugger::Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, #match, method_missing, options

Constructor Details

This class inherits a constructor from Debugger::Command

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/ruby-debug/commands/condition.rb', line 40

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

.help_commandObject



36
37
38
# File 'lib/ruby-debug/commands/condition.rb', line 36

def help_command
  'condition'
end

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruby-debug/commands/condition.rb', line 10

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]
        print_contdition_set(b.id)
        break
      end
    end

  end
end

#regexpObject



6
7
8
# File 'lib/ruby-debug/commands/condition.rb', line 6

def regexp
  /^\s* cond(?:ition)? (?:\s+(\d+)\s*(.*))?$/ix
end