dlv attach to Go runtime process that binary is built with go build -ldflags="-s -w"

41 Views Asked by At

I want to debug with dlv in runtime. However, our binary is built with ldflags="-s -w", is there any way to recover/load the symbol table and debug information? I cannot build another binary for the situation I want to check would no longer exist once I stop the process.

[environment]

go version: 1.21.6 linux/amd64
Go process run in a container

[build command]

go build -ldflags="-s -w" -o server cmd/server/main.go
0

There are 0 best solutions below