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
# 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 "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 = ("Enable" == is_enable)
        break
      end
    end
  end
end

#enable_disable_display(is_enable, args) ⇒ Object



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

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