Skip to content

Commit 8a42a66

Browse files
committed
Allow starting debug server without opening apps
1 parent 4ec9d7a commit 8a42a66

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

lib/debug/config.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def self.parse_argv argv
322322
when 'tcp'
323323
config[:open] = true
324324
config[:port] ||= 0
325-
when 'vscode', 'chrome', 'cdp'
325+
when 'vscode', 'dap', 'chrome', 'cdp'
326326
config[:open] = f&.downcase
327327
else
328328
raise "Unknown option for --open: #{f}"

lib/debug/server.rb

+11-4
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ def after_fork_parent
374374
# do nothing
375375
end
376376

377-
def vscode_setup debug_port
377+
def vscode_setup debug_port, launch_vscode: true
378378
require_relative 'server_dap'
379-
UI_DAP.setup debug_port
379+
UI_DAP.setup debug_port if launch_vscode
380380
end
381381
end
382382

@@ -440,8 +440,10 @@ def accept
440440
case CONFIG[:open]
441441
when 'chrome'
442442
chrome_setup
443+
when 'dap-server' # Start in Debug Adapter Protocol mode without launching Visual Studio Code
444+
vscode_setup @local_addr.inspect_sockaddr, launch_vscode: false
443445
when 'vscode'
444-
vscode_setup @local_addr.inspect_sockaddr
446+
vscode_setup @local_addr.inspect_sockaddr, launch_vscode: true
445447
end
446448

447449
Socket.accept_loop(socks) do |sock, client|
@@ -494,7 +496,12 @@ def accept
494496
end
495497

496498
::DEBUGGER__.warn "Debugger can attach via UNIX domain socket (#{@sock_path})"
497-
vscode_setup @sock_path if CONFIG[:open] == 'vscode'
499+
case CONFIG[:open]
500+
when 'dap-server' # Start in Debug Adapter Protocol mode without launching Visual Studio Code
501+
vscode_setup @sock_path, launch_vscode: false
502+
when 'vscode'
503+
vscode_setup @sock_path, launch_vscode: true
504+
end
498505

499506
begin
500507
Socket.unix_server_loop @sock_path do |sock, client|

lib/debug/session.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,15 @@ def register_default_command
11011101
when 'vscode'
11021102
CONFIG[:open] = 'vscode'
11031103
::DEBUGGER__.open nonstop: true
1104-
when 'chrome', 'cdp'
1104+
when 'dap'
1105+
CONFIG[:open] = 'dap'
1106+
::DEBUGGER__.open nonstop: true
1107+
when 'chrome'
11051108
CONFIG[:open] = 'chrome'
11061109
::DEBUGGER__.open_tcp host: CONFIG[:host], port: (CONFIG[:port] || 0), nonstop: true
1110+
when 'cdp'
1111+
CONFIG[:open] = 'cdp'
1112+
::DEBUGGER__.open_tcp host: CONFIG[:host], port: (CONFIG[:port] || 0), nonstop: true
11071113
else
11081114
raise "Unknown arg: #{arg}"
11091115
end

0 commit comments

Comments
 (0)