From 735ca68b243a1fd45e8d0f03a073784b18e65dbb Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 8 Jul 2022 16:56:39 +0900 Subject: [PATCH] check `in_subsession?` on disconnect request This message can be received while in the subsession or not (running debuggee program) and it should change the handling. Also `UI_DAP#event` can be called after closing the socket so so `send` should check `@sock` is available or not. fix #630 --- lib/debug/server_dap.rb | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/debug/server_dap.rb b/lib/debug/server_dap.rb index d048b130d..5c6b8d4b2 100644 --- a/lib/debug/server_dap.rb +++ b/lib/debug/server_dap.rb @@ -184,10 +184,12 @@ def dap_setup bytes end def send **kw - kw[:seq] = @seq += 1 - str = JSON.dump(kw) - @sock.write "Content-Length: #{str.bytesize}\r\n\r\n#{str}" - show_protocol '<', str + if sock = @sock + kw[:seq] = @seq += 1 + str = JSON.dump(kw) + sock.write "Content-Length: #{str.bytesize}\r\n\r\n#{str}" + show_protocol '<', str + end end def send_response req, success: true, message: nil, **kw @@ -319,11 +321,21 @@ def process send_response req, breakpoints: filters when 'disconnect' - if args.fetch("terminateDebuggee", false) - @q_msg << 'kill!' + terminate = args.fetch("terminateDebuggee", false) + + if SESSION.in_subsession? + if terminate + @q_msg << 'kill!' + else + @q_msg << 'continue' + end else - @q_msg << 'continue' + if terminate + @q_msg << 'kill!' + pause + end end + send_response req ## control