Skip to content

Commit 288fb35

Browse files
committed
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
1 parent bfe6be4 commit 288fb35

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

lib/debug/server_dap.rb

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ def dap_setup bytes
184184
end
185185

186186
def send **kw
187-
kw[:seq] = @seq += 1
188-
str = JSON.dump(kw)
189-
@sock.write "Content-Length: #{str.bytesize}\r\n\r\n#{str}"
190-
show_protocol '<', str
187+
if sock = @sock
188+
kw[:seq] = @seq += 1
189+
str = JSON.dump(kw)
190+
sock.write "Content-Length: #{str.bytesize}\r\n\r\n#{str}"
191+
show_protocol '<', str
192+
end
191193
end
192194

193195
def send_response req, success: true, message: nil, **kw
@@ -319,11 +321,21 @@ def process
319321
send_response req, breakpoints: filters
320322

321323
when 'disconnect'
322-
if args.fetch("terminateDebuggee", false)
323-
@q_msg << 'kill!'
324+
terminate = args.fetch("terminateDebuggee", false)
325+
326+
if SESSION.in_subsession?
327+
if terminate
328+
@q_msg << 'kill!'
329+
else
330+
@q_msg << 'continue'
331+
end
324332
else
325-
@q_msg << 'continue'
333+
if terminate
334+
@q_msg << 'kill!'
335+
pause
336+
end
326337
end
338+
327339
send_response req
328340

329341
## control

0 commit comments

Comments
 (0)