src/goDebugFactory.ts: remove the "godlvdap" debug type
The user can now use dlv-dap by changing the user setting
go.useDlvDap=true. This allows users to keep a single set
of configurations in launch.json to activate both the
legacy and the new adapter.
Change-Id: I6b10409162a8cb00f2a74ad1850fa486f2cdf949
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/290749
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/docs/settings.md b/docs/settings.md
index abde52b..496d30b 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -438,6 +438,11 @@
Complete functions with their parameter signature, excluding the variable types. Use `gopls.usePlaceholders` when using the language server.
Default: `false`
+### `go.useDlvDap`
+
+Use the Go debug adapter implemented in "delve". This debug adapter is still experimental.
+
+Default: `false`
### `go.useGoProxyToCheckForToolUpdates (deprecated)`
Use `go.toolsManagement.checkForUpdates` instead.
diff --git a/package.json b/package.json
index 99d94a5..eadf780 100644
--- a/package.json
+++ b/package.json
@@ -827,9 +827,10 @@
"gdbwire",
"lldbout",
"debuglineerr",
- "rpc"
+ "rpc",
+ "dap"
],
- "description": "Comma separated list of components that should produce debug output. Maps to `--log-output` flag.",
+ "description": "Comma separated list of components that should produce debug output. Maps to `--log-output` flag. `dap` is only applicable if using dlv-dap",
"default": "debugger"
},
"dlvLoadConfig": {
@@ -892,395 +893,6 @@
}
}
}
- },
- {
- "type": "godlvdap",
- "label": "Go Dlv Dap (Experimental)",
- "languages": [
- "go"
- ],
- "configurationSnippets": [
- {
- "label": "Go: Launch package",
- "description": "Debug the package in the program attribute",
- "body": {
- "name": "${2:Launch Package}",
- "type": "godlvdap",
- "request": "launch",
- "mode": "debug",
- "program": "^\"\\${workspaceFolder}${1:}\""
- }
- },
- {
- "label": "Go: Launch file",
- "description": "Debug the file in the program attribute",
- "body": {
- "name": "${2:Launch file}",
- "type": "godlvdap",
- "request": "launch",
- "mode": "debug",
- "program": "^\"${1:\\${file\\}}\""
- }
- },
- {
- "label": "Go: Launch test package",
- "description": "Debug the test package in the program attribute",
- "body": {
- "name": "${2:Launch test package}",
- "type": "godlvdap",
- "request": "launch",
- "mode": "test",
- "program": "^\"\\${workspaceFolder}${1:}\""
- }
- },
- {
- "label": "Go: Launch test function",
- "description": "Debug the test function in the args, ensure program attributes points to right package",
- "body": {
- "name": "${3:Launch test function}",
- "type": "godlvdap",
- "request": "launch",
- "mode": "test",
- "program": "^\"\\${workspaceFolder}${1:}\"",
- "args": [
- "-test.run",
- "${2:MyTestFunction}"
- ]
- }
- },
- {
- "label": "Go: Attach to local process",
- "description": "Attach to an existing process by process ID",
- "body": {
- "name": "${1:Attach to Process}",
- "type": "godlvdap",
- "request": "attach",
- "mode": "local",
- "processId": 0
- }
- },
- {
- "label": "Go: Connect to server",
- "description": "Connect to a remote headless debug server",
- "body": {
- "name": "${1:Connect to server}",
- "type": "godlvdap",
- "request": "attach",
- "mode": "remote",
- "remotePath": "^\"\\${workspaceFolder}\"",
- "port": 2345,
- "host": "127.0.0.1"
- }
- }
- ],
- "configurationAttributes": {
- "launch": {
- "required": [],
- "properties": {
- "program": {
- "type": "string",
- "description": "Path to the program folder (or any file within that folder) when in 'debug' or 'test' mode, and to the pre-built binary file to debug in 'exec' mode.",
- "default": "${workspaceFolder}"
- },
- "mode": {
- "enum": [
- "auto",
- "debug",
- "test",
- "exec"
- ],
- "description": "One of 'auto', 'debug', 'test', 'exec'.",
- "default": "auto"
- },
- "stopOnEntry": {
- "type": "boolean",
- "description": "Automatically stop program after launch.",
- "default": false
- },
- "args": {
- "type": "array",
- "description": "Command line arguments passed to the program.",
- "items": {
- "type": "string"
- },
- "default": []
- },
- "showLog": {
- "type": "boolean",
- "description": "Show log output from the delve debugger. Maps to dlv's `--log` flag.",
- "default": false
- },
- "cwd": {
- "type": "string",
- "description": "Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.",
- "default": "."
- },
- "env": {
- "type": "object",
- "description": "Environment variables passed to the program.",
- "default": {}
- },
- "buildFlags": {
- "type": "string",
- "description": "Build flags, to be passed to the Go compiler.",
- "default": ""
- },
- "init": {
- "type": "string",
- "description": "Init file, executed by the terminal client.",
- "default": ""
- },
- "dlvFlags": {
- "type": "array",
- "description": "Extra flags for `dlv`. See `dlv help` for the full list of supported. Flags such as `--log-output` and `--log` already have corresponding properties in the debug configuration, and flags such as `--listen` and `--headless` are used internally. If they are specified in `dlvFlags`, they may be ignored or cause an error.",
- "items": {
- "type": "string"
- },
- "default": []
- },
- "remotePath": {
- "type": "string",
- "description": "Absolute path to the file being debugged on the remote machine in case of remote debugging.",
- "default": ""
- },
- "port": {
- "type": "number",
- "description": "The port that the delve debugger will be listening on.",
- "default": 2345
- },
- "host": {
- "type": "string",
- "description": "The host name of the machine the delve debugger will be listening on.",
- "default": "127.0.0.1"
- },
- "trace": {
- "type": "string",
- "enum": [
- "log",
- "verbose",
- "error"
- ],
- "default": "error",
- "description": "Various levels of logging shown in the debug console. When set to 'log' or 'verbose', the logs will also be written to a file."
- },
- "envFile": {
- "type": [
- "string",
- "array"
- ],
- "items": {
- "type": "string"
- },
- "description": "Absolute path to a file containing environment variable definitions. Multiple files can be specified by provided an array of absolute paths",
- "default": "${workspaceFolder}/.env"
- },
- "backend": {
- "type": "string",
- "enum": [
- "default",
- "native",
- "lldb"
- ],
- "description": "Backend used by delve. Only available in delve version 0.12.2 and above."
- },
- "output": {
- "type": "string",
- "description": "Output path for the binary of delve. Maps to dlv's `--output` flag.",
- "default": "debug"
- },
- "logOutput": {
- "type": "string",
- "enum": [
- "debugger",
- "gdbwire",
- "lldbout",
- "debuglineerr",
- "dap"
- ],
- "description": "Comma separated list of components that should produce debug output. Maps to dlv's `--log-output` flag.",
- "default": "debugger"
- },
- "dlvLoadConfig": {
- "type": "object",
- "properties": {
- "followPointers": {
- "type": "boolean",
- "description": "FollowPointers requests pointers to be automatically dereferenced",
- "default": true
- },
- "maxVariableRecurse": {
- "type": "number",
- "description": "MaxVariableRecurse is how far to recurse when evaluating nested types",
- "default": 1
- },
- "maxStringLen": {
- "type": "number",
- "description": "MaxStringLen is the maximum number of bytes read from a string",
- "default": 64
- },
- "maxArrayValues": {
- "type": "number",
- "description": "MaxArrayValues is the maximum number of elements read from an array, a slice or a map",
- "default": 64
- },
- "maxStructFields": {
- "type": "number",
- "description": "MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields",
- "default": -1
- }
- },
- "description": "LoadConfig describes to delve, how to load values from target's memory",
- "default": {
- "followPointers": true,
- "maxVariableRecurse": 1,
- "maxStringLen": 64,
- "maxArrayValues": 64,
- "maxStructFields": -1
- }
- },
- "stackTraceDepth": {
- "type": "number",
- "description": "Maximum depth of stack trace collected from Delve",
- "default": 50
- },
- "showGlobalVariables": {
- "type": "boolean",
- "default": false,
- "description": "Boolean value to indicate whether global package variables should be shown in the variables pane or not."
- }
- }
- },
- "attach": {
- "required": [],
- "properties": {
- "processId": {
- "type": "number",
- "description": "The ID of the process to be debugged."
- },
- "mode": {
- "enum": [
- "local",
- "remote"
- ],
- "description": "Indicates local or remote debugging. Local maps to the dlv 'attach' command, remote maps to 'connect'.",
- "default": "local"
- },
- "dlvFlags": {
- "type": "array",
- "description": "Extra flags for `dlv`. See `dlv help` for the full list of supported. Flags such as `--log-output` and `--log` already have corresponding properties in the debug configuration, and flags such as `--listen` and `--headless` are used internally. If they are specified in `dlvFlags`, they may be ignored or cause an error.",
- "items": {
- "type": "string"
- },
- "default": []
- },
- "showLog": {
- "type": "boolean",
- "description": "Show log output from the delve debugger. Maps to dlv's `--log` flag.",
- "default": false
- },
- "cwd": {
- "type": "string",
- "description": "Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.",
- "default": "${workspaceFolder}"
- },
- "remotePath": {
- "type": "string",
- "description": "If remote debugging, the path to the source code on the remote machine, if different from the local machine. If specified, becomes the first entry in substitutePath.",
- "default": ""
- },
- "port": {
- "type": "number",
- "description": "The port that the delve debugger will be listening on.",
- "default": 2345
- },
- "host": {
- "type": "string",
- "description": "The host name of the machine the delve debugger will be listening on.",
- "default": "127.0.0.1"
- },
- "trace": {
- "type": "string",
- "enum": [
- "log",
- "verbose",
- "error"
- ],
- "default": "error",
- "description": "Various levels of logging shown in the debug console. When set to 'log' or 'verbose', the logs will also be written to a file."
- },
- "backend": {
- "type": "string",
- "enum": [
- "default",
- "native",
- "lldb"
- ],
- "description": "Backend used by delve. Only available in delve version 0.12.2 and above."
- },
- "logOutput": {
- "type": "string",
- "enum": [
- "debugger",
- "gdbwire",
- "lldbout",
- "debuglineerr",
- "dap",
- "rpc"
- ],
- "description": "Comma separated list of components that should produce debug output. Maps to dlv's `--log-output` flag.",
- "default": "debugger"
- },
- "dlvLoadConfig": {
- "type": "object",
- "properties": {
- "followPointers": {
- "type": "boolean",
- "description": "FollowPointers requests pointers to be automatically dereferenced",
- "default": true
- },
- "maxVariableRecurse": {
- "type": "number",
- "description": "MaxVariableRecurse is how far to recurse when evaluating nested types",
- "default": 1
- },
- "maxStringLen": {
- "type": "number",
- "description": "MaxStringLen is the maximum number of bytes read from a string",
- "default": 64
- },
- "maxArrayValues": {
- "type": "number",
- "description": "MaxArrayValues is the maximum number of elements read from an array, a slice or a map",
- "default": 64
- },
- "maxStructFields": {
- "type": "number",
- "description": "MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields",
- "default": -1
- }
- },
- "description": "LoadConfig describes to delve, how to load values from target's memory",
- "default": {
- "followPointers": true,
- "maxVariableRecurse": 1,
- "maxStringLen": 64,
- "maxArrayValues": 64,
- "maxStructFields": -1
- }
- },
- "stackTraceDepth": {
- "type": "number",
- "description": "Maximum depth of stack trace collected from Delve",
- "default": 50
- },
- "showGlobalVariables": {
- "type": "boolean",
- "default": false,
- "description": "Boolean value to indicate whether global package variables should be shown in the variables pane or not."
- }
- }
- }
- }
}
],
"configuration": {
@@ -2049,6 +1661,11 @@
"description": "Folder names (not paths) to ignore while using Go to Symbol in Workspace feature. Not applicable when using the language server.",
"scope": "resource"
},
+ "go.useDlvDap": {
+ "type": "boolean",
+ "default": false,
+ "description": "Use the Go debug adapter implemented in \"delve\". This debug adapter is still experimental."
+ },
"go.delveConfig": {
"type": "object",
"properties": {
diff --git a/src/goDebugFactory.ts b/src/goDebugFactory.ts
index 39eac56..a9c4c4a 100644
--- a/src/goDebugFactory.ts
+++ b/src/goDebugFactory.ts
@@ -9,6 +9,7 @@
import path = require('path');
import { DebugConfiguration } from 'vscode';
import vscode = require('vscode');
+import { getGoConfig } from './config';
import { logError, logInfo } from './goLogging';
import { envPath } from './utils/pathUtils';
import { killProcessTree } from './utils/processUtils';
@@ -21,20 +22,32 @@
session: vscode.DebugSession,
executable: vscode.DebugAdapterExecutable | undefined
): Promise<vscode.ProviderResult<vscode.DebugAdapterDescriptor>> {
+ const config = getGoConfig();
+ if (config['useDlvDap']) {
+ return this.createDebugAdapterDescriptorDlvDap(session.configuration);
+ }
+ // Terminate any running dlv dap server process.
+ await this.terminateDlvDapServerProcess();
+ return executable;
+ }
+
+ public async dispose() {
+ await this.terminateDlvDapServerProcess();
+ }
+
+ private async createDebugAdapterDescriptorDlvDap(
+ configuration: vscode.DebugConfiguration,
+ ): Promise<vscode.ProviderResult<vscode.DebugAdapterDescriptor>> {
// The dlv-dap server currently receives certain flags and arguments on startup
// and must be started in an appropriate folder for the program to be debugged.
// In order to support this, we kill the current dlv-dap server, and start a
// new one.
await this.terminateDlvDapServerProcess();
- const {port, host} = await this.startDapServer(session.configuration);
+ const {port, host} = await this.startDapServer(configuration);
return new vscode.DebugAdapterServer(port, host);
}
- public async dispose() {
- await this.terminateDlvDapServerProcess();
- }
-
private async terminateDlvDapServerProcess() {
if (this.dlvDapServer) {
await killProcessTree(this.dlvDapServer);
diff --git a/src/goMain.ts b/src/goMain.ts
index 3a53c3f..14beeb0 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -187,8 +187,6 @@
ctx.subscriptions.push(
vscode.debug.registerDebugConfigurationProvider('go', new GoDebugConfigurationProvider('go')));
ctx.subscriptions.push(
- vscode.debug.registerDebugConfigurationProvider('godlvdap', new GoDebugConfigurationProvider('godlvdap')));
- ctx.subscriptions.push(
vscode.commands.registerCommand('go.debug.pickProcess', async (): Promise<string> => {
return await pickProcess();
}));
@@ -199,7 +197,7 @@
const factory = new GoDebugAdapterDescriptorFactory();
ctx.subscriptions.push(
- vscode.debug.registerDebugAdapterDescriptorFactory('godlvdap', factory));
+ vscode.debug.registerDebugAdapterDescriptorFactory('go', factory));
if ('dispose' in factory) {
ctx.subscriptions.push(factory);
}
@@ -704,7 +702,7 @@
return;
}
const session = vscode.debug.activeDebugSession;
- if (session && (session.type === 'go' || session.type === 'godlvdap')) {
+ if (session && (session.type === 'go')) {
const neverAgain = { title: `Don't Show Again` };
const ignoreActiveDebugWarningKey = 'ignoreActiveDebugWarningKey';
const ignoreActiveDebugWarning = getFromGlobalState(ignoreActiveDebugWarningKey);