Class: Rubinius::Debugger::Command::SetBreakPoint

Inherits:
Rubinius::Debugger::Command show all
Defined in:
lib/rubinius/debugger/commands.rb

Direct Known Subclasses

SetTempBreakPoint

Instance Method Summary collapse

Methods inherited from Rubinius::Debugger::Command

commands, #current_frame, #current_method, descriptor, ext_help, help, #initialize, #listen, match?, pattern, #run_code, #variables

Methods included from Display

#ask, #crit, #display, #error, #info, #section

Constructor Details

This class inherits a constructor from Rubinius::Debugger::Command

Instance Method Details

#ask_deferred(klass_name, which, name, line) ⇒ Object



167
168
169
170
171
172
173
174
# File 'lib/rubinius/debugger/commands.rb', line 167

def ask_deferred(klass_name, which, name, line)
  answer = ask "Would you like to defer this breakpoint to later? [y/n] "

  if answer.strip.downcase[0] == ?y
    @debugger.add_deferred_breakpoint(klass_name, which, name, line)
    info "Deferred breakpoint created."
  end
end

#match_method(method_identifier) ⇒ Object

provide this method so it can be overriden for other languages wanting to use this debugger



123
124
125
# File 'lib/rubinius/debugger/commands.rb', line 123

def match_method(method_identifier)
  /([A-Z]\w*(?:::[A-Z]\w*)*)([.#]|::)([a-zA-Z0-9_\[\]]+[!?=]?)(?:[:](\d+))?(\s+if\s+.*)?/.match(method_identifier)
end

#run(args, temp = false) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/rubinius/debugger/commands.rb', line 127

def run(args, temp=false)
  m = match_method(args)
  unless m
    error "Unrecognized position: '#{args}'"
    return
  end

  klass_name = m[1]
  which      = m[2]
  name       = m[3]
  line       = m[4] ? m[4].to_i : nil
  condition  = m[5] ? m[5].sub(/\A\s+if\s+/, '') : nil

  begin
    klass = run_code(klass_name)
  rescue NameError
    error "Unable to find class/module: #{m[1]}"
    ask_deferred klass_name, which, name, line
    return
  end

  begin
    if which == "#"
      method = klass.instance_method(name)
    else
      method = klass.method(name)
    end
  rescue NameError
    error "Unable to find method '#{name}' in #{klass}"
    ask_deferred klass_name, which, name, line
    return
  end

  bp = @debugger.set_breakpoint_method args.strip, method, line, condition

  bp.set_temp! if temp

  return bp
end