Skip to content

Commit f5d1004

Browse files
committed
docs/debugging.md: add details for troubleshooting
Fixes #1719 Change-Id: I37d22ac0a6ec8d6854909eb87200f3c152fc1d56 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/370074 Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Polina Sokolova <[email protected]> TryBot-Result: kokoro <[email protected]>
1 parent 5cb334d commit f5d1004

File tree

2 files changed

+42
-37
lines changed

2 files changed

+42
-37
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ conduct-related issue, please mail [email protected].
170170
[code editing]: https://github.com/golang/vscode-go/blob/master/docs/features.md#code-editing
171171
[diagnostics]: https://github.com/golang/vscode-go/blob/master/docs/features.md#diagnostics
172172
[testing]: https://github.com/golang/vscode-go/blob/master/docs/features.md##run-and-test-in-the-editor
173-
[debugging]: https://github.com/golang/vscode-go/blob/master/docs/features.md#debugging
173+
[debugging]: https://github.com/golang/vscode-go/blob/master/docs/debugging.md#features
174174
[full feature breakdown]: https://github.com/golang/vscode-go/blob/master/docs/features.md
175175
[workspace documentation]: https://github.com/golang/tools/blob/master/gopls/doc/workspace.md
176176
[`Go: Install/Update Tools` command]: https://github.com/golang/vscode-go/blob/master/docs/commands.md#go-installupdate-tools

docs/debugging.md

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,49 @@ Sometimes you might like to launch the program for debugging outside of VS Code
457457

458458
The suggestions below are intended to help you troubleshoot any problems you encounter. If you are unable to resolve the issue, please take a look at the [current known debugging issues](https://github.com/golang/vscode-go/issues?q=is%3Aissue+is%3Aopen+label%3ADebug) or [report a new issue](#reporting-issues).
459459

460-
### Read documentation and [common issues](#common-issues)
460+
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.
461+
1. Check your `launch.json` configuration. Often error messages appearing in the DEBUG CONSOLE panel reveal issues.
462+
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).
463+
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).
464+
1. Capture [logs](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#collecting-logs) and inspect them.
465+
1. Look at the [existing debugging issues](https://github.com/golang/vscode-go/labels/Debug) if similar issues were reported.
466+
1. If none of these solve your problem, please [open a new issue](#reporting-issues).
461467

462-
Start by taking a quick glance at the [FAQs](#faqs) described below. You can also check the [Delve FAQ](https://github.com/go-delve/delve/blob/master/Documentation/faq.md) in case the problem is mentioned there.
468+
## FAQs
469+
470+
### I need to view large strings. How can I do that if `dlvLoadConfig` with `maxStringLen` is deprecated?
471+
472+
The legacy adapter used `dlvLoadConfig` as one-time session-wide setting to override dlv's conservative default variable loading limits, intended to protect tool's performance. The new debug adapter is taking a different approach with on-demand loading of composite data and updated string limits, relaxed when interacting with individual strings. In particular, if the new default limit of 512, applied to all string values in the variables pane, is not sufficient, you can take advantage of a larger limit of 4096 with one of the following:
473+
474+
* Hover over the variable in the source code
475+
* `Copy as Expression` to query the string via REPL in the DEBUG CONSOLE panel
476+
* `Copy Value` to clipboard
477+
478+
Please [open an issue](https://github.com/golang/vscode-go/issues/new) if this is not sufficient for your use case or if you have any additional feedback.
479+
480+
### Why does my debug session have an `invalid command` error when I try to step?
481+
482+
When stepping through a program on a particular goroutine, the debugger will make sure that the step is completed, even when interrupted by events on a different goroutine. If a breakpoint is hit on a different goroutine, the debug adapter will stop the program execution to allow you to inspect the state, even though the step request is still active.
483+
484+
If you attempt to make another step request you will get an `invalid command` error.
463485

486+
<p align="center"><img src="images/invalidCommandExceptionInfo.png" alt="Disable breakpoints from the Breakpoints context menu" width="75%"> </p>
487+
488+
Use `Continue` to resume program execution.
489+
490+
If you do not want the step request to be interrupted, you can disable all breakpoints from VS Code from the context menu in the `Breakpoints` view.
491+
492+
<p align="center"><img src="images/disablebps.png" alt="Disable breakpoints from the Breakpoints context menu" width="75%"> </p>
493+
494+
### My program does not stop at breakpoints.
495+
496+
Check the "BREAKPOINTS" section in the debug view and see if the breakpoints are [greyed out](https://code.visualstudio.com/docs/editor/debugging#_breakpoints) when your debug session is active. Setting `stopOnEntry` is a great way to pause execution at the start to _verify_ breakpoints are set correctly. Or [enable logging](#collecting-logs) and see if `setBreakpoints` requests succeeded with all the breakpoints _verified_.
497+
498+
This problem often occurs when the source location used in compiling the debugged program and the workspace directory VS Code uses are different. Common culprits are remote debugging where the program is built in the remote location, use of symbolic links, or use of `-trimpath` build flags. In this case, configure the `substitutePath` attribute in your launch configuration.
499+
500+
### Debug sessions started with the "debug test" CodeLens or the test UI does not use my `launch.json` configuration.
501+
502+
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.
464503
## Reporting Issues
465504

466505
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).
@@ -526,41 +565,7 @@ $ dlv-dap dap --listen=:12345 --log --log-output=dap
526565
}
527566
```
528567

529-
## FAQs
530-
531-
### I need to view large strings. How can I do that if `dlvLoadConfig` with `maxStringLen` is deprecated?
532-
533-
The legacy adapter used `dlvLoadConfig` as one-time session-wide setting to override dlv's conservative default variable loading limits, intended to protect tool's performance. The new debug adapter is taking a different approach with on-demand loading of composite data and updated string limits, relaxed when interacting with individual strings. In particular, if the new default limit of 512, applied to all string values in the variables pane, is not sufficient, you can take advantage of a larger limit of 4096 with one of the following:
534-
535-
* Hover over the variable in the source code
536-
* `Copy as Expression` to query the string via REPL in the DEBUG CONSOLE panel
537-
* `Copy Value` to clipboard
538-
539-
Please [open an issue](https://github.com/golang/vscode-go/issues/new) if this is not sufficient for your use case or if you have any additional feedback.
540-
541-
### Why does my debug session have an `invalid command` error when I try to step?
542-
543-
When stepping through a program on a particular goroutine, the debugger will make sure that the step is completed, even when interrupted by events on a different goroutine. If a breakpoint is hit on a different goroutine, the debug adapter will stop the program execution to allow you to inspect the state, even though the step request is still active.
544-
545-
If you attempt to make another step request you will get an `invalid command` error.
546568

547-
<p align="center"><img src="images/invalidCommandExceptionInfo.png" alt="Disable breakpoints from the Breakpoints context menu" width="75%"> </p>
548-
549-
Use `Continue` to resume program execution.
550-
551-
If you do not want the step request to be interrupted, you can disable all breakpoints from VS Code from the context menu in the `Breakpoints` view.
552-
553-
<p align="center"><img src="images/disablebps.png" alt="Disable breakpoints from the Breakpoints context menu" width="75%"> </p>
554-
555-
### My program does not stop at breakpoints.
556-
557-
Check the "BREAKPOINTS" section in the debug view and see if the breakpoints are [greyed out](https://code.visualstudio.com/docs/editor/debugging#_breakpoints) when your debug session is active. Setting `stopOnEntry` is a great way to pause execution at the start to _verify_ breakpoints are set correctly. Or [enable logging](#collecting-logs) and see if `setBreakpoints` requests succeeded with all the breakpoints _verified_.
558-
559-
This problem often occurs when the source location used in compiling the debugged program and the workspace directory VS Code uses are different. Common culprits are remote debugging where the program is built in the remote location, use of symbolic links, or use of `-trimpath` build flags. In this case, configure the `substitutePath` attribute in your launch configuration.
560-
561-
### Debug sessions started with the "debug test" CodeLens or the test UI does not use my `launch.json` configuration.
562-
563-
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.
564569

565570
[Delve]: https://github.com/go-delve/delve
566571
[VS Code variables]: https://code.visualstudio.com/docs/editor/variables-reference

0 commit comments

Comments
 (0)