Module: Debugger

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/ide/interface.rb,
lib/debugger/xml/ide/processor.rb,
lib/debugger/xml/vim/interface.rb,
lib/debugger/xml/vim/processor.rb,
lib/debugger/xml/vim/notification.rb,
lib/debugger/xml/multiprocess/monkey.rb,
lib/debugger/xml/extensions/processor.rb,
lib/debugger/xml/extensions/ide_server.rb,
lib/debugger/xml/extensions/vim_server.rb,
lib/debugger/xml/multiprocess/pre_child.rb,
lib/debugger/xml/extensions/commands/irb.rb,
lib/debugger/xml/extensions/commands/edit.rb,
lib/debugger/xml/extensions/commands/help.rb,
lib/debugger/xml/extensions/commands/info.rb,
lib/debugger/xml/extensions/commands/kill.rb,
lib/debugger/xml/extensions/commands/frame.rb,
lib/debugger/xml/extensions/commands/tmate.rb,
lib/debugger/xml/extensions/commands/trace.rb,
lib/debugger/xml/extensions/commands/inspect.rb,
lib/debugger/xml/extensions/commands/threads.rb,
lib/debugger/xml/extensions/commands/variables.rb,
lib/debugger/xml/ide/control_command_processor.rb,
lib/debugger/xml/vim/control_command_processor.rb

Defined Under Namespace

Modules: FrameFunctions, ThreadFunctions, VarFunctions, Xml Classes: CommandProcessor, Edit, HelpCommand, IRBCommand, InfoCommand, InspectCommand, KillCommand, TextMateCommand, TraceCommand, VarInstanceCommand

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.control_threadObject

Returns the value of attribute control_thread.



3
4
5
# File 'lib/debugger/xml/extensions/ide_server.rb', line 3

def control_thread
  @control_thread
end

.wait_for_startObject

Returns the value of attribute wait_for_start.



3
4
5
# File 'lib/debugger/xml/extensions/ide_server.rb', line 3

def wait_for_start
  @wait_for_start
end

Class Method Details

.proceedObject



27
28
29
30
# File 'lib/debugger/xml/extensions/ide_server.rb', line 27

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

.start_for_vim(options) ⇒ Object



6
7
8
9
10
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
# File 'lib/debugger/xml/extensions/vim_server.rb', line 6

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

.start_remote_ide(host, port) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/debugger/xml/extensions/ide_server.rb', line 5

def start_remote_ide(host, port)
  return if @control_thread
  @mutex = Mutex.new
  @proceed = ConditionVariable.new
  start
  @control_thread = DebugThread.new do
    server = TCPServer.new(host, port)
    $stderr.printf "Fast Debugger (debugger-xml #{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 = Xml::Ide::Interface.new(session)
      processor = Xml::Ide::ControlCommandProcessor.new(interface)
      self.handler = Xml::Ide::Processor.new(interface)
      processor.process_commands
    end
  end
  @mutex.synchronize { @proceed.wait(@mutex) } if wait_for_start
end