Description
Go version
go version go1.22.3 linux/amd64
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/.cache/go-build'
GOENV='/home/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/user/1000/go-build3235747414=/tmp/go-build -gno-record-gcc-switches'
What did you do?
I tried to view the value of different types of const values with dlv.
Code:
package main
import "fmt"
const myValueStr = "try"
const myValueInt = 12
const myValueFloat = 1.2func main() {
fmt.Println(myValueStr, myValueInt, myValueFloat)
}
What did you see happen?
I obtain a different behavior depending of the type of the constant.
Debug:
dlv exec main
(dlv) print main.constValueInt
12
(dlv) print main.constValueStr
Command failed: could not find symbol value for main
(dlv) print main.constValueFloat
Command failed: could not find symbol value for main
Analyze:
objdump -W main | grep -i constV
<2547> DW_AT_name : main.constValueInt
By analyzing Go ompiler code, we can see into src/cmd/compile/internal/gc/obj.go:163 that's the func dumpGlobalConst exports only integer const "for now" (ie. comment line 172).
What did you expect to see?
I expect to see all const values.
Debug:
dlv exec main
(dlv) print main.constValueInt
12
(dlv) print main.constValueStr
"try"
(dlv) print main.constValueFloat
1.2
Analyze:
objdump -W main | grep -i constV
<2547> DW_AT_name : main.constValueInt
<2547> DW_AT_name : main.constValueStr
<2547> DW_AT_name : main.constValueFloat
Metadata
Metadata
Assignees
Labels
Type
Projects
Status