Skip to content

Commit cd0fd93

Browse files
committed
Allow starting debug server without opening apps
1 parent ab937ac commit cd0fd93

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

lib/debug/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def self.parse_argv argv
324324
when 'tcp'
325325
config[:open] = true
326326
config[:port] ||= 0
327-
when 'vscode', 'chrome', 'cdp'
327+
when 'vscode', 'dap', 'chrome', 'cdp'
328328
config[:open] = f&.downcase
329329
else
330330
raise "Unknown option for --open: #{f}"

lib/debug/server.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ def after_fork_parent
376376
# do nothing
377377
end
378378

379-
def vscode_setup debug_port
379+
def vscode_setup debug_port, launch_vscode: true
380380
require_relative 'server_dap'
381-
UI_DAP.setup debug_port
381+
UI_DAP.setup debug_port if launch_vscode
382382
end
383383
end
384384

@@ -442,8 +442,10 @@ def accept
442442
case CONFIG[:open]
443443
when 'chrome'
444444
chrome_setup
445+
when 'dap-server' # Start in Debug Adapter Protocol mode without launching Visual Studio Code
446+
vscode_setup @local_addr.inspect_sockaddr, launch_vscode: false
445447
when 'vscode'
446-
vscode_setup @local_addr.inspect_sockaddr
448+
vscode_setup @local_addr.inspect_sockaddr, launch_vscode: true
447449
end
448450

449451
Socket.accept_loop(socks) do |sock, client|
@@ -496,7 +498,12 @@ def accept
496498
end
497499

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

501508
begin
502509
Socket.unix_server_loop @sock_path do |sock, client|

lib/debug/session.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,9 +1118,15 @@ def register_default_command
11181118
when 'vscode'
11191119
CONFIG[:open] = 'vscode'
11201120
::DEBUGGER__.open nonstop: true
1121-
when 'chrome', 'cdp'
1121+
when 'dap'
1122+
CONFIG[:open] = 'dap'
1123+
::DEBUGGER__.open nonstop: true
1124+
when 'chrome'
11221125
CONFIG[:open] = 'chrome'
11231126
::DEBUGGER__.open_tcp host: CONFIG[:host], port: (CONFIG[:port] || 0), nonstop: true
1127+
when 'cdp'
1128+
CONFIG[:open] = 'cdp'
1129+
::DEBUGGER__.open_tcp host: CONFIG[:host], port: (CONFIG[:port] || 0), nonstop: true
11241130
else
11251131
raise "Unknown arg: #{arg}"
11261132
end

0 commit comments

Comments
 (0)