class DebuggerXml::Ide::Processor

Attributes

context[R]
display[R]
file[R]
interface[RW]
line[R]

Public Class Methods

new(interface, proxy) click to toggle source
# File lib/debugger_xml/ide/processor.rb, line 31
def initialize(interface, proxy)
  @mutex = Mutex.new
  @interface = interface
  @proxy = proxy
  @display = []
end

Private Class Methods

protect(mname) click to toggle source

Copied from debugger gem.

# File lib/debugger_xml/ide/processor.rb, line 8
def protect(mname)
  alias_method "__#{mname}", mname
  module_eval %Q{
    def #{mname}(*args)
      @mutex.synchronize do
        return unless @interface
        __#{mname}(*args)
      end
    rescue IOError, Errno::EPIPE
      self.interface = nil
    rescue SignalException
      raise
    rescue Exception
      @interface.print "INTERNAL ERROR!!! #\{$!\}\n" rescue nil
      @interface.print $!.backtrace.map{|l| "\t#\{l\}"}.join("\n") rescue nil
    end
  }
end

Public Instance Methods

at_breakpoint(context, breakpoint) click to toggle source
# File lib/debugger_xml/ide/processor.rb, line 38
def at_breakpoint(context, breakpoint)
  raise "@last_breakpoint supposed to be nil. is #{@last_breakpoint}" if @last_breakpoint
  # at_breakpoint is immediately followed by #at_line event. So postpone breakpoint printing until #at_line.
  @last_breakpoint = breakpoint
end
at_catchpoint(context, excpt) click to toggle source

TODO: Catching exceptions doesn't work so far, need to fix

# File lib/debugger_xml/ide/processor.rb, line 46
def at_catchpoint(context, excpt)
end
at_line(context, file, line) click to toggle source
# File lib/debugger_xml/ide/processor.rb, line 53
def at_line(context, file, line)
  if context.nil? || context.stop_reason == :step
    print_file_line(context, file, line)
  end
  line_event(context, file, line)
end
at_line?() click to toggle source
# File lib/debugger_xml/ide/processor.rb, line 67
def at_line?
  !!@line
end
at_return(context, file, line) click to toggle source
# File lib/debugger_xml/ide/processor.rb, line 61
def at_return(context, file, line)
  print_file_line(context, file, line)
  context.stop_frame = -1
  line_event(context, file, line)
end
at_tracing(*args) click to toggle source

We don't have tracing for IDE

# File lib/debugger_xml/ide/processor.rb, line 50
def at_tracing(*args)
end

Private Instance Methods

line_event(context, file, line) click to toggle source
# File lib/debugger_xml/ide/processor.rb, line 86
def line_event(context, file, line)
  @line = line
  @file = file
  @context = context
  if @last_breakpoint
    # followed after #at_breakpoint in the same thread. Print breakpoint
    # now when @line, @file and @context are correctly set to prevent race
    # condition with `control thread'.
    n = @proxy.breakpoints.index(@last_breakpoint) + 1
    @interface.print(@proxy.print("breakpoints.stop_at_breakpoint",
      id: n, file: @file, line: @line, thread_id: @proxy.current_context.thnum
    ))
  end
  if @proxy.debug_thread?(@context)
    raise @proxy.print("thread.errors.debug_trace", thread: @context.thread)
  end
  # will be resumed by commands like `step', `next', `continue', `finish'
  # from `control thread'
  stop_thread
ensure
  @line = nil
  @file = nil
  @context = nil
  @last_breakpoint = nil
  @proxy.inspect_command_class.clear_references
end
print_file_line(context, file, line) click to toggle source
stop_thread() click to toggle source
# File lib/debugger_xml/ide/processor.rb, line 113
def stop_thread
  Thread.stop
end