Module: Debugger::EnableDisableFunctions

Defined in:
lib/ruby-debug/commands/enable.rb

Overview

Mix-in module to assist in command parsing.

Instance Method Summary collapse

Instance Method Details

#enable_disable_breakpoints(is_enable, args) ⇒ Object

:nodoc:



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ruby-debug/commands/enable.rb', line 4

def enable_disable_breakpoints(is_enable, args)
  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
    errmsg "No breakpoints have been set.\n"
    return
  end
  args.each do |pos|
    pos = get_int(pos, "#{is_enable} breakpoints", 1, largest)
    return nil unless pos
    breakpoints.each do |b|
      if b.id == pos 
        enabled = ("Enable" == is_enable)
        if enabled
          unless syntax_valid?(b.expr)
            errmsg("Expression \"#{b.expr}\" syntactically incorrect; breakpoint remains disabled.\n")
            break
          end
        end
        b.enabled = enabled
        enabled ? print_breakpoint_enabled(b) : print_breakpoint_disabled(b)
        break
      end
    end
  end
end

#enable_disable_display(is_enable, args) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ruby-debug/commands/enable.rb', line 33

def enable_disable_display(is_enable, args)
  if 0 == @state.display.size 
    errmsg "No display expressions have been set.\n"
    return
  end
  args.each do |pos|
    pos = get_int(pos, "#{is_enable} display", 1, @state.display.size)
    return nil unless pos
    @state.display[pos-1][0] = ("Enable" == is_enable)
  end
end