Class: Debugger::AddBreakpoint

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/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, #find, inherited, #initialize, load_commands, #match, method_missing, options

Constructor Details

This class inherits a constructor from Debugger::Command

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



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

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



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

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
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

#regexpObject



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

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