@@ -73,17 +73,17 @@ def interrupt_last
7373 end
7474 end
7575
76- def start_server ( host = nil , port = 1234 , notify_dispatcher = false )
76+ def start_server ( host = nil , port = 1234 , notify_dispatcher = false , socket_path : nil )
7777 return if started?
7878 start
79- start_control ( host , port , notify_dispatcher )
79+ start_control ( host , port , notify_dispatcher , socket_path : socket_path )
8080 end
8181
8282 def prepare_debugger ( options )
8383 @mutex = Mutex . new
8484 @proceed = ConditionVariable . new
8585
86- start_server ( options . host , options . port , options . notify_dispatcher )
86+ start_server ( options . host , options . port , options . notify_dispatcher , socket_path : options . socket_path )
8787
8888 raise "Control thread did not start (#{ @control_thread } }" unless @control_thread && @control_thread . alive?
8989
@@ -111,25 +111,38 @@ def run_prog_script
111111 end
112112 end
113113
114- def start_control ( host , port , notify_dispatcher )
114+ def start_control ( host , port , notify_dispatcher , socket_path : nil )
115115 raise "Debugger is not started" unless started?
116116 return if @control_thread
117117 @control_thread = DebugThread . new do
118118 begin
119- # 127.0.0.1 seemingly works with all systems and with IPv6 as well.
120- # "localhost" and nil have problems on some systems.
121- host ||= '127.0.0.1'
122-
123- server = notify_dispatcher_if_needed ( host , port , notify_dispatcher ) do |real_port , port_changed |
124- s = TCPServer . new ( host , real_port )
125- print_greeting_msg $stderr, host , real_port , port_changed ? "Subprocess" : "Fast" if defined? IDE_VERSION
126- s
119+ if socket_path . nil?
120+ # 127.0.0.1 seemingly works with all systems and with IPv6 as well.
121+ # "localhost" and nil have problems on some systems.
122+ host ||= '127.0.0.1'
123+
124+ server = notify_dispatcher_if_needed ( host , port , notify_dispatcher ) do |real_port , port_changed |
125+ s = TCPServer . new ( host , real_port )
126+ print_greeting_msg $stderr, host , real_port , port_changed ? "Subprocess" : "Fast" if defined? IDE_VERSION
127+ s
128+ end
129+ else
130+ raise "Cannot specify host and socket_file at the same time" if host
131+ File . delete ( socket_path ) if File . exist? ( socket_path )
132+ server = UNIXServer . new ( socket_path )
133+ print_greeting_msg $stderr, nil , nil , "Fast" , socket_path : socket_path if defined? IDE_VERSION
127134 end
128135
129136 return unless server
130137
131138 while ( session = server . accept )
132- $stderr. puts "Connected from #{ session . peeraddr [ 2 ] } " if Debugger . cli_debug
139+ if Debugger . cli_debug
140+ if session . peeraddr == 'AF_INET'
141+ $stderr. puts "Connected from #{ session . peeraddr [ 2 ] } "
142+ else
143+ $stderr. puts "Connected from local client"
144+ end
145+ end
133146 dispatcher = ENV [ 'IDE_PROCESS_DISPATCHER' ]
134147 if dispatcher
135148 ENV [ 'IDE_PROCESS_DISPATCHER' ] = "#{ session . peeraddr [ 2 ] } :#{ dispatcher } " unless dispatcher . include? ( ":" )
0 commit comments