You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugging.md
+11-11
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ These debugging features are possible by using [Delve](https://github.com/go-del
6
6
The Go extension has been communicating with Delve through a custom debug adapter program (`legacy` mode).
7
7
As the new [`Delve`'s native debug adapter implementation](https://github.com/go-delve/delve/tree/master/service/dap) has become available, the Go extension is transitioning to deprecate the legacy debug adapter in favor of direct communication with Delve via [DAP](https://microsoft.github.io/debug-adapter-protocol/overview).
8
8
9
-
📣 **We are happy to announce that now this new mode of Delve integration (_`dlv-dap`_ mode) is enabled for _local__debugging_ by default and is available for _remote__debugging_ on demand!**
9
+
📣 **We are happy to announce that now this new mode of Delve integration (_`dlv-dap`_ mode) is enabled for _local__debugging_ by default and is available for [_remote__debugging_](#remote-debugging) on demand!**
10
10
11
11
Many features and settings described in this document may be available only with the new `dlv-dap` mode.
12
12
For troubleshooting and configuring the legacy debug adapter, see [the legacy debug adapter documentation](https://github.com/golang/vscode-go/tree/master/docs/debugging-legacy.md).
@@ -369,17 +369,18 @@ Remote debugging is the debug mode commonly used to work with a debugger and tar
369
369
370
370
With the introduction of `dlv dap` users now have two options for remote (i.e. external) debugging.
371
371
372
-
#### Connecting to External Debugger with Pending Debug Session
372
+
#### Connecting to Headless Delve with Target Specified at Server Start-Up
373
373
374
-
Here the user must first start a `dlv --headless` server listening at `host:port`and specify a program to debug/test/exec or a process to attach to on the command-line. A [remote attach](#Attach) configuration is then used to attach to the pending debug session.
374
+
In this mode the user must first manually start a [`dlv --headless`](https://github.com/go-delve/delve/tree/master/Documentation/api) server listening at `host:port`while specifying the target program to debug/test/exec or a process to attach to on the command-line. A [remote attach](#attach) configuration is then used to connect to the debugger with a running target.
375
375
376
-
This is the tried-and-true remote mode that has been available since the `legacy` adapter. This is the only mode where we still use the `legacy` adapter by default while we stabilize the new `dlv-dap` version. Please do give the new version a try with `"debugAdapter": "dlv-dap"` in your launch configuration and Delve v.1.7.3 or newer and [let us know of any issues](https://github.com/golang/vscode-go/issues/new).
376
+
The [headless dlv server](https://github.com/go-delve/delve/tree/master/Documentation/api) can now be used with both `"debugAdapter": "legacy"` (default value) and `"debugAdapter": "dlv-dap"` (with Delve v1.7.3 or newer) as well as Delve's [command-line interface](https://github.com/go-delve/delve/tree/master/Documentation/cli) via `dlv connect`. The `--accept-multiclient` flag can be used to make this a multi-use server that persists on `Disconnect` from a client and allows repeated client connections. Please see `dlv --help` and `dlv [command] --help` for dlv's command-line options.
377
+
378
+
We encourage you to give the newly added `"debugAdapter": "dlv-dap"` support a try and to [let us know of any issues](https://github.com/golang/vscode-go/issues/new). If you need to use the `legacy` mode, pleasse also see the [legacy remote debugging](https://github.com/golang/vscode-go/blob/master/docs/debugging-legacy.md#remote-debugging) documentation.
The `--accept-multiclient` flag can be used to make this a multi-use server that persists on `Disconnect` from a client (unless `Stop` option is used instead) and allows repeated client connections. Please see `dlv --help` and `dlv [command] --help` for dlv's command-line options.
383
384
384
385
Connect to it with a remote attach configuration in your `launch.json`:
385
386
```json5
@@ -398,9 +399,11 @@ Connect to it with a remote attach configuration in your `launch.json`:
398
399
}
399
400
```
400
401
401
-
#### Connecting to External Debugger to Start Debug Session
402
+
#### Connecting to Delve DAP with Target Specified at Client Start-Up
403
+
404
+
In this mode the user must first manually start a [`dlv dap` server](https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md) listening at `host:port` and then specify the target program via [launch](#launch) or [attach](#attach) client config with a `"port"` attribute. Instead of starting a new local server, the Go extension will tell VS Code to connect to the server specified by `host:port` attributes and then send a request with the target to debug. This option provides the flexibility of easily adapting local configurations to connect to external servers, but ⚠️ must be used with care since anyone who can connect to the server can make it run arbitrary programs.
402
405
403
-
Here the user must first start a `dlv dap` server listening at `host:port` and specify a program to debug/test/exec or a process to attach to via [launch](#Launch) or [attach](#Attach) configuration with a `"port"` attribute. When the `"port"` attribute is specified, Go extension will assume a Delve DAP server has been started externally and tell VS Code to connect to it directly through the specified `host:port`. The `program` attribute must point to the absolute path of the package or binary to debug in the remote host’s file system even when `substitutePath` is specified.
406
+
When using `launch` mode, the `program` attribute must point to the absolute path of the package or binary to debug in the remote host’s file system even when `substitutePath` is specified. When using `attach` mode outside of local host, you need to specify the `processId` in the config since [the processId resolution feature](#attach) cannot gather information about processes running remotely.
@@ -438,11 +441,8 @@ Or have the binary compiled by dlv-dap by modifying the above configuration to u
438
441
```
439
442
440
443
⚠️ Limitations
441
-
* Anyone who can connect to the Delve DAP server’s host:port can exploit it to run arbitrary programs as the target is not launched until a client request is received.
442
-
* When using `"attach"` requests, you will need to specify the `processId` since
443
-
[the processId resolution feature](#attach) cannot gather process information running remotely.
444
444
* Delve DAP does not support `--accept-multiclient` or `--continue` flags, which means after a debug session ends, the dlv-dap process will always exit.
445
-
* If you use `debug` or `test` mode `launch` requests, Delve builds the target binary. Delve tries to build the target from the directory where the `dlv` (or `dlv-dap`) process is running, so make sure to run the `dlv-dap` command from the directory you’d run the `go build` or `go test` command.
445
+
* If you use `debug` or `test` mode `launch` requests, Delve builds the target binary. Delve tries to build the target from the directory where the `dlv` (or `dlv-dap`) process is running, so make sure to run the `dlv-dap` command from the directory you would run the `go build` or `go test` command.
0 commit comments