diff --git a/README.md b/README.md
index 040bba498..aa886ad20 100644
--- a/README.md
+++ b/README.md
@@ -138,7 +138,7 @@ d => 4
[1, 2, 3, 4]
```
-### Invoke the program from the debugger as a traditional debuggers
+### Invoke the program from the debugger as a traditional debugger
If you don't want to modify the source code, you can set breakpoints with a debug command `break` (`b` for short).
Using `rdbg` command (or `bundle exec rdbg`) to launch the program without any modifications, you can run the program with the debugger.
@@ -253,7 +253,7 @@ Examples:
* `rdbg -c -- bundle exec rake test`
* `rdbg -c -- ruby target.rb` is same as `rdbg target.rb`
-NOTE: `--` is needed to separate the command line options for `rdbg` and invoking command. For example, `rdbg -c rake -T` is recognized like `rdbg -c -T -- rake`. It should be `rdbg -c -- rake -T`.
+NOTE: `--` is needed to separate the command line options for `rdbg` from the invoked command. For example, `rdbg -c rake -T` is recognized like `rdbg -c -T -- rake`. It should be `rdbg -c -- rake -T`.
NOTE: If you want to use bundler (`bundle` command), you need to write `gem debug` line in your `Gemfile`.
@@ -358,15 +358,20 @@ $ RUBY_DEBUG_PORT=12345 ruby target.rb
### Integration with external debugger frontend
-You can attach with external debugger frontend with VSCode and Chrome.
+You can start a debugging session for an external debugger frontend using:
-```
+```shell
$ rdbg --open=[frontend] target.rb
```
-will open a debug port and `[frontend]` can attach to the port.
+The currently available frontends are:
-Also `open` command allows opening the debug port.
+| Flag | Frontend |
+|------|----------|
+| `--open=vscode` | Starts a DAP session and automatically opens Visual Studio Code. |
+| `--open=dap` | Starts a debug adapter protocol (DAP) session, _without_ opening Visual Studio code. This allows for another DAP client to connect instead.
+| `--open=chrome` | Starts a CDP session and automatically opens Chrome. |
+| `--open=cdp` | Starts a Chrome debug protocol (CDP) session, _without_ opening Chrome. This allows for another CDP client to connect instead.
#### VSCode integration
diff --git a/lib/debug/config.rb b/lib/debug/config.rb
index ab4c9c559..d925f2446 100644
--- a/lib/debug/config.rb
+++ b/lib/debug/config.rb
@@ -324,7 +324,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 0915b5bd5..8d927cf10 100644
--- a/lib/debug/server.rb
+++ b/lib/debug/server.rb
@@ -376,9 +376,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
@@ -442,8 +442,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|
@@ -496,7 +498,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 c5b410182..b07052fe9 100644
--- a/lib/debug/session.rb
+++ b/lib/debug/session.rb
@@ -1118,9 +1118,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
diff --git a/misc/README.md.erb b/misc/README.md.erb
index d591a2f2b..f8cbabf87 100644
--- a/misc/README.md.erb
+++ b/misc/README.md.erb
@@ -138,7 +138,7 @@ d => 4
[1, 2, 3, 4]
```
-### Invoke the program from the debugger as a traditional debuggers
+### Invoke the program from the debugger as a traditional debugger
If you don't want to modify the source code, you can set breakpoints with a debug command `break` (`b` for short).
Using `rdbg` command (or `bundle exec rdbg`) to launch the program without any modifications, you can run the program with the debugger.
@@ -253,7 +253,7 @@ Examples:
* `rdbg -c -- bundle exec rake test`
* `rdbg -c -- ruby target.rb` is same as `rdbg target.rb`
-NOTE: `--` is needed to separate the command line options for `rdbg` and invoking command. For example, `rdbg -c rake -T` is recognized like `rdbg -c -T -- rake`. It should be `rdbg -c -- rake -T`.
+NOTE: `--` is needed to separate the command line options for `rdbg` from the invoked command. For example, `rdbg -c rake -T` is recognized like `rdbg -c -T -- rake`. It should be `rdbg -c -- rake -T`.
NOTE: If you want to use bundler (`bundle` command), you need to write `gem debug` line in your `Gemfile`.
@@ -358,15 +358,20 @@ $ RUBY_DEBUG_PORT=12345 ruby target.rb
### Integration with external debugger frontend
-You can attach with external debugger frontend with VSCode and Chrome.
+You can start a debugging session for an external debugger frontend using:
-```
+```shell
$ rdbg --open=[frontend] target.rb
```
-will open a debug port and `[frontend]` can attach to the port.
+The currently available frontends are:
-Also `open` command allows opening the debug port.
+| Flag | Frontend |
+|------|----------|
+| `--open=vscode` | Starts a DAP session and automatically opens Visual Studio Code. |
+| `--open=dap` | Starts a debug adapter protocol (DAP) session, _without_ opening Visual Studio code. This allows for another DAP client to connect instead.
+| `--open=chrome` | Starts a CDP session and automatically opens Chrome. |
+| `--open=cdp` | Starts a Chrome debug protocol (CDP) session, _without_ opening Chrome. This allows for another CDP client to connect instead.
#### VSCode integration