Method: Debugger::AddBreakpoint#execute

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

#executeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ruby-debug/commands/breakpoints.rb', line 20

def execute
  if @match[1]
    line, _, _, expr = @match.captures
  else
    _, file, line, expr = @match.captures
  end

  if file.nil?
    file = File.basename(@state.file)
  else
    if line !~ /^\d+$/
      klass = debug_silent_eval(file)
      if klass && !klass.kind_of?(Module)
        print_error "Unknown class #{file}"
        throw :debug_error
      end
      file = klass.name if klass
    else
      file = File.expand_path(file) if file.index(File::SEPARATOR) || \
        File::ALT_SEPARATOR && file.index(File::ALT_SEPARATOR)
    end
  end
  
  if line =~ /^\d+$/
    line = line.to_i
  else
    line = line.intern.id2name
  end
  
  b = Debugger.add_breakpoint file, line, expr
  print_breakpoint_added b
end