-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dlv cannot attach to process spawned with go run
#2844
Comments
I can also reproduce on Ubuntu 20.04.3 LTS, same setup.
|
For dlv to work correctly, you must build your program with debugging symbols and with optimizations and inlining turned off. |
Closing, see also: golang/go#24833. Quod Go non dat, Delve non præstat. |
Bummer. I don't think the Go team will change this behaviour, but is it known why |
AFAIK go run is meant to run thing quickly so it doesn't bother building and writing debug info. And besides that to use go run you have to have the source available so you could just use 'dlv debug main.go' instead. |
@1ma Would you please kindly rerun your attach attempt with "go run" with logging enabled in
Looking more closely at your report, it doesn't look like |
Here you go.
|
On the command line I get this:
for the given reproducer. That said, something doesn't add up, the reproducer is a simple go program, it wouldn't link to libpthread.so, on the other hand something that does link to libpthread.so could go through the system linker, get linked to a bunch of C object files and end up containing a valid debug_info section for something (just not the go code). |
Updates go-delve/delve#2844 Change-Id: I1886c63e5eb1acc7ac48072b68239770367acf87 GitHub-Last-Rev: a64cb34 GitHub-Pull-Request: #1982 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/374674 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Trust: Ian Lance Taylor <iant@golang.org>
FTR. Might have something to do with Linux or Ubuntu.
|
I got |
dlv version
)?Both installed recently in
$GOPATH/bin
via theGo: Install/Update Tools
dialog of the VS Code Go extension:go version
)?go version go1.17.5 linux/amd64
, installed from https://go.dev/dl/Ubuntu 18.04.6 LTS, amd64
Given this simple program:
I can compile it with
go build main.go
, run it in a terminal with./main
, add a breakpoint on the Println line and then click "Attach to process" in the Debug dialog of VS Code. In a few seconds, the breakpoint triggers as expected:However, if I directly go for
go run main.go
and follow the same process I get what seems like a Delve error.I expected to be able to attach to a Go process spawned with
go run
and debug it.The text was updated successfully, but these errors were encountered: