From 8a42a6655982fe8f250de0dc65fb2a2e1692428a Mon Sep 17 00:00:00 2001 From: Alexander Momchilov Date: Thu, 6 Jul 2023 22:12:51 -0400 Subject: [PATCH] Allow starting debug server without opening apps --- lib/debug/config.rb | 2 +- lib/debug/server.rb | 15 +++++++++++---- lib/debug/session.rb | 8 +++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/debug/config.rb b/lib/debug/config.rb index f6f1a066d..bcc9077f0 100644 --- a/lib/debug/config.rb +++ b/lib/debug/config.rb @@ -322,7 +322,7 @@ def self.parse_argv argv when 'tcp' config[:open] = true config[:port] ||= 0 - when 'vscode', 'chrome', 'cdp' + when 'vscode', 'dap', 'chrome', 'cdp' config[:open] = f&.downcase else raise "Unknown option for --open: #{f}" diff --git a/lib/debug/server.rb b/lib/debug/server.rb index a67922ac1..1d435848d 100644 --- a/lib/debug/server.rb +++ b/lib/debug/server.rb @@ -374,9 +374,9 @@ def after_fork_parent # do nothing end - def vscode_setup debug_port + def vscode_setup debug_port, launch_vscode: true require_relative 'server_dap' - UI_DAP.setup debug_port + UI_DAP.setup debug_port if launch_vscode end end @@ -440,8 +440,10 @@ def accept case CONFIG[:open] when 'chrome' chrome_setup + when 'dap-server' # Start in Debug Adapter Protocol mode without launching Visual Studio Code + vscode_setup @local_addr.inspect_sockaddr, launch_vscode: false when 'vscode' - vscode_setup @local_addr.inspect_sockaddr + vscode_setup @local_addr.inspect_sockaddr, launch_vscode: true end Socket.accept_loop(socks) do |sock, client| @@ -494,7 +496,12 @@ def accept end ::DEBUGGER__.warn "Debugger can attach via UNIX domain socket (#{@sock_path})" - vscode_setup @sock_path if CONFIG[:open] == 'vscode' + case CONFIG[:open] + when 'dap-server' # Start in Debug Adapter Protocol mode without launching Visual Studio Code + vscode_setup @sock_path, launch_vscode: false + when 'vscode' + vscode_setup @sock_path, launch_vscode: true + end begin Socket.unix_server_loop @sock_path do |sock, client| diff --git a/lib/debug/session.rb b/lib/debug/session.rb index e9d95775c..4a1d99c94 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -1101,9 +1101,15 @@ def register_default_command when 'vscode' CONFIG[:open] = 'vscode' ::DEBUGGER__.open nonstop: true - when 'chrome', 'cdp' + when 'dap' + CONFIG[:open] = 'dap' + ::DEBUGGER__.open nonstop: true + when 'chrome' CONFIG[:open] = 'chrome' ::DEBUGGER__.open_tcp host: CONFIG[:host], port: (CONFIG[:port] || 0), nonstop: true + when 'cdp' + CONFIG[:open] = 'cdp' + ::DEBUGGER__.open_tcp host: CONFIG[:host], port: (CONFIG[:port] || 0), nonstop: true else raise "Unknown arg: #{arg}" end