Skip to content

Commit

Permalink
check in_subsession? on disconnect request
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ko1 committed Jul 8, 2022
1 parent bfe6be4 commit 288fb35
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 288fb35

Please sign in to comment.