Gerrit Dou has uploaded this change for review.
debugging.md: note that 'go build', not 'go run' must be used with dlv
Updates https://github.com/go-delve/delve/issues/2844
Change-Id: I1886c63e5eb1acc7ac48072b68239770367acf87
GitHub-Last-Rev: 06fe6868bb2110d6238953244a93d7e9e0543ef4
GitHub-Pull-Request: golang/vscode-go#1982
---
M docs/debugging.md
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/docs/debugging.md b/docs/debugging.md
index 4019f80..9366604 100644
--- a/docs/debugging.md
+++ b/docs/debugging.md
@@ -84,8 +84,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).
@@ -97,6 +98,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:
@@ -420,7 +422,7 @@
$ dlv-dap dap --listen=:12345
```
-Use the following `launch` configuration to tell `dlv-dap` to execute a binary precompiled with `-gcflags='all=-N -l'`:
+Use the following `launch` configuration to tell `dlv-dap` to execute a binary precompiled with `go build -gcflags='all=-N -l'`:
```json5
{
@@ -504,6 +506,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-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).
To view, visit change 374674. To unsubscribe, or for help writing mail filters, visit settings.
Gerrit Dou uploaded patch set #2 to this change.
debugging.md: note that 'go build', not 'go run' must be used with dlv
Updates go-delve/delve#2844
Change-Id: I1886c63e5eb1acc7ac48072b68239770367acf87
GitHub-Last-Rev: 06fe6868bb2110d6238953244a93d7e9e0543ef4
GitHub-Pull-Request: golang/vscode-go#1982
---
M docs/debugging.md
1 file changed, 23 insertions(+), 3 deletions(-)
To view, visit change 374674. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Gerrit Dou uploaded patch set #3 to this change.
debugging.md: note that 'go build', not 'go run' must be used with dlv
Updates go-delve/delve#2844
Change-Id: I1886c63e5eb1acc7ac48072b68239770367acf87
GitHub-Last-Rev: 692327cdf92c67997d979ea9fee90f25c851997f
GitHub-Pull-Request: golang/vscode-go#1982
---
M docs/debugging.md
1 file changed, 23 insertions(+), 3 deletions(-)
To view, visit change 374674. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Gerrit Dou uploaded patch set #4 to this change.
debugging.md: note that 'go build', not 'go run' must be used with dlv
Updates go-delve/delve#2844
Change-Id: I1886c63e5eb1acc7ac48072b68239770367acf87
GitHub-Last-Rev: a64cb34ca857bf96188c3e836121dc3323d2ba82
GitHub-Pull-Request: golang/vscode-go#1982
---
M docs/debugging.md
1 file changed, 23 insertions(+), 3 deletions(-)
To view, visit change 374674. To unsubscribe, or for help writing mail filters, visit settings.
Patch set 4:Code-Review +2
1 comment:
File docs/debugging.md:
Patch Set #4, Line 88: must be built with `go build -gcflags=all="-N -l"`
Weird that people attempt to debug a binary running with go run :-(
Strictly speaking, binaries built with bazel, blaze, or other build systems can be debugged by supplying the gcflags.
To view, visit change 374674. To unsubscribe, or for help writing mail filters, visit settings.
Patch set 4:Trust +1
Attention is currently required from: Hyang-Ah Hana Kim.
1 comment:
File docs/debugging.md:
Patch Set #4, Line 88: must be built with `go build -gcflags=all="-N -l"`
Weird that people attempt to debug a binary running with go run :-( […]
Hmm, I see your point. We could add something like "or another compatible build system"? But then this already long note will get even longer.
To view, visit change 374674. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Polina Sokolova.
1 comment:
File docs/debugging.md:
Patch Set #4, Line 88: must be built with `go build -gcflags=all="-N -l"`
Hmm, I see your point. […]
Let's just go with your current version. It looks like people are so creative that it's impossible to enumerate all the possibilities and exceptions people would encounter. We explicitly cover here the case we verified working - so it's an improvement.
To view, visit change 374674. To unsubscribe, or for help writing mail filters, visit settings.
Polina Sokolova submitted this change.
debugging.md: note that 'go build', not 'go run' must be used with dlv
Updates go-delve/delve#2844
Change-Id: I1886c63e5eb1acc7ac48072b68239770367acf87
GitHub-Last-Rev: a64cb34ca857bf96188c3e836121dc3323d2ba82
GitHub-Pull-Request: golang/vscode-go#1982
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/374674
Reviewed-by: Hyang-Ah Hana Kim <hya...@gmail.com>
Trust: Ian Lance Taylor <ia...@golang.org>
---
M docs/debugging.md
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/docs/debugging.md b/docs/debugging.md
index 051b019..b51ffea 100644
--- a/docs/debugging.md
+++ b/docs/debugging.md
@@ -84,8 +84,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).
@@ -97,6 +98,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:
@@ -420,7 +422,7 @@
$ dlv-dap dap --listen=:12345
```
-Use the following `launch` configuration to tell `dlv-dap` to execute a binary precompiled with `-gcflags='all=-N -l'`:
+Use the following `launch` configuration to tell `dlv-dap` to execute a binary precompiled with `go build -gcflags='all=-N -l'`:
```json5
{
@@ -504,6 +506,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-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).
To view, visit change 374674. To unsubscribe, or for help writing mail filters, visit settings.