Skip to content

Commit

Permalink
Allow starting debug server without opening apps
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov committed Jul 7, 2023
1 parent 4ec9d7a commit 8a42a66
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/debug/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
15 changes: 11 additions & 4 deletions lib/debug/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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|
Expand Down
8 changes: 7 additions & 1 deletion lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8a42a66

Please sign in to comment.