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 |tally, b|
    tally = b.id if b.id > tally
  end
  if 0 == largest
    errmsg pr("toggle.errors.no_breakpoints")
    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 pr("toggle.errors.expression", expr: b.expr)
            break
          end
        end
        b.enabled = ("Enable" == is_enable)
        print(pr("toggle.breakpoint_#{enabled ? "enabled" : "disabled"}", id: b.id))
        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 pr("toggle.errors.no_display")
    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