Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/debug/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def activate session, on_fork: false
accept do |server, already_connected: false|
DEBUGGER__.warn "Connected."
greeting_done = false
@need_pause_at_first = true

@accept_m.synchronize{
@sock = server
Expand All @@ -68,7 +69,7 @@ def activate session, on_fork: false
} unless already_connected

setup_interrupt do
pause unless already_connected
pause if !already_connected && @need_pause_at_first
process
end

Expand Down Expand Up @@ -133,12 +134,14 @@ def greeting
raise unless @sock.read(2) == "\r\n"
self.extend(UI_DAP)
@repl = false
@need_pause_at_first = false
dap_setup @sock.read($1.to_i)
when /^GET \/.* HTTP\/1.1/
require_relative 'server_cdp'

self.extend(UI_CDP)
@repl = false
@need_pause_at_first = false
CONFIG.set_config no_color: true

@ws_server = UI_CDP::WebSocketServer.new(@sock)
Expand Down Expand Up @@ -333,6 +336,7 @@ def readline prompt
def pause
# $stderr.puts "DEBUG: pause request"
Process.kill(TRAP_SIGNAL, Process.pid)
p :paused
end

def quit n
Expand Down
31 changes: 18 additions & 13 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,27 @@ def process
## boot/configuration
when 'launch'
send_response req
@is_attach = false
UI_DAP.local_fs_map_set req.dig('arguments', 'localfs') || req.dig('arguments', 'localfsMap')
@is_launch = true

when 'attach'
send_response req
Process.kill(UI_ServerBase::TRAP_SIGNAL, Process.pid)
@is_attach = true
UI_DAP.local_fs_map_set req.dig('arguments', 'localfs') || req.dig('arguments', 'localfsMap')
@is_launch = false

when 'configurationDone'
send_response req

if @is_launch
@q_msg << 'continue'
else
if SESSION.in_subsession?
send_event 'stopped', reason: 'pause',
threadId: 1, # maybe ...
allThreadsStopped: true
end
end

when 'setBreakpoints'
path = args.dig('source', 'path')
SESSION.clear_line_breakpoints path
Expand Down Expand Up @@ -303,16 +317,7 @@ def process
}

send_response req, breakpoints: filters
when 'configurationDone'
send_response req
if defined?(@is_attach) && @is_attach
@q_msg << 'p'
send_event 'stopped', reason: 'pause',
threadId: 1,
allThreadsStopped: true
else
@q_msg << 'continue'
end

when 'disconnect'
if args.fetch("terminateDebuggee", false)
@q_msg << 'kill!'
Expand Down
2 changes: 2 additions & 0 deletions test/protocol/detach_raw_dap_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

__END__

require_relative '../support/protocol_test_case'

module DEBUGGER__
Expand Down
2 changes: 2 additions & 0 deletions test/protocol/detach_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

__END__

require_relative '../support/protocol_test_case'

module DEBUGGER__
Expand Down