Class: RubyDebugServer

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
ext/ae-ruby-debug/ae-ruby-debug.rb

Constant Summary collapse

RDS_QUIET =
'RDS_QUIET'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_caller, _arcadia = nil) ⇒ RubyDebugServer

Returns a new instance of RubyDebugServer.



694
695
696
697
698
699
700
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 694

def initialize(_caller, _arcadia=nil)
  if _caller.respond_to? :rdebug_server_update
    ObserverCallback.new(self,_caller,:rdebug_server_update)
  end
  @arcadia = _arcadia
  @quit_confirm_request = false
end

Instance Attribute Details

#quit_confirm_requestObject

Returns the value of attribute quit_confirm_request.



692
693
694
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 692

def quit_confirm_request
  @quit_confirm_request
end

Instance Method Details

#is_windows?Boolean

Returns:

  • (Boolean)


763
764
765
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 763

def is_windows?
  !(RUBY_PLATFORM =~ /(win|w)32$/).nil?
end

#killObject



749
750
751
752
753
754
755
756
757
758
759
760
761
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 749

def kill
  begin
    if is_windows?
      @tid.join(2)
      @tid.kill!
    else
      Process.kill('QUIT',@pid)
    end
    notify(RDS_QUIET)
  rescue Exception => e
    Arcadia.new_debug_msg(self,"Error on start_server : #{e.class}:#{e.message}")    
  end
end

#notify(_state) ⇒ Object



767
768
769
770
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 767

def notify(_state)
   changed
   notify_observers(_state)
end

#start_session(_filename, _host = 'localhost', _remote_port = '8989') ⇒ Object



711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 711

def start_session(_filename, _host='localhost', _remote_port='8989')
  if is_windows?
    commandLine = "rdebug.cmd --port #{_remote_port} -sw #{_filename}"
  else
    commandLine = "rdebug --host #{_host} --port #{_remote_port} -sw #{_filename}"
  end
  begin
    if is_windows?
      @tid = Thread.new {
        if Kernel.system(commandLine)
            Kernel.system('y')
        else
          if @quit_confirm_request
            Arcadia.new_msg(self,"#{$?.inspect}")    
          else
            _event = Arcadia.process_event(RunRubyFileEvent.new(self, 'file'=>_filename))
            Arcadia.new_debug_msg(self,"#{_event.results[0].output}")    
          end
        end
        notify(RDS_QUIET)
      }
    else
      @pid = Process.fork {
        if Kernel.system(commandLine)
          Kernel.system('y')
        else
          Kernel.exit!
          Arcadia.new_debug_msg(self,"#{$?.inspect}")    
        end
        Process.wait
        notify(RDS_QUIET)
      }
    end
  rescue Exception => e
    Arcadia.new_debug_msg(self,"Error on start_server : #{e.class}:#{e.message}")    
  end
end

#start_session_new(_filename, _host = 'localhost', _remote_port = '8989') ⇒ Object



702
703
704
705
706
707
708
709
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 702

def start_session_new(_filename, _host='localhost', _remote_port='8989')
  if is_windows?
     commandLine = "rdebug.cmd --host #{_host} --port #{_remote_port} -sw #{_filename}"
  else
     commandLine = "rdebug --host #{_host} --port #{_remote_port} -sw #{_filename}"
  end
  Arcadia.process_event(SystemExecEvent.new(self, 'command'=>commandLine))
end