Skip to content

Commit 60c8ec9

Browse files
committed
src/goDebugConfiguration: change remote/attach default to dlv-dap
And warn users who are affected by this change. For #2205 For #3096 Change-Id: Ie74b0f2d02b1f64d984d1120463f0b01328e2bb0 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/550917 TryBot-Result: kokoro <[email protected]> Reviewed-by: Suzy Mueller <[email protected]> Commit-Queue: Hyang-Ah Hana Kim <[email protected]>
1 parent e54c930 commit 60c8ec9

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

src/goDebugConfiguration.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,25 +183,36 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
183183
}
184184
}
185185
// If neither launch.json nor settings.json gave us the debugAdapter value, we go with the default
186-
// from package.json (dlv-dap) unless this is remote attach with a stable release.
186+
// from package.json (dlv-dap).
187187
if (!debugConfiguration['debugAdapter']) {
188188
debugConfiguration['debugAdapter'] = defaultConfig.debugAdapter.default;
189-
if (debugConfiguration['mode'] === 'remote' && !extensionInfo.isPreview) {
190-
debugConfiguration['debugAdapter'] = 'legacy';
191-
}
192-
}
193-
if (debugConfiguration['debugAdapter'] === 'dlv-dap') {
194-
if (debugConfiguration['mode'] === 'remote') {
195-
// This needs to use dlv at version 'v1.7.3-0.20211026171155-b48ceec161d5' or later,
196-
// but we have no way of detectng that with an external server ahead of time.
197-
// If an earlier version is used, the attach will fail with warning about versions.
198-
} else if (debugConfiguration['port']) {
189+
if (
190+
debugConfiguration.request === 'attach' &&
191+
debugConfiguration['mode'] === 'remote' &&
192+
!extensionInfo.isPreview
193+
) {
199194
this.showWarning(
200-
'ignorePortUsedInDlvDapWarning',
201-
"`port` with 'dlv-dap' debugAdapter connects to [an external `dlv dap` server](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#running-debugee-externally) to launch a program or attach to a process. Remove 'host' and 'port' from your launch.json if you have not launched a 'dlv dap' server."
195+
'ignoreDefaultDebugAdapterChangeWarning',
196+
"We are using the 'dlv-dap' integration for remote debugging by default. Please comment on [issue 3096](https://github.com/golang/vscode-go/issues/3096) if this impacts your workflows."
202197
);
203198
}
204199
}
200+
if (debugConfiguration['debugAdapter'] === 'legacy') {
201+
this.showWarning(
202+
'ignoreLegacyDADeprecationWarning',
203+
'Legacy debug adapter is deprecated. Please comment on [issue 3096](https://github.com/golang/vscode-go/issues/3096) if this impacts your workflows.'
204+
);
205+
}
206+
if (
207+
debugConfiguration['debugAdapter'] === 'dlv-dap' &&
208+
debugConfiguration.request === 'launch' &&
209+
debugConfiguration['port']
210+
) {
211+
this.showWarning(
212+
'ignorePortUsedInDlvDapWarning',
213+
"`port` with 'dlv-dap' debugAdapter connects to [a `dlv dap` server](https://github.com/golang/vscode-go/wiki/debugging#run-debugee-externally) to launch a program or attach to a process. Remove 'host'/'port' from your launch.json configuration if you have not launched a 'dlv dap' server."
214+
);
215+
}
205216

206217
const debugAdapter = debugConfiguration['debugAdapter'] === 'dlv-dap' ? 'dlv-dap' : 'dlv';
207218

test/integration/goDebug.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
4343
name: 'Attach',
4444
type: 'go',
4545
request: 'attach',
46-
mode: 'remote', // This implies debugAdapter = legacy.
46+
mode: 'remote',
4747
host: '127.0.0.1',
48-
port: 3456
48+
port: 3456,
49+
debugAdapter: isDlvDap ? undefined : 'legacy'
4950
};
5051

5152
let dc: DebugClient;

test/integration/goDebugConfiguration.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ suite('Debug Configuration Default DebugAdapter', () => {
951951
assert.strictEqual(resolvedConfig['debugAdapter'], 'dlv-dap');
952952
});
953953

954-
test("default debugAdapter for remote mode should be 'legacy' when not in Preview mode", async () => {
954+
test("default debugAdapter for remote mode should be 'dlv-dap'", async () => {
955955
const config = {
956956
name: 'Attach',
957957
type: 'go',
@@ -961,24 +961,24 @@ suite('Debug Configuration Default DebugAdapter', () => {
961961
cwd: '/path'
962962
};
963963

964-
const want = extensionInfo.isPreview ? 'dlv-dap' : 'legacy';
964+
const want = 'dlv-dap';
965965
await debugConfigProvider.resolveDebugConfiguration(undefined, config);
966966
const resolvedConfig = config as any;
967967
assert.strictEqual(resolvedConfig['debugAdapter'], want);
968968
});
969969

970-
test('debugAdapter=dlv-dap is allowed with remote mode', async () => {
970+
test('debugAdapter=legacy is allowed with remote mode', async () => {
971971
const config = {
972972
name: 'Attach',
973973
type: 'go',
974974
request: 'attach',
975975
mode: 'remote',
976-
debugAdapter: 'dlv-dap',
976+
debugAdapter: 'legacy',
977977
program: '/path/to/main_test.go',
978978
cwd: '/path'
979979
};
980980

981-
const want = 'dlv-dap'; // If requested, dlv-dap is preserved.
981+
const want = 'legacy'; // If requested, legacy is preserved.
982982
await debugConfigProvider.resolveDebugConfiguration(undefined, config);
983983
const resolvedConfig = config as any;
984984
assert.strictEqual(resolvedConfig['debugAdapter'], want);

0 commit comments

Comments
 (0)