Skip to content

Commit 6a4ca67

Browse files
committed
src/goDebugConfiguration: default to dlv-dap for remote in preview mode
Follows this example: https://golang.org/cl/325581. Fixes #2168 Change-Id: I468d169662eb2cd023b19046a519bb92db3f7c41 GitHub-Last-Rev: 9ec545b GitHub-Pull-Request: #2174 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/399077 Run-TryBot: Suzy Mueller <[email protected]> Reviewed-by: Suzy Mueller <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Polina Sokolova <[email protected]>
1 parent f4ccfc9 commit 6a4ca67

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ provides rich language support for the
99
[Go programming language](https://golang.org/).
1010

1111
📣
12-
[Remote attach debugging](docs/debugging.md#connecting-to-headless-delve-with-target-specified-at-server-start-up) is now available via Delve's native DAP implementation with Delve v1.7.3 or newer.
13-
We plan to enable this as the default in early 2022 to enhance remote debugging with the same
14-
[debugging features](docs/debugging.md) that are already in use for local debugging.
12+
[Remote attach debugging](docs/debugging.md#connecting-to-headless-delve-with-target-specified-at-server-start-up) is now available via Delve's native DAP implementation with Delve v1.7.3 or newer. It enchances remote debugging with the same
13+
[debugging features](docs/debugging.md) that are already in use for local debugging. It is now the default with the
14+
[Go Nightly](docs/nightly.md) build of the extension and will become the default for the stable releases in mid 2022.
1515
We recommend switching your remote attach configurations in `launch.json` to use
1616
`"debugAdapter":"dlv-dap"` now to verify that this works for you.
1717
Please [file a new issue](https://github.com/golang/vscode-go/issues/new/choose) if you encounter any problems.

docs/debugging.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ These debugging features are possible by using [Delve](https://github.com/go-del
66
The Go extension has been communicating with Delve through a custom debug adapter program (`legacy` mode).
77
As the new [`Delve`'s native debug adapter implementation](https://github.com/go-delve/delve/tree/master/service/dap) has become available (since Delve v1.6.1), 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).
88

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!**
9+
📣 **We are happy to announce that the new _`dlv-dap`_ mode of Delve integration is enabled for _local_ _debugging_ by default. For [_remote_ _debugging_](#remote-debugging) it is the default in [Go Nightly](docs/nightly.md) and is
10+
available with stable builds on demand with `"debugAdapter": "dlv-dap"` attribute in `launch.json` or `settings.json`!**
1011

1112
Many features and settings described in this document may be available only with the new `dlv-dap` mode.
1213
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).

src/goDebugConfiguration.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
promptForUpdatingTool,
2121
shouldUpdateTool
2222
} from './goInstallTools';
23+
import { extensionInfo } from './config';
2324
import { packagePathToGoModPathMap } from './goModules';
2425
import { getToolAtVersion } from './goTools';
2526
import { pickProcess, pickProcessByName } from './pickProcess';
@@ -159,23 +160,27 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
159160

160161
// Figure out which debugAdapter is being used first, so we can use this to send warnings
161162
// for properties that don't apply.
163+
// If debugAdapter is not provided in launch.json, see if it's in settings.json.
162164
if (!debugConfiguration.hasOwnProperty('debugAdapter') && dlvConfig.hasOwnProperty('debugAdapter')) {
163165
const { globalValue, workspaceValue } = goConfig.inspect('delveConfig.debugAdapter');
164166
// user configured the default debug adapter through settings.json.
165167
if (globalValue !== undefined || workspaceValue !== undefined) {
166168
debugConfiguration['debugAdapter'] = dlvConfig['debugAdapter'];
167169
}
168170
}
171+
// If neither launch.json nor settings.json gave us the debugAdapter value, we go with the default
172+
// from package.json (dlv-dap) unless this is remote attach with a stable release.
169173
if (!debugConfiguration['debugAdapter']) {
170-
// For local modes, default to dlv-dap. For remote - to legacy for now.
171-
debugConfiguration['debugAdapter'] = debugConfiguration['mode'] !== 'remote' ? 'dlv-dap' : 'legacy';
174+
debugConfiguration['debugAdapter'] = defaultConfig.debugAdapter.default;
175+
if (debugConfiguration['mode'] !== 'remote' && !extensionInfo.isPreview) {
176+
debugConfiguration['debugAdapter'] = 'legacy';
177+
}
172178
}
173179
if (debugConfiguration['debugAdapter'] === 'dlv-dap') {
174180
if (debugConfiguration['mode'] === 'remote') {
175-
// This is only possible if a user explicitely requests this combination. Let them.
176-
// They need to use dlv at version 'v1.7.3-0.20211026171155-b48ceec161d5' or later,
181+
// This needs to use dlv at version 'v1.7.3-0.20211026171155-b48ceec161d5' or later,
177182
// but we have no way of detectng that with an external server ahead of time.
178-
// If an earlier version is used, the attach will fail and a warning will warn about it.
183+
// If an earlier version is used, the attach will fail with warning about versions.
179184
} else if (debugConfiguration['port']) {
180185
this.showWarning(
181186
'ignorePortUsedInDlvDapWarning',

test/integration/goDebugConfiguration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import os = require('os');
77
import path = require('path');
88
import sinon = require('sinon');
99
import vscode = require('vscode');
10-
import { getGoConfig } from '../../src/config';
10+
import { getGoConfig, extensionInfo } from '../../src/config';
1111
import { GoDebugConfigurationProvider } from '../../src/goDebugConfiguration';
1212
import { updateGoVarsFromConfig } from '../../src/goInstallTools';
1313
import { rmdirRecursive } from '../../src/util';
@@ -915,7 +915,7 @@ suite('Debug Configuration Default DebugAdapter', () => {
915915
assert.strictEqual(resolvedConfig['debugAdapter'], 'dlv-dap');
916916
});
917917

918-
test("default debugAdapter for remote mode should be always 'legacy'", async () => {
918+
test("default debugAdapter for remote mode should be 'legacy' when not in Preview mode", async () => {
919919
const config = {
920920
name: 'Attach',
921921
type: 'go',
@@ -925,7 +925,7 @@ suite('Debug Configuration Default DebugAdapter', () => {
925925
cwd: '/path'
926926
};
927927

928-
const want = 'legacy'; // Remote mode defaults to legacy mode.
928+
const want = extensionInfo.isPreview ? 'dlv-dap' : 'legacy';
929929
await debugConfigProvider.resolveDebugConfiguration(undefined, config);
930930
const resolvedConfig = config as any;
931931
assert.strictEqual(resolvedConfig['debugAdapter'], want);

0 commit comments

Comments
 (0)