Class: Debugger::AddBreakpoint

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

Overview

:nodoc:

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, file_filter_supported?, #find, inherited, #initialize, load_commands, #match, method_missing, options, unescape_incoming

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/ruby-debug-ide/commands/breakpoints.rb', line 57

def help(cmd)
  %{
    b[reak] file:line [if expr]
    b[reak] [file|class(:|.|#)]<line|method> [if expr] -
    \tset breakpoint to some position, (optionally) if expr == true
  }
end

.help_commandObject



53
54
55
# File 'lib/ruby-debug-ide/commands/breakpoints.rb', line 53

def help_command
  'break'
end

Instance Method Details

#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
# File 'lib/ruby-debug-ide/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 = realpath(file)
    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

#regexpObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ruby-debug-ide/commands/breakpoints.rb', line 5

def regexp
  / ^\s*
    b(?:reak)?
    (?: \s+
    (?:
      (\d+) |
      (.+?)[:.#]([^.:\s]+)
    ))?
    (?:\s+
      if\s+(.+)
    )?
    $
  /x
end