Hyang-Ah Hana Kim submitted this change.
4 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: docs/debugging.md
Insertions: 2, Deletions: 2.
@@ -86,8 +86,9 @@
* Supported modes
* `debug`: build and debug a main package
* `test`: build and debug a test
- * `exec`: debug a precompiled binary. The binary needs to be built with `-gcflags=all="-N -l"` flags to avoid stripping debugging information.
- * `auto`: automatically choose between `debug` and `test` depending on the open file.
+ * `exec`: debug a precompiled binary
+ * The binary must be built with `go build -gcflags=all="-N -l"` to disable inlining and optimizations that can interfere with debugging.
+ * `auto`: automatically choose between `debug` and `test` depending on the open file
⚠️ If a `port` attribute is added to any of the launch configurations, it will signal VS Code that instead of launching the debug server internally, it should connect to an external user-specified `dlv dap` server at `host:port` and launch the target there. See ["Remote Debugging"](#remote-debugging) for more details).
@@ -99,6 +100,7 @@
* Supported modes
* `local`: attaches to a local process
+ * The binary must be built with `go build -gcflags=all="-N -l"` to disable inlining and optimizations that can interfere with debugging.
* `remote`: attaches to an in-progress debug session run by an external server
You can debug an already running program using the `local` mode type configuration. The Go extension will start `dlv dap` and configure it to attach to the specified process. Users can select the process to debug with one of the following options:
@@ -358,7 +360,7 @@
```
You can choose to install a different version of `dlv` by specifying a specific commit hash, a branch name (e.g. `master`), or a released version instead of `latest`.
-For more details about manual installation, see [Delve's documentation](https://github.com/go-delve/delve/tree/master/Documentation/installation).
+For more details about manual installation, see [Delve's documentation](https://github.com/go-delve/delve/tree/master/Documentation/installation).
If you want to explicitly specify the location of the delve binary, use the `go.alternateTools` setting:
```json5
@@ -421,7 +423,7 @@
$ dlv dap --listen=:12345
```
-Use the following `launch` configuration to tell `dlv` to execute a binary precompiled with `-gcflags='all=-N -l'`:
+Use the following `launch` configuration to tell `dlv` to execute a binary precompiled with `go build -gcflags='all=-N -l'`:
```json5
{
@@ -505,6 +507,11 @@
### Debug sessions started with the "debug test" CodeLens or the test UI does not use my `launch.json` configuration.
The "debug test" CodeLens and the [test UI](https://github.com/golang/vscode-go/blob/master/docs/features.md#test-and-benchmark) do not use the `launch.json` configuration ([Issue 855](https://github.com/golang/vscode-go/issues/855)). As a workaround, use the `go.delveConfig` setting and the `go.testFlags` setting. Please note that these all apply to all debug sessions unless overwritten by a specific `launch.json` configuration.
+
+### Why can't I use local attach with a process started with `go run`?
+
+Unlike `go build`, `go run` passes `-s -w` to the linker to strip the debug info. If you try attach to such a binary with a debugger, it will fail an error like `decoding dwarf section info at offset 0x0: too short`. Use `go build -gcflags='all=-N -l'` to build your binary instead. See Go Issue [24833](https://github.com/golang/go/issues/24833) for more information.
+
## Reporting Issues
When you are having issues in `dlv-dap` mode, first check if the problems are reproducible after updating `dlv` and using the most recent version of `dlv`. It's possible that the problems are already fixed. You can also try to install `dlv` at tree head. Follow the instruction for [updating `dlv`](#staying-up-to-date) and [updating extension](https://code.visualstudio.com/docs/editor/extension-gallery#\_extension-autoupdate).
```
src/goDebugConfiguration: use 'dlv' instead of 'dlv-dap' binary
The stable version of dlv includes all the features Delve DAP
mode debug setup requires. We do not need to depend on Delve
built from the master or newer than the stable version.
Use 'dlv' instead of 'dlv-dap', and remove 'dlv-dap' binary
installation/update logic.
The extension presents a warning to the users who configured
`go.alternateTools.dlv-dap` and offers an option to open
the corresponding settings.json.
Fixes golang/vscode-go#1977
Change-Id: I5ed398c4d85594a6ad26bea4874324a75f96badb
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/374594
Trust: Hyang-Ah Hana Kim <hya...@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hya...@gmail.com>
Reviewed-by: Polina Sokolova <pol...@google.com>
---
M src/goDebugFactory.ts
M docs/debugging.md
M src/goMain.ts
M src/goTools.ts
M tools/installtools/main.go
M test/integration/install.test.ts
M tools/generate.go
M tools/allTools.ts.in
M src/goInstallTools.ts
M src/goDebugConfiguration.ts
M test/gopls/update.test.ts
M src/goToolsInformation.ts
12 files changed, 121 insertions(+), 139 deletions(-)
diff --git a/docs/debugging.md b/docs/debugging.md
index b51ffea..0d53b3e 100644
--- a/docs/debugging.md
+++ b/docs/debugging.md
@@ -4,7 +4,7 @@
These debugging features are possible by using [Delve](https://github.com/go-delve/delve), the Go debugger.
The Go extension has been communicating with Delve through a custom debug adapter program (`legacy` mode).
-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).
+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).
📣 **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!**
@@ -20,9 +20,9 @@
If you already have launch configurations for the project (`.vscode/launch.json`), the Run view will display the configuration list to choose from.
<p align="center">
-<img src="images/dlvdap-install.gif" alt="Delve DAP Install" width="75%">
+<img src="images/dlvdap-install.gif" alt="Delve Install" width="75%"><!--TODO: update image-->
<br/>
-<em>❗ When you start debugging in `dlv-dap` mode for the first time, the extension will ask to install Delve built from head (`dlv-dap`). Please follow the instructions to install, and then start the debugging session again (i.e. selecting the source file, pressing F5 or click the codelens).</em>
+<em>❗ When you start debugging for the first time or if the `dlv` executable on your system is too old to support DAP, the extension may ask to install or update Delve. Please follow the instructions to install, and then start the debugging session again (i.e. selecting the source file, pressing F5 or click the codelens).</em>
</p>
<div style="text-align: center;"></div>
@@ -32,14 +32,16 @@
Please review [the Features section](#features) that provides an overview of the debug UI and available features.
### Staying Up-To-Date
-[Delve’s native DAP implementation](https://github.com/go-delve/delve/tree/master/service/dap) is under active development, so take advantage of the most recent features and bug fixes by using Delve built from its master branch. The Go extension maintains this newest version of Delve separately from the officially released version of `dlv` and installs it with the name `dlv-dap`.
+[Delve’s native DAP implementation](https://github.com/go-delve/delve/tree/master/service/dap) is under active development, so take advantage of the most recent features and bug fixes by installing the latest version of Delve.
-The easiest way to update `dlv-dap` on demand is to use the `"Go: Install/Update Tools"` command from the Command Palette (Linux/Windows: Ctrl+Shift+P, Mac: ⇧+⌘+P). The command will show `dlv-dap` in the tool list. Select `dlv-dap`, and the extension will build the tool at master.
+The easiest way to update `dlv` on demand is to use the `"Go: Install/Update Tools"` command from the Command Palette (Linux/Windows: Ctrl+Shift+P, Mac: ⇧+⌘+P). The command will show `dlv` in the tool list.
-Once `dlv-dap` is installed on your system, the extension will prompt you for update whenever installing a newer version is necessary (usually after the Go extension upgrade). You can set the `go.toolsManagement.autoUpdate` setting so the extension can update `dlv-dap` automatically for you.
+Once `dlv` is installed on your system, the extension will prompt you for update whenever installing a newer version is necessary (usually after the Go extension upgrade). You can set the `go.toolsManagement.autoUpdate` setting so the extension can update `dlv` automatically for you.
-If you need to install `dlv-dap` manually outside of VS Code (for example, you are building a dev container with necessary tools preinstalled), please see the [Manual Installation](#bookmark=id.xuaxofprncd5) section.
+If you need to install `dlv` manually outside of VS Code (for example, you are building a dev container with necessary tools preinstalled, or install `dlv` built from the tree head), follow the instruction in [Manually installing `dlv`](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#manually-installing-dlv).
+💡 The extension used to install a dev version of `dlv` as a separate binary (known as `dlv-dap`). As Delve DAP is stable and the transition work is near completion, from v0.31.0 (to be released in Jan 2022), the extension will switch to use `dlv`, instead of the `dlv-dap` binary. It is safe to delete `dlv-dap` installed on the system after v0.31.0 release.
+
### Switching to legacy debug adapter
If you need to use the legacy debug adapter (`legacy` mode) by default,
@@ -101,7 +103,7 @@
* The binary must be built with `go build -gcflags=all="-N -l"` to disable inlining and optimizations that can interfere with debugging.
* `remote`: attaches to an in-progress debug session run by an external server
-You can debug an already running program using the `local` mode type configuration. The Go extension will start `dlv-dap` and configure it to attach to the specified process. Users can select the process to debug with one of the following options:
+You can debug an already running program using the `local` mode type configuration. The Go extension will start `dlv dap` and configure it to attach to the specified process. Users can select the process to debug with one of the following options:
* Specifying the numeric process id (PID) with the `processId` attribute.
* Specifying the target program name in the `processId` attribute. If there are multiple processes matching the specified program name, the extension will show the list of matching processes at the start of the debug session.
@@ -286,7 +288,7 @@
| `traceDirPath` | Directory in which the record trace is located or to be created for a new output trace. For use on 'replay' mode only<br/>(Default: `""`)<br/> | <center>_n/a_</center> |
<!-- SETTINGS END -->
-⚠️ `dlv-dap` needs file or directory values in the launch configuration to be absolute paths. When configuring those values, use [the VS Code variables substitution](https://code.visualstudio.com/docs/editor/variables-reference) - VS Code will resolve the variables inside strings in `launch.json` before passing the configuration to the Go extension and `dlv-dap`. For example, `${workspaceFolder}` will be replaced with the absolute path to the workspace root folder. When appropriate, the Go extension will resolve relative paths or home directory (~) before sending the configuration to `dlv-dap`.
+⚠️ Delve resolves relative paths from `dlv dap` process's working directory, but from which directory the extension spawns the `dlv dap` process is an implementation detail. Thus, use [the VS Code variables substitution](https://code.visualstudio.com/docs/editor/variables-reference) to ensure consistent expansion of paths. VS Code will resolve the variables inside strings in `launch.json` before passing the configuration to the Go extension and `dlv dap`. For example, `${workspaceFolder}` will be replaced with the absolute path to the workspace root folder. When appropriate, the Go extension will resolve relative paths or home directory (~) before sending the configuration to `dlv dap`.
### **Debugging symlink directories**
@@ -338,33 +340,32 @@
For information on debugging using the legacy debug adapter, please see the old [Debugging Documentation](https://github.com/golang/vscode-go/blob/master/docs/debugging.md). Note that many new or enhanced features discussed in this document may not be available with the legacy debug adapter.
-### Manually installing `dlv-dap`
+### Manually installing `dlv`
-On rare occasions, you may want to install `dlv-dap` by yourself instead of letting the extension handle its installation.
+On rare occasions, you may want to install `dlv` by yourself instead of letting the extension handle its installation.
-First, find where the Go extension finds tools. Like [other tools the extension uses](https://github.com/golang/vscode-go/blob/master/docs/tools.md#tools), the Go extension searches the `dlv-dap` executable from `${GOPATH}/bin`, `${GOBIN}` and `${PATH}` (or `Path` in Windows). So, install `dlv-dap` in the directory. The easiest way to check the tool installation location the Go extension uses is currently by running the `Go: Locate Configured Go Tools` command from the command palette (⇧+⌘+P or Ctrl+Shift+P).
-
-The following commands download the source of Delve from the master branch, build & store as `dlv-dap` in `~/go/bin/` directory assuming the directory is the place you found from the first step.
+First, find where the Go extension finds tools. Like [other tools the extension uses](https://github.com/golang/vscode-go/blob/master/docs/tools.md#tools), the Go extension searches the `dlv` executable from `${GOPATH}/bin`, `${GOBIN}` and `${PATH}` (or `Path` in Windows). So, install `dlv` in the directory. The easiest way to check the tool installation location the Go extension uses is currently by running the `Go: Locate Configured Go Tools` command from the command palette (⇧+⌘+P or Ctrl+Shift+P).
If your Go version is 1.16 or newer:
```
-$ GOBIN=/tmp/ go install github.com/go-delve/delve/cmd/dlv@master
-$ mv /tmp/dlv $GOPATH/bin/dlv-dap
+$ GOBIN=<dir_to_install_dlv> go install github.com/go-delve/delve/cmd/dlv@latest
```
If your Go version is older than 1.16:
```
$ cd $(mktemp -d)
-$ GO111MODULE=on GOBIN=/tmp/ go get github.com/go-delve/delve/cmd/dlv@master
-$ mv /tmp/dlv $GOPATH/bin/dlv-dap
+$ GO111MODULE=on GOBIN=<dir_to_install_dlv> go get github.com/go-delve/delve/cmd/dlv@latest
```
+You can choose to install a different version of `dlv` by specifying a specific commit hash, a branch name (e.g. `master`), or a released version instead of `latest`.
+For more details about manual installation, see [Delve's documentation](https://github.com/go-delve/delve/tree/master/Documentation/installation).
+
If you want to explicitly specify the location of the delve binary, use the `go.alternateTools` setting:
```json5
"go.alternateTools": {
- "dlv-dap": "<absolute path to your dlv binary>"
+ "dlv": "<absolute path to your dlv binary>"
}
```
@@ -417,12 +418,12 @@
<p align="center"><img src="images/remote-debugging.png" alt="Remote Debugging"> </p>
-->
-Start a dlv-dap server ready to accept a client request to launch or attach to a target process:
+Start a `dlv dap` server ready to accept a client request to launch or attach to a target process:
```
-$ dlv-dap dap --listen=:12345
+$ dlv dap --listen=:12345
```
-Use the following `launch` configuration to tell `dlv-dap` to execute a binary precompiled with `go build -gcflags='all=-N -l'`:
+Use the following `launch` configuration to tell `dlv` to execute a binary precompiled with `go build -gcflags='all=-N -l'`:
```json5
{
@@ -441,7 +442,7 @@
}
```
-Or have the binary compiled by dlv-dap by modifying the above configuration to use:
+Or have the binary compiled by `dlv dap` by modifying the above configuration to use:
```json5
"mode": "debug",
@@ -449,8 +450,8 @@
```
⚠️ Limitations
-* Unlike `dlv --headless` above, `dlv dap` does not support `--accept-multiclient` or `--continue` flags, which means after a debug session ends, the dlv-dap process will always exit.
-* 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.
+* Unlike `dlv --headless` above, `dlv dap` does not support `--accept-multiclient` or `--continue` flags, which means after a debug session ends, the `dlv dap` process will always exit.
+* 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` process is running, so make sure to run the `dlv` command from the directory you would run the `go build` or `go test` command.
### Running Debugee Externally
@@ -465,8 +466,8 @@
1. Read documentation and [FAQs](#faqs). Also check the [Delve FAQ](https://github.com/go-delve/delve/blob/master/Documentation/faq.md) in case the problem is mentioned there.
1. Check your `launch.json` configuration. Often error messages appearing in the DEBUG CONSOLE panel reveal issues.
-1. Update Delve (`dlv-dap`) to pick up most recent bug fixes. Follow [the instruction](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#staying-up-to-date).
-1. Check if you can reproduce the issue with `dlv`, the command line tool from the integrated terminal. <!-- TODO(vscode-go): add instructions https://github.com/golang/vscode-go/issues/1931 --> If it's reproducible when using `dlv`, take a look at the [delve's issue tracker](https://github.com/go-delve/delve/issues).
+1. Update Delve (`dlv`) to pick up most recent bug fixes. Follow [the instruction](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#staying-up-to-date).
+1. Check if you can reproduce the issue with `dlv`, the command line tool from the integrated terminal. <!-- TODO(vscode-go): add instructions https://github.com/golang/vscode-go/issues/1931 --> If it's reproducible when using `dlv`, take a look at the [Delve project issue tracker](https://github.com/go-delve/delve/issues).
1. Capture [logs](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#collecting-logs) and inspect them.
1. Look at the [existing debugging issues](https://github.com/golang/vscode-go/labels/Debug) if similar issues were reported.
1. If none of these solve your problem, please [open a new issue](#reporting-issues).
@@ -513,12 +514,12 @@
## Reporting Issues
-When you are having issues in `dlv-dap` mode, first check if the problems are reproducible after updating `dlv-dap`. It's possible that the problems are already fixed. Follow the instruction for [updating dlv-dap](#updating-dlv-dap)) and [updating extension](https://code.visualstudio.com/docs/editor/extension-gallery#\_extension-autoupdate).
+When you are having issues in `dlv-dap` mode, first check if the problems are reproducible after updating `dlv` and using the most recent version of `dlv`. It's possible that the problems are already fixed. You can also try to install `dlv` at tree head. Follow the instruction for [updating `dlv`](#staying-up-to-date) and [updating extension](https://code.visualstudio.com/docs/editor/extension-gallery#\_extension-autoupdate).
Please report issues in [our issue tracker](https://github.com/golang/vscode-go/issues) with the following information.
* `go version`
-* `go version -m <path/to/dlv-dap>`
+* `go version -m <path/to/dlv>`
* VS Code and VS Code Go version (e.g. `code --version`)
* Instructions to reproduce the issue (code snippets, your `launch.json`, screenshot)
* DAP trace (See [the instruction](#collecting-logs))
@@ -550,11 +551,11 @@
### Testing
-For simple launch cases, build the delve binary, and configure `"go.alternateTools"` setting.
+For simple launch cases, build the `dlv` binary, and configure `"go.alternateTools"` setting.
```json5
"go.alternateTools": {
- "dlv-dap": <path_to_your_delve>
+ "dlv": <path_to_your_dlv>
}
```
@@ -562,7 +563,7 @@
If you are having issues with seeing logs and/or suspect problems in the extension's integration, you can start the Delve DAP server from a separate terminal and configure the extension to directly connect to it. Please remember to [file an issue](https://github.com/golang/vscode-go/issues/new) if you encounter any logging-related problems.
```
-$ dlv-dap dap --listen=:12345 --log --log-output=dap
+$ dlv dap --listen=:12345 --log --log-output=dap
```
```json5
diff --git a/src/goDebugConfiguration.ts b/src/goDebugConfiguration.ts
index 3bc9829..f7e7336 100644
--- a/src/goDebugConfiguration.ts
+++ b/src/goDebugConfiguration.ts
@@ -263,34 +263,34 @@
}
}
- const dlvToolPath = getBinPath(debugAdapter);
+ const dlvToolPath = getBinPath('dlv');
if (!path.isAbsolute(dlvToolPath)) {
// If user has not already declined to install this tool,
// prompt for it. Otherwise continue and have the lack of
// dlv binary be caught later.
- if (!declinedToolInstall(debugAdapter)) {
- await promptForMissingTool(debugAdapter);
+ if (!declinedToolInstall('dlv')) {
+ await promptForMissingTool('dlv');
return;
}
}
debugConfiguration['dlvToolPath'] = dlvToolPath;
+ // For dlv-dap mode, check if the dlv is recent enough to support DAP.
if (debugAdapter === 'dlv-dap' && !dlvDAPVersionChecked) {
- const tool = getToolAtVersion('dlv-dap');
+ const tool = getToolAtVersion('dlv');
if (await shouldUpdateTool(tool, dlvToolPath)) {
// If the user has opted in to automatic tool updates, we can update
// without prompting.
const toolsManagementConfig = getGoConfig()['toolsManagement'];
if (toolsManagementConfig && toolsManagementConfig['autoUpdate'] === true) {
const goVersion = await getGoVersion();
- const toolVersion = { ...tool, version: tool.latestVersion }; // ToolWithVersion
- await installTools([toolVersion], goVersion, true);
+ await installTools([tool], goVersion, true);
} else {
await promptForUpdatingTool(tool.name);
}
- // installTools could've failed (e.g. no network access) or the user decliend to install dlv-dap
- // in promptForUpdatingTool. If dlv-dap doesn't exist or dlv-dap is too old to have MVP features,
- // the failure will be visible to users when launching the dlv-dap process (crash or error message).
+ // installTools could've failed (e.g. no network access) or the user decliend to install dlv
+ // in promptForUpdatingTool. If dlv doesn't exist or dlv is too old to have MVP features,
+ // the failure will be visible to users when launching the dlv process (crash or error message).
}
dlvDAPVersionChecked = true;
}
diff --git a/src/goDebugFactory.ts b/src/goDebugFactory.ts
index 701450a..d9dead6 100644
--- a/src/goDebugFactory.ts
+++ b/src/goDebugFactory.ts
@@ -12,7 +12,6 @@
import path = require('path');
import * as fs from 'fs';
import * as net from 'net';
-import { getTool } from './goTools';
import { Logger, logVerbose, TimestampedLogger } from './goLogging';
import { DebugProtocol } from 'vscode-debugprotocol';
import { getWorkspaceFolderPath } from './util';
@@ -578,12 +577,12 @@
// launchArgsEnv is user-requested env vars (envFiles + env).
const env = Object.assign(goToolsEnvVars, launchArgsEnv);
- const dlvPath = launchAttachArgs.dlvToolPath ?? getTool('dlv-dap');
+ const dlvPath = launchAttachArgs.dlvToolPath ?? 'dlv';
if (!fs.existsSync(dlvPath)) {
const envPath = process.env['PATH'] || (process.platform === 'win32' ? process.env['Path'] : null);
logErr(
- `Couldn't find dlv-dap at the Go tools path, ${process.env['GOPATH']}${
+ `Couldn't find ${dlvPath} at the Go tools path, ${process.env['GOPATH']}${
env['GOPATH'] ? ', ' + env['GOPATH'] : ''
} or ${envPath}\n` +
'Follow the setup instruction in https://github.com/golang/vscode-go/blob/master/docs/debugging.md#getting-started.\n'
diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts
index 1b02cc5..c6298ff 100644
--- a/src/goInstallTools.ts
+++ b/src/goInstallTools.ts
@@ -235,7 +235,7 @@
}
try {
- if (!modulesOn || goVersion.lt('1.16') || hasModSuffix(tool) || tool.name === 'dlv-dap') {
+ if (!modulesOn || goVersion.lt('1.16') || hasModSuffix(tool)) {
await installToolWithGoGet(tool, goVersion, env, modulesOn, importPath);
} else {
await installToolWithGoInstall(goVersion, env, importPath);
@@ -284,9 +284,9 @@
if (!modulesOn) {
args.push('-u');
}
- // dlv-dap or tools with a "mod" suffix can't be installed with
+ // tools with a "mod" suffix can't be installed with
// simple `go install` or `go get`. We need to get, build, and rename them.
- if (hasModSuffix(tool) || tool.name === 'dlv-dap') {
+ if (hasModSuffix(tool)) {
args.push('-d'); // get the version, but don't build.
}
args.push(importPath);
@@ -307,8 +307,8 @@
logVerbose(`$ ${goBinary} ${args.join(' ')} (cwd: ${opts.cwd})`);
await execFile(goBinary, args, opts);
- if (hasModSuffix(tool) || tool.name === 'dlv-dap') {
- // Actual installation of the -gomod tool and dlv-dap is done by running go build.
+ if (hasModSuffix(tool)) {
+ // Actual installation of the -gomod tool is done by running go build.
let destDir = env['GOBIN'];
if (!destDir) {
const gopath0 = env['GOPATH']?.split(path.delimiter)[0];
@@ -383,14 +383,13 @@
// Offer the option to install all tools.
installOptions.push('Install All');
}
- let msg = `The "${tool.name}" command is not available.
-Run "go get -v ${getImportPath(tool, goVersion)}" to install.`;
- if (tool.name === 'dlv-dap') {
- msg = `The ["${tool.name}"](https://github.com/golang/vscode-go/blob/master/docs/debugging.md) command is not available.
-Please select "Install", or follow the installation instructions [here](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#updating-dlv-dap).`;
- }
-
- const selected = await vscode.window.showErrorMessage(msg, ...installOptions);
+ const cmd = goVersion.lt('1.16')
+ ? `go get -v ${getImportPath(tool, goVersion)}`
+ : `go install -v ${getImportPathWithVersion(tool, tool.defaultVersion, goVersion)}`;
+ const selected = await vscode.window.showErrorMessage(
+ `The "${tool.name}" command is not available. Run "${cmd}" to install.`,
+ ...installOptions
+ );
switch (selected) {
case 'Install':
await installTools([tool], goVersion);
@@ -436,7 +435,7 @@
if (toolName === 'gopls') {
choices = ['Always Update', 'Update Once', 'Release Notes'];
}
- if (toolName === 'dlv-dap') {
+ if (toolName === 'dlv') {
choices = ['Always Update', 'Update Once'];
}
diff --git a/src/goMain.ts b/src/goMain.ts
index b2cd019..939b2d4 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -188,6 +188,10 @@
}
}
}
+
+ // Present a warning about the deprecation of a 'dlv-dap' binary setting.
+ checkAlternateTools(cfg);
+
updateGoVarsFromConfig().then(async () => {
suggestUpdates(ctx);
offerToInstallLatestGoVersion();
@@ -1030,3 +1034,23 @@
delete process.env.GOROOT;
}
}
+
+async function checkAlternateTools(goConfig: vscode.WorkspaceConfiguration) {
+ const alternateTools = goConfig ? goConfig['alternateTools'] : {};
+ // TODO(hyangah): delete this check after 2022-03-01.
+ if (alternateTools['dlv-dap']) {
+ const msg = `The extension no longer requires a separate 'dlv-dap' binary but uses the 'dlv' binary.
+The "dlv-dap" property of the "go.alternateTools" setting will be ignored.
+Please use the "dlv" property if you need to override the default Go debugger.`;
+
+ const selected = await vscode.window.showWarningMessage(msg, 'Open settings.json');
+ if (selected === 'Open settings.json') {
+ const { workspaceValue } = goConfig.inspect('alternateTools.dlv-dap');
+ if (workspaceValue !== undefined) {
+ vscode.commands.executeCommand('workbench.action.openWorkspaceSettingsFile');
+ } else {
+ vscode.commands.executeCommand('workbench.action.openSettingsJson');
+ }
+ }
+ }
+}
diff --git a/src/goTools.ts b/src/goTools.ts
index a14420d..01289db 100644
--- a/src/goTools.ts
+++ b/src/goTools.ts
@@ -157,9 +157,8 @@
// Check if the system supports dlv, i.e. is 64-bit.
// There doesn't seem to be a good way to check if the mips and s390
// families are 64-bit, so just try to install it and hope for the best.
- if (process.arch.match(/^(arm64|mips|mipsel|ppc64|s390|s390x|x64)$/)) {
+ if (process.arch.match(/^(mips|mipsel|ppc64|s390|s390x|x64)$/)) {
maybeAddTool('dlv');
- maybeAddTool('dlv-dap');
}
// gocode-gomod needed in go 1.11 & higher
diff --git a/src/goToolsInformation.ts b/src/goToolsInformation.ts
index aae0d5d..ca68e12 100644
--- a/src/goToolsInformation.ts
+++ b/src/goToolsInformation.ts
@@ -203,10 +203,10 @@
description: 'Language Server from Google',
usePrereleaseInPreviewMode: true,
minimumGoVersion: semver.coerce('1.12'),
- latestVersion: semver.parse('v0.7.1'),
- latestVersionTimestamp: moment('2021-08-02', 'YYYY-MM-DD'),
- latestPrereleaseVersion: semver.parse('v0.7.1'),
- latestPrereleaseVersionTimestamp: moment('2021-08-02', 'YYYY-MM-DD')
+ latestVersion: semver.parse('v0.7.4'),
+ latestVersionTimestamp: moment('2021-12-09', 'YYYY-MM-DD'),
+ latestPrereleaseVersion: semver.parse('v0.7.4'),
+ latestPrereleaseVersionTimestamp: moment('2021-12-09', 'YYYY-MM-DD')
},
'dlv': {
name: 'dlv',
@@ -215,20 +215,10 @@
replacedByGopls: false,
isImportant: true,
description: 'Go debugger (Delve)',
+ latestVersion: semver.parse('v1.6.1'), // minimum version that supports DAP
+ latestVersionTimestamp: moment('2021-05-19', 'YYYY-MM-DD'),
minimumGoVersion: semver.coerce('1.12') // dlv requires 1.12+ for build
},
- 'dlv-dap': {
- name: 'dlv-dap',
- importPath: 'github.com/go-delve/delve/cmd/dlv',
- modulePath: 'github.com/go-delve/delve',
- replacedByGopls: false,
- isImportant: true,
- description: 'Go debugger & debug adapter (Delve DAP)',
- defaultVersion: '2f13672765fe', // pinned version
- minimumGoVersion: semver.coerce('1.12'), // dlv requires 1.12+ for build
- latestVersion: semver.parse('v1.7.3-0.20211026171155-b48ceec161d5'),
- latestVersionTimestamp: moment('2021-10-26', 'YYYY-MM-DD')
- },
'fillstruct': {
name: 'fillstruct',
importPath: 'github.com/davidrjenni/reftools/cmd/fillstruct',
diff --git a/test/gopls/update.test.ts b/test/gopls/update.test.ts
index bb36605..150f02c 100644
--- a/test/gopls/update.test.ts
+++ b/test/gopls/update.test.ts
@@ -188,7 +188,7 @@
});
suite('version comparison', () => {
- const tool = getTool('dlv-dap');
+ const tool = getTool('dlv');
const latestVersion = tool.latestVersion;
teardown(() => {
@@ -197,7 +197,7 @@
async function testShouldUpdateTool(expected: boolean, moduleVersion?: string) {
sinon.stub(goInstallTools, 'inspectGoToolVersion').returns(Promise.resolve({ moduleVersion }));
- const got = await goInstallTools.shouldUpdateTool(tool, '/bin/path/to/dlv-dap');
+ const got = await goInstallTools.shouldUpdateTool(tool, '/bin/path/to/dlv');
assert.strictEqual(
expected,
got,
diff --git a/test/integration/install.test.ts b/test/integration/install.test.ts
index 3602022..6272c8a 100644
--- a/test/integration/install.test.ts
+++ b/test/integration/install.test.ts
@@ -157,12 +157,7 @@
await runTest(
[
{ name: 'gopls', versions: ['v0.1.0', 'v1.0.0-pre.1', 'v1.0.0'], wantVersion: 'v1.0.0' },
- { name: 'guru', versions: ['v1.0.0'], wantVersion: 'v1.0.0' },
- {
- name: 'dlv-dap',
- versions: ['v1.0.0', getTool('dlv-dap').defaultVersion!],
- wantVersion: 'v' + getTool('dlv-dap').latestVersion!.toString()
- }
+ { name: 'dlv', versions: ['v1.0.0', 'v1.8.0'], wantVersion: 'v1.8.0' }
],
true
);
@@ -172,12 +167,7 @@
await runTest(
[
{ name: 'gopls', versions: ['v0.1.0', 'v1.0.0-pre.1', 'v1.0.0'], wantVersion: 'v1.0.0' },
- { name: 'guru', versions: ['v1.0.0'], wantVersion: 'v1.0.0' },
- {
- name: 'dlv-dap',
- versions: ['v1.0.0', getTool('dlv-dap').defaultVersion!],
- wantVersion: 'v' + getTool('dlv-dap').latestVersion!.toString()
- }
+ { name: 'dlv', versions: ['v1.0.0', 'v1.8.0'], wantVersion: 'v1.8.0' }
],
true, // LOCAL PROXY
true // GOBIN
@@ -214,7 +204,7 @@
versions.map((version) => {
if (!version.match(/^v\d+\.\d+\.\d+/)) {
- // for dlv-dap that retrieves the version from a revision (commit hash)
+ // for tools that retrieve the versions from a revision (commit hash)
const resolvedVersion = tool.latestVersion?.toString() || '1.0.0';
const infoPath = path.join(dir, `${version}.info`);
version = `v${resolvedVersion}`;
diff --git a/tools/allTools.ts.in b/tools/allTools.ts.in
index e6377b8..b088054 100644
--- a/tools/allTools.ts.in
+++ b/tools/allTools.ts.in
@@ -213,20 +213,10 @@
replacedByGopls: false,
isImportant: true,
description: 'Go debugger (Delve)',
+ latestVersion: semver.parse('v1.6.1'), // minimum version that supports DAP
+ latestVersionTimestamp: moment('2021-05-19', 'YYYY-MM-DD'),
minimumGoVersion: semver.coerce('1.12') // dlv requires 1.12+ for build
},
- 'dlv-dap': {
- name: 'dlv-dap',
- importPath: 'github.com/go-delve/delve/cmd/dlv',
- modulePath: 'github.com/go-delve/delve',
- replacedByGopls: false,
- isImportant: true,
- description: 'Go debugger & debug adapter (Delve DAP)',
- defaultVersion: '%s', // pinned version
- minimumGoVersion: semver.coerce('1.12'), // dlv requires 1.12+ for build
- latestVersion: semver.parse('%s'),
- latestVersionTimestamp: moment('%s', 'YYYY-MM-DD')
- },
'fillstruct': {
name: 'fillstruct',
importPath: 'github.com/davidrjenni/reftools/cmd/fillstruct',
diff --git a/tools/generate.go b/tools/generate.go
index e3169d1..87e540c 100644
--- a/tools/generate.go
+++ b/tools/generate.go
@@ -15,7 +15,6 @@
import (
"bytes"
"encoding/json"
- "errors"
"flag"
"fmt"
"io"
@@ -24,7 +23,6 @@
"os"
"os/exec"
"path/filepath"
- "regexp"
"sort"
"strings"
@@ -232,18 +230,6 @@
// Clear so that we can rewrite src/goToolsInformation.ts.
b.Reset()
- // Check for latest dlv-dap version.
- dlvVersion, err := listModuleVersion("github.com/go-delve/delve@master")
- if err != nil {
- log.Fatal(err)
- }
- // Due to https://github.com/golang/vscode-go/issues/1682, we cannot use
- // pseudo-version as the pinned version reliably.
- dlvRevOrStable := dlvVersion.Version
- if rev, err := pseudoVersionRev(dlvVersion.Version); err == nil { // pseudo-version
- dlvRevOrStable = rev
- }
-
// Check for the latest gopls version.
versions, err := listAllModuleVersions("golang.org/x/tools/gopls")
if err != nil {
@@ -277,7 +263,7 @@
}
// TODO(suzmue): change input to json and avoid magic string printing.
- toolsString := fmt.Sprintf(string(data), goplsVersion.Version, goplsVersion.Time[:len("YYYY-MM-DD")], goplsVersionPre.Version, goplsVersionPre.Time[:len("YYYY-MM-DD")], dlvRevOrStable, dlvVersion.Version, dlvVersion.Time[:len("YYYY-MM-DD")])
+ toolsString := fmt.Sprintf(string(data), goplsVersion.Version, goplsVersion.Time[:len("YYYY-MM-DD")], goplsVersionPre.Version, goplsVersionPre.Time[:len("YYYY-MM-DD")])
// Write tools section.
b.WriteString(toolsString)
@@ -693,19 +679,3 @@
}
return b.String()
}
-
-// pseudoVersionRev extracts the revision info if the given version is pseudo version.
-// We wanted to use golang.org/x/mod/module.PseudoVersionRev, but couldn't due to
-// an error in the CI. This is a workaround.
-//
-// It assumes the version string came from the proxy, so a valid, canonical version
-// string. Thus, the check for pseudoversion is not as robust as golang.org/x/mod/module
-// offers.
-func pseudoVersionRev(ver string) (rev string, _ error) {
- var pseudoVersionRE = regexp.MustCompile(`^v[0-9]+\.(0\.0-|\d+\.\d+-([^+]*\.)?0\.)\d{14}-[A-Za-z0-9]+(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$`)
- if strings.Count(ver, "-") < 2 || !pseudoVersionRE.MatchString(ver) {
- return "", errors.New("not a pseudo version")
- }
- j := strings.LastIndex(ver, "-")
- return ver[j+1:], nil
-}
diff --git a/tools/installtools/main.go b/tools/installtools/main.go
index 99a2def..d892bd2 100644
--- a/tools/installtools/main.go
+++ b/tools/installtools/main.go
@@ -31,7 +31,6 @@
{"github.com/zmb3/gogetdoc", "", ""},
{"honnef.co/go/tools/cmd/staticcheck", "", ""},
{"golang.org/x/tools/cmd/gorename", "", ""},
- {"github.com/go-delve/delve/cmd/dlv", "master", "dlv-dap"},
{"github.com/go-delve/delve/cmd/dlv", "", ""},
}
@@ -140,7 +139,3 @@
}
return b
}
-
-func runWithGoInstall() error {
- return nil
-}
To view, visit change 374594. To unsubscribe, or for help writing mail filters, visit settings.