diff --git a/docs/debugging.md b/docs/debugging.md index baff27bde5..fad2d4985e 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -240,6 +240,7 @@ Here is the list of attributes specific to Go debugging. | `args` | Command line arguments passed to the debugged program.
|
_n/a_
| | `backend` | Backend used by delve. Maps to `dlv`'s `--backend` flag.

Allowed Values: `"default"`, `"native"`, `"lldb"`
|

_same as Launch_
| | `buildFlags` | Build flags, to be passed to the Go compiler. Maps to dlv's `--build-flags` flag.
(Default: `""`)
|
_n/a_
| +| `coreFilePath` | Path to the core dump file to open. For use on 'core' mode only
(Default: `""`)
|
_n/a_
| | `cwd` | Workspace relative or absolute path to the working directory of the program being debugged if a non-empty value is specified. The `program` folder is used as the working directory if `cwd` is omitted or empty.
(Default: `""`)
| Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
(Default: `"${workspaceFolder}"`)
| | `debugAdapter` | Select which debug adapter to use with this launch configuration.

Allowed Values: `"legacy"`, `"dlv-dap"`
(Default: `dlv-dap`)
|

_same as Launch_
| | `dlvFlags` | Extra flags for `dlv`. See `dlv help` for the full list of supported. Flags such as `--log-output`, `--log`, `--log-dest`, `--api-version`, `--output`, `--backend` 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.
|
_same as Launch_
| @@ -248,7 +249,7 @@ Here is the list of attributes specific to Go debugging. | `host` | The host name of the machine the delve debugger will be listening on.
(Default: `"127.0.0.1"`)
|
_same as Launch_
| | `logDest` | dlv's `--log-dest` flag. See `dlv log` for details. Number argument is not allowed. Supported only in `dlv-dap` mode, and on Linux and Mac OS.
| dlv's `--log-dest` flag. See `dlv log` for details. Number argument is not allowed. Supported only in `dlv-dap` mode and on Linux and Mac OS.
| | `logOutput` | Comma separated list of components that should produce debug output. Maps to dlv's `--log-output` flag. Check `dlv log` for details.

Allowed Values: `"debugger"`, `"gdbwire"`, `"lldbout"`, `"debuglineerr"`, `"rpc"`, `"dap"`
(Default: `"debugger"`)
|

_same as Launch_
| -| `mode` | One of `auto`, `debug`, `test`, `exec`. In `auto` mode, the extension will choose either `debug` or `test` depending on active editor window.

Allowed Values: `"auto"`, `"debug"`, `"test"`, `"exec"`
(Default: `auto`)
| Indicates local or remote debugging. Local maps to the `dlv attach` command, remote maps to `connect`. `remote` is not supported in `dlv-dap` mode currently. Use `host` and `port` instead.

Allowed Values: `"local"`, `"remote"`
(Default: `local`)
| +| `mode` | One of `auto`, `debug`, `test`, `exec`, `replay`, `core`. In `auto` mode, the extension will choose either `debug` or `test` depending on active editor window.

Allowed Values: `"auto"`, `"debug"`, `"test"`, `"exec"`, `"replay"`, `"core"`
(Default: `auto`)
| Indicates local or remote debugging. Local maps to the `dlv attach` command, remote maps to `connect`. `remote` is not supported in `dlv-dap` mode currently. Use `host` and `port` instead.

Allowed Values: `"local"`, `"remote"`
(Default: `local`)
| | `output` | Output path for the binary of the debugee.
(Default: `"debug"`)
|

_n/a_
| | `port` | The port that the delve debugger will be listening on.
(Default: `2345`)
|
_same as Launch_
| | `processId` |
_n/a_
|

Option 1: Use process picker to select a process to attach, or Process ID as integer.

Allowed Values: `"${command:pickProcess}"`, `"${command:pickGoProcess}"`

Option 2: Attach to a process by name. If more than one process matches the name, use the process picker to select a process.

Option 3: The numeric ID of the process to be debugged. If 0, use the process picker to select a process.

(Default: `0`)
| @@ -260,6 +261,7 @@ Here is the list of attributes specific to Go debugging. | `stopOnEntry` | Automatically stop program after launch.
(Default: `false`)
| Automatically stop program after attach.
(Default: `false`)
| | `substitutePath` | An array of mappings from a local path (editor) to the remote path (debugee). This setting is useful when working in a file system with symbolic links, running remote debugging, or debugging an executable compiled externally. The debug adapter will replace the local path with the remote path in all of the calls.



| An array of mappings from a local path (editor) to the remote path (debugee). This setting is useful when working in a file system with symbolic links, running remote debugging, or debugging an executable compiled externally. The debug adapter will replace the local path with the remote path in all of the calls. Overriden by `remotePath`.



| | `trace` | Various levels of logging shown in the debug console & 'Go Debug' output channel. When using the `legacy` debug adapter, the logs will also be written to a file if it is set to a value other than `error`.

Allowed Values: `"verbose"`, `"trace"`, `"log"`, `"info"`, `"warn"`, `"error"`
(Default: `"error"`)
|

_same as Launch_
| +| `traceDirPath` | Directory in which the record trace is located or to be created for a new output trace. For use on 'replay' mode only
(Default: `""`)
|
_n/a_
| ⚠️ `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`. diff --git a/package.json b/package.json index d903528132..5b38190352 100644 --- a/package.json +++ b/package.json @@ -541,11 +541,23 @@ "auto", "debug", "test", - "exec" + "exec", + "replay", + "core" ], - "description": "One of `auto`, `debug`, `test`, `exec`. In `auto` mode, the extension will choose either `debug` or `test` depending on active editor window.", + "description": "One of `auto`, `debug`, `test`, `exec`, `replay`, `core`. In `auto` mode, the extension will choose either `debug` or `test` depending on active editor window.", "default": "auto" }, + "traceDirPath": { + "type": "string", + "description": "Directory in which the record trace is located or to be created for a new output trace. For use on 'replay' mode only", + "default": "" + }, + "coreFilePath": { + "type": "string", + "description": "Path to the core dump file to open. For use on 'core' mode only", + "default": "" + }, "stopOnEntry": { "type": "boolean", "description": "Automatically stop program after launch.", diff --git a/src/goDebugFactory.ts b/src/goDebugFactory.ts index 09fceda2f7..a71b53e775 100644 --- a/src/goDebugFactory.ts +++ b/src/goDebugFactory.ts @@ -492,10 +492,17 @@ export function parseProgramArgSync( launchAttachArgs: vscode.DebugConfiguration ): { program: string; dirname: string; programIsDirectory: boolean } { const program = launchAttachArgs.program; + let programIsDirectory = false; + + if (launchAttachArgs.mode === 'replay') { + // Skip program parsing on modes that do not require a program + return { program: '', dirname: '', programIsDirectory: programIsDirectory }; + } + if (!program) { throw new Error('The program attribute is missing in the debug configuration in launch.json'); } - let programIsDirectory = false; + try { programIsDirectory = fs.lstatSync(program).isDirectory(); } catch (e) {