Skip to content

Commit ea58fe1

Browse files
committed
debugging.md: add FAQ on debugging binaries with missing debug info
Updates #182 Change-Id: I056edb1056499d714ae303988366780fa5620cdc GitHub-Last-Rev: 52890f1 GitHub-Pull-Request: #2152 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/396882 Trust: Jamal Carvalho <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent 106d188 commit ea58fe1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/debugging.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,9 @@ This problem often occurs when the source location used in compiling the debugge
510510

511511
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.
512512

513-
### Why can't I use local attach with a process started with `go run`?
513+
### Starting a debug session fails with `decoding dwarf section info at offset 0x0: too short` or `could not open debug info` error.
514514

515-
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.
515+
These errors indicate that your binary was built with linker flags that stripped the symbol table (`-s`) or the DWARF debug information (`-w`), making debugging impossible. If the binary is built while launching the session, make sure your `launch.json` configuration does not contain `"buildFlags": "--ldflags '-s -w'"`. If you use `debug test` or Test Explorer, check `go.buildFlags` in `settings.json`. If the binary is built externally, check the command-line flags and do not use `go run`. Unlike `go build`, `go run` passes `-s -w` to the linker under the hood. If you try to attach to such a binary with a debugger, it will fail with one of the above errors (see Go Issue [24833](https://github.com/golang/go/issues/24833)). Instead let dlv build the binary for you or use `go build -gcflags='all=-N -l'`.
516516

517517
## Reporting Issues
518518

0 commit comments

Comments
 (0)