From 60c8ec9f1485a88f70d6d313f6eb8958a3be779a Mon Sep 17 00:00:00 2001 From: "Hana (Hyang-Ah) Kim" Date: Mon, 18 Dec 2023 15:30:32 -0500 Subject: [PATCH] src/goDebugConfiguration: change remote/attach default to dlv-dap And warn users who are affected by this change. For golang/vscode-go#2205 For golang/vscode-go#3096 Change-Id: Ie74b0f2d02b1f64d984d1120463f0b01328e2bb0 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/550917 TryBot-Result: kokoro Reviewed-by: Suzy Mueller Commit-Queue: Hyang-Ah Hana Kim --- src/goDebugConfiguration.ts | 37 ++++++++++++------- test/integration/goDebug.test.ts | 5 ++- test/integration/goDebugConfiguration.test.ts | 10 ++--- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts index 1d1a1baba2..44e422adaa 100644 --- a/src/goDebugConfiguration.ts +++ b/src/goDebugConfiguration.ts @@ -183,25 +183,36 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr } } // If neither launch.json nor settings.json gave us the debugAdapter value, we go with the default - // from package.json (dlv-dap) unless this is remote attach with a stable release. + // from package.json (dlv-dap). if (!debugConfiguration['debugAdapter']) { debugConfiguration['debugAdapter'] = defaultConfig.debugAdapter.default; - if (debugConfiguration['mode'] === 'remote' && !extensionInfo.isPreview) { - debugConfiguration['debugAdapter'] = 'legacy'; - } - } - if (debugConfiguration['debugAdapter'] === 'dlv-dap') { - if (debugConfiguration['mode'] === 'remote') { - // This needs to use dlv at version 'v1.7.3-0.20211026171155-b48ceec161d5' or later, - // but we have no way of detectng that with an external server ahead of time. - // If an earlier version is used, the attach will fail with warning about versions. - } else if (debugConfiguration['port']) { + if ( + debugConfiguration.request === 'attach' && + debugConfiguration['mode'] === 'remote' && + !extensionInfo.isPreview + ) { this.showWarning( - 'ignorePortUsedInDlvDapWarning', - "`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." + 'ignoreDefaultDebugAdapterChangeWarning', + "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." ); } } + if (debugConfiguration['debugAdapter'] === 'legacy') { + this.showWarning( + 'ignoreLegacyDADeprecationWarning', + 'Legacy debug adapter is deprecated. Please comment on [issue 3096](https://github.com/golang/vscode-go/issues/3096) if this impacts your workflows.' + ); + } + if ( + debugConfiguration['debugAdapter'] === 'dlv-dap' && + debugConfiguration.request === 'launch' && + debugConfiguration['port'] + ) { + this.showWarning( + 'ignorePortUsedInDlvDapWarning', + "`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." + ); + } const debugAdapter = debugConfiguration['debugAdapter'] === 'dlv-dap' ? 'dlv-dap' : 'dlv'; diff --git a/test/integration/goDebug.test.ts b/test/integration/goDebug.test.ts index a9537ddc93..2dc148f73e 100644 --- a/test/integration/goDebug.test.ts +++ b/test/integration/goDebug.test.ts @@ -43,9 +43,10 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) => name: 'Attach', type: 'go', request: 'attach', - mode: 'remote', // This implies debugAdapter = legacy. + mode: 'remote', host: '127.0.0.1', - port: 3456 + port: 3456, + debugAdapter: isDlvDap ? undefined : 'legacy' }; let dc: DebugClient; diff --git a/test/integration/goDebugConfiguration.test.ts b/test/integration/goDebugConfiguration.test.ts index 75ea818966..3d6bff60f1 100644 --- a/test/integration/goDebugConfiguration.test.ts +++ b/test/integration/goDebugConfiguration.test.ts @@ -951,7 +951,7 @@ suite('Debug Configuration Default DebugAdapter', () => { assert.strictEqual(resolvedConfig['debugAdapter'], 'dlv-dap'); }); - test("default debugAdapter for remote mode should be 'legacy' when not in Preview mode", async () => { + test("default debugAdapter for remote mode should be 'dlv-dap'", async () => { const config = { name: 'Attach', type: 'go', @@ -961,24 +961,24 @@ suite('Debug Configuration Default DebugAdapter', () => { cwd: '/path' }; - const want = extensionInfo.isPreview ? 'dlv-dap' : 'legacy'; + const want = 'dlv-dap'; await debugConfigProvider.resolveDebugConfiguration(undefined, config); const resolvedConfig = config as any; assert.strictEqual(resolvedConfig['debugAdapter'], want); }); - test('debugAdapter=dlv-dap is allowed with remote mode', async () => { + test('debugAdapter=legacy is allowed with remote mode', async () => { const config = { name: 'Attach', type: 'go', request: 'attach', mode: 'remote', - debugAdapter: 'dlv-dap', + debugAdapter: 'legacy', program: '/path/to/main_test.go', cwd: '/path' }; - const want = 'dlv-dap'; // If requested, dlv-dap is preserved. + const want = 'legacy'; // If requested, legacy is preserved. await debugConfigProvider.resolveDebugConfiguration(undefined, config); const resolvedConfig = config as any; assert.strictEqual(resolvedConfig['debugAdapter'], want);