Module: DebuggerXml

Defined in:
lib/debugger_xml.rb,
lib/debugger_xml/version.rb,
lib/debugger_xml/ide/logger.rb,
lib/debugger_xml/vim/logger.rb,
lib/debugger_xml/fake_logger.rb,
lib/debugger_xml/byebug_proxy.rb,
lib/debugger_xml/ide/interface.rb,
lib/debugger_xml/ide/processor.rb,
lib/debugger_xml/vim/interface.rb,
lib/debugger_xml/vim/processor.rb,
lib/debugger_xml/debugger_proxy.rb,
lib/debugger_xml/vim/notification.rb,
lib/debugger_xml/multiprocess/monkey.rb,
lib/debugger_xml/multiprocess/pre_child.rb,
lib/debugger_xml/ide/control_command_processor.rb,
lib/debugger_xml/vim/control_command_processor.rb

Defined Under Namespace

Modules: Ide, MultiProcess, Vim Classes: ByebugProxy, DebuggerProxy, FakeLogger

Constant Summary collapse

VERSION =
"0.4.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.control_threadObject

Returns the value of attribute control_thread.



10
11
12
# File 'lib/debugger_xml.rb', line 10

def control_thread
  @control_thread
end

.handlerObject

Returns the value of attribute handler.



10
11
12
# File 'lib/debugger_xml.rb', line 10

def handler
  @handler
end

.loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/debugger_xml.rb', line 10

def logger
  @logger
end

.queueObject

Returns the value of attribute queue.



10
11
12
# File 'lib/debugger_xml.rb', line 10

def queue
  @queue
end

.wait_for_startObject

Returns the value of attribute wait_for_start.



10
11
12
# File 'lib/debugger_xml.rb', line 10

def wait_for_start
  @wait_for_start
end

Class Method Details

.proceedObject



75
76
77
78
# File 'lib/debugger_xml.rb', line 75

def proceed
  return unless @mutex
  @mutex.synchronize { @proceed.signal }
end

.start_for_vim(proxy, options) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/debugger_xml.rb', line 35

def start_for_vim(proxy, options)
  return if @control_thread
  logger.puts("Going to daemonize")
  daemonize!
  logger.puts("Successfully daemonized")
  $stdout.reopen(options.output_file, 'w')
  $stdout.sync
  $stderr.reopen($stdout)
  logger.puts("Redirected stderr")
  @mutex = Mutex.new
  @proceed = ConditionVariable.new
  @queue = Queue.new
  proxy.start
  logger.puts("Started debugger")
  File.unlink(options.socket) if File.exist?(options.socket)
  server = UNIXServer.new(options.socket)
  Vim::Notification.new("establish_connection", options).send
  logger.puts("Sent 'established_connection' command")
  @control_thread = proxy.debug_thread_class.new do
    begin
      while (session = server.accept)
        logger.puts("Accepted connection");
        interface = Vim::Interface.new(session, options)
        processor = Vim::ControlCommandProcessor.new(interface, proxy)
        proxy.handler = Vim::Processor.new(processor, interface, proxy)
        logger.puts("Going to process commands");
        processor.process_commands
      end
    rescue Exception => e
      logger.puts("INTERNAL ERROR!!! #{$!}") rescue nil
      logger.puts($!.backtrace.map { |l| "\t#{l}" }.join("\n")) rescue nil
      raise e
    ensure
      logger.puts("Closing server");
      server.close
    end
  end
  @mutex.synchronize { @proceed.wait(@mutex) } if wait_for_start
end

.start_remote_ide(proxy, host, port) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/debugger_xml.rb', line 12

def start_remote_ide(proxy, host, port)
  return if @control_thread
  @mutex = Mutex.new
  @proceed = ConditionVariable.new
  @queue = Queue.new
  proxy.start
  @control_thread = proxy.debug_thread_class.new do
    server = TCPServer.new(host, port)
    $stderr.printf "Fast Debugger (debugger-xml #{VERSION}) listens on #{host}:#{port}\n"
    while (session = server.accept)
      dispatcher = ENV['IDE_PROCESS_DISPATCHER']
      if dispatcher && !dispatcher.include?(":")
        ENV['IDE_PROCESS_DISPATCHER'] = "#{session.peeraddr[2]}:#{dispatcher}"
      end
      interface = DebuggerXml::Ide::Interface.new(session)
      processor = DebuggerXml::Ide::ControlCommandProcessor.new(interface, proxy)
      debugger_class.handler = DebuggerXml::Ide::Processor.new(interface, proxy)
      processor.process_commands
    end
  end
  @mutex.synchronize { @proceed.wait(@mutex) } if wait_for_start
end