Class: RubyDebugServer
- Inherits:
-
Object
- Object
- RubyDebugServer
- Includes:
- Observable
- Defined in:
- ext/ae-ruby-debug/ae-ruby-debug.rb
Constant Summary collapse
- RDS_QUIET =
'RDS_QUIET'
Instance Attribute Summary collapse
-
#quit_confirm_request ⇒ Object
Returns the value of attribute quit_confirm_request.
Instance Method Summary collapse
-
#initialize(_caller, _arcadia = nil) ⇒ RubyDebugServer
constructor
A new instance of RubyDebugServer.
- #is_alive? ⇒ Boolean
- #kill ⇒ Object
- #notify(_state) ⇒ Object
- #set_alive(_value = false) ⇒ Object
- #start_session(_debug_event, _host = 'localhost', _remote_port = '8989') ⇒ Object
- #start_session_new(_filename, _host = 'localhost', _remote_port = '8989') ⇒ Object
Constructor Details
#initialize(_caller, _arcadia = nil) ⇒ RubyDebugServer
Returns a new instance of RubyDebugServer.
774 775 776 777 778 779 780 781 782 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 774 def initialize(_caller, _arcadia=nil) if _caller.respond_to? :rdebug_server_update ObserverCallback.new(self,_caller,:rdebug_server_update) end @arcadia = _arcadia @rdebug_file = _caller.rdebug_file @quit_confirm_request = false @alive = false end |
Instance Attribute Details
#quit_confirm_request ⇒ Object
Returns the value of attribute quit_confirm_request.
772 773 774 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 772 def quit_confirm_request @quit_confirm_request end |
Instance Method Details
#is_alive? ⇒ Boolean
790 791 792 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 790 def is_alive? @alive end |
#kill ⇒ Object
872 873 874 875 876 877 878 879 880 881 882 883 884 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 872 def kill begin if Arcadia.is_windows? @tid.join(2) @tid.kill! else Process.kill('QUIT',@pid) end notify(RDS_QUIET) rescue Exception => e Arcadia.console(self, 'msg'=>Arcadia.text('ext.ruby_debug.server.e.on_kill', [e.class, e.]), 'level'=>'debug') end end |
#notify(_state) ⇒ Object
886 887 888 889 890 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 886 def notify(_state) #p "----- notify ----- #{_state}" changed notify_observers(_state) end |
#set_alive(_value = false) ⇒ Object
794 795 796 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 794 def set_alive(_value=false) @alive = _value end |
#start_session(_debug_event, _host = 'localhost', _remote_port = '8989') ⇒ Object
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 798 def start_session(_debug_event, _host='localhost', _remote_port='8989') _filename = _debug_event.file commandLine = "#{Arcadia.ruby} #{@rdebug_file} --host #{_host} --port #{_remote_port} -sw '#{_filename}'" #p commandLine begin @alive = true if Arcadia.is_windows? @tid = Thread.new do if Kernel.system(commandLine) Kernel.system('y') else if @quit_confirm_request Arcadia.console(self, 'msg'=>"#{$?.inspect}") #Arcadia.new_msg(self,"#{$?.inspect}") else _event = Arcadia.process_event(RunCmdEvent.new(self, {'file'=>_filename})) Arcadia.console(self, 'msg'=>"#{_event.results[0].output}", 'level'=>'debug') #Arcadia.new_debug_msg(self,"#{_event.results[0].output}") end end set_alive(false) notify(RDS_QUIET) if _debug_event.persistent == false && File.basename(_debug_event.file)[0..1] == '~~' File.delete(_debug_event.file) if File.exist?(_debug_event.file) end end else @pid = Process.fork do # pid = Process.pid # abort_action = proc{ # ArcadiaUtils.unix_child_pids(pid).each {|pid| # Process.kill(9,pid.to_i) # } # Process.kill(9,pid.to_i) # } # # alive_check = proc{ # num = `ps -p #{pid}|wc -l` # num.to_i > 1 # } # Arcadia.process_event(SubProcessEvent.new(self,'pid'=>pid, 'name'=>"debugging :#{_filename}",'abort_action'=>abort_action, 'alive_check'=>alive_check)) if File.basename(Arcadia.ruby) != 'ruby' commandLine="export PATH=#{Arcadia.instance.local_dir}/bin:$PATH && #{commandLine}" end if Kernel.system(commandLine) set_alive(false) #p "alive=#{is_alive?}" notify(RDS_QUIET) Kernel.system('y') if _debug_event.persistent == false && File.basename(_debug_event.file)[0..1] == '~~' File.delete(_debug_event.file) if File.exist?(_debug_event.file) end Kernel.exit! else Kernel.exit! Arcadia.console(self, 'msg'=>"#{$?.inspect}", 'level'=>'debug') #Arcadia.new_debug_msg(self,"#{$?.inspect}") end #p "@alive=#{@alive}" #notify(RDS_QUIET) #Process.wait end end rescue Exception => e Arcadia.console(self, 'msg'=>Arcadia.text('ext.ruby_debug.server.e.on_start', [e.class, e.]), 'level'=>'debug') #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
784 785 786 787 788 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 784 def start_session_new(_filename, _host='localhost', _remote_port='8989') commandLine = "#{@rdebug_file} --host #{_host} --port #{_remote_port} -sw #{_filename}" #Arcadia.process_event(SystemExecEvent.new(self, 'command'=>commandLine)) Arcadia.process_event(RunCmdEvent.new(self, 'cmd'=>commandLine, 'file'=>_filename)) end |