Class: PryDebugger::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-debugger/processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(pry_start_options = {}, &block) ⇒ Processor

Returns a new instance of Processor.


6
7
8
9
# File 'lib/pry-debugger/processor.rb', line 6

def initialize(pry_start_options = {}, &block)
  Debugger.handler = self
  @pry_start_options = pry_start_options
end

Instance Method Details

#at_breakpoint(context, breakpoint) ⇒ Object


54
55
56
# File 'lib/pry-debugger/processor.rb', line 54

def at_breakpoint(context, breakpoint)
  # TODO
end

#at_catchpoint(context, exception) ⇒ Object


58
59
60
# File 'lib/pry-debugger/processor.rb', line 58

def at_catchpoint(context, exception)
  # TODO
end

#at_line(context, file, line) ⇒ Object

— Callbacks from debugger C extension —


49
50
51
52
# File 'lib/pry-debugger/processor.rb', line 49

def at_line(context, file, line)
  return if file && TRACE_IGNORE_FILES.include?(File.expand_path(file))
  start_pry context
end

#run(&block) ⇒ Object


11
12
13
14
15
16
17
18
19
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
# File 'lib/pry-debugger/processor.rb', line 11

def run(&block)
  return_value = nil
  command = catch(:breakout_nav) do  # Throws from PryDebugger::Commands
    return_value = yield
    {}    # Nothing thrown == no navigational command
  end

  times = (command[:times] || 1).to_i   # Command argument
  times = 1 if times <= 0

  remote = @pry_start_options[:pry_remote] && PryDebugger.current_remote_server

  if [:step, :next].include? command[:action]
    Debugger.start
    if Debugger.current_context.frame_self.is_a? Debugger::Context
      # The first binding.pry call will have a frame inside Debugger. If we
      # step normally, it'll stop inside this Processor instead. So jump it
      # out to the above frame.
      #
      # TODO: times isn't respected
      Debugger.current_context.stop_frame = 1 # (remote ? 2 : 1)
    else
      if :next == command[:action]
        Debugger.current_context.step_over(times, 0)
      else  # step
        Debugger.current_context.step(times)
      end
    end
  elsif remote  # Continuing execution... cleanup DRb remote if running
    PryDebugger.current_remote_server.teardown
  end

  return_value
end