Skip to content

Commit

Permalink
Revert "src/goDebugConfiguration: change remote/attach default to dlv…
Browse files Browse the repository at this point in the history
…-dap"

This reverts commit 60c8ec9.

Reason for revert: Need to address path mapping issue: #3175

Change-Id: I9422ab3feaad91ae7f44de90bb3fa3ffbe353278
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/576635
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Commit-Queue: Suzy Mueller <suzmue@golang.org>
  • Loading branch information
suzmue committed Apr 4, 2024
1 parent 40990c0 commit ad37a53
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 32 deletions.
37 changes: 13 additions & 24 deletions extension/src/goDebugConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,36 +183,25 @@ 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).
// from package.json (dlv-dap) unless this is remote attach with a stable release.
if (!debugConfiguration['debugAdapter']) {
debugConfiguration['debugAdapter'] = defaultConfig.debugAdapter.default;
if (
debugConfiguration.request === 'attach' &&
debugConfiguration['mode'] === 'remote' &&
!extensionInfo.isPreview
) {
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']) {
this.showWarning(
'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."
'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."
);
}
}
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';

Expand Down
5 changes: 2 additions & 3 deletions extension/test/integration/goDebug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ const testAll = (ctx: Mocha.Context, isDlvDap: boolean, withConsole?: string) =>
name: 'Attach',
type: 'go',
request: 'attach',
mode: 'remote',
mode: 'remote', // This implies debugAdapter = legacy.
host: '127.0.0.1',
port: 3456,
debugAdapter: isDlvDap ? undefined : 'legacy'
port: 3456
};

let dc: DebugClient;
Expand Down
10 changes: 5 additions & 5 deletions extension/test/integration/goDebugConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ suite('Debug Configuration Default DebugAdapter', () => {
assert.strictEqual(resolvedConfig['debugAdapter'], 'dlv-dap');
});

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

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

test('debugAdapter=legacy is allowed with remote mode', async () => {
test('debugAdapter=dlv-dap is allowed with remote mode', async () => {
const config = {
name: 'Attach',
type: 'go',
request: 'attach',
mode: 'remote',
debugAdapter: 'legacy',
debugAdapter: 'dlv-dap',
program: '/path/to/main_test.go',
cwd: '/path'
};

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

0 comments on commit ad37a53

Please sign in to comment.