问题
we are trying to debug Go code and getting this error:
could not launch process: decoding dwarf section info at offset 0x0: too short
our settings:
WITSC02X6385JGH:orderer sjain68$ uname -a
Darwin WITSC02X6385JGH 17.7.0 Darwin Kernel Version 17.7.0: Fri Jul 6 19:54:51 PDT 2018; root:xnu-4570.71.3~2/RELEASE_X86_64 x86_64
WITSC02X6385JGH:orderer sjain68$ go version
go version go1.11 darwin/amd64
WITSC02X6385JGH:orderer sjain68$ dlv version
Delve Debugger
Version: 1.1.0
Build: $Id: 1990ba12450cab9425a2ae62e6ab988725023d5c
Things we have tried:
- Update dlv using VS Code -> Go: Install/Update Tools
Try running from command line:
WITSC02X6385JGH:orderer sjain68$ /Users/sjain68/go/bin/dlv debug github.com/hyperledger/fabric/orderer --headless=true --listen=127.0.0.1:41305 --api-version=2 --log=true --
API server listening at: 127.0.0.1:41305
INFO[0002] launching process with args: [/Users/sjain68/go/src/github.com/hyperledger/fabric/orderer/debug] layer=debugger
debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-902.0.79.7
for x86_64.
Got a connection, launched process /Users/sjain68/go/src/github.com/hyperledger/fabric/orderer/debug (pid = 9278).
Exiting.
could not launch process: decoding dwarf section info at offset 0x0: too short
Note that the binary that we are trying to debug does gets executed. Its just that the debugger does not launch.
Another thing we tried from this link:
WITSC02X6385JGH:orderer sjain68$ export GOFLAGS="-ldflags=-compressdwarf=false"; dlv debug
could not launch process: decoding dwarf section info at offset 0x0: too short
Someone said to run GOCACHE=off go build ... and output of that is pasted here.
How can we fix this?
回答1:
I had the same issue after updateing Go. Updating Delve package from console helped:
go get -u github.com/go-delve/delve/cmd/dlv
回答2:
The solution that worked for us was to upgrade Go version
$ go version
go version go1.13.3 darwin/amd64
So Go 1.11 is the culprit.
来源:https://stackoverflow.com/questions/54333761/unable-to-debug-go-code-could-not-launch-process-decoding-dwarf-section-info-a