Unable to debug Go code: could not launch process: decoding dwarf section info at offset 0x0: too short
Asked Answered
M

4

5

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?

Memorial answered 23/1, 2019 at 18:45 Comment(2)
Did you read this answer?Firooc
Yes we have. Is there anything in that answer that we have not tried?Memorial
M
1

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.

Memorial answered 25/10, 2019 at 23:35 Comment(0)
O
7

I had the same issue after updateing Go. Updating Delve package from console helped:

go get -u github.com/go-delve/delve/cmd/dlv
Obstipation answered 18/3, 2019 at 8:39 Comment(0)
B
2

I was able to fix it using -ldflags=-linkmode internal

enter image description here

references :- https://github.com/go-delve/delve/issues/1138

Balas answered 19/9 at 20:46 Comment(1)
This fixed issue after upgrading to MacOS Sequia 15.0. Thx mateOralle
M
1

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.

Memorial answered 25/10, 2019 at 23:35 Comment(0)
L
1

make sure you aren't using flags that remove the debug info from your build ie -ldflags="-s -w" .

https://lukeeckley.com/post/useful-go-build-flags/

Lindblad answered 15/4, 2020 at 22:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.