Skip to content
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

debug/gosym: LineToPC doesn't work on macho files #51890

Closed
yardenlai opened this issue Mar 23, 2022 · 5 comments
Closed

debug/gosym: LineToPC doesn't work on macho files #51890

yardenlai opened this issue Mar 23, 2022 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@yardenlai
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.18 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/yarden/Library/Caches/go-build"
GOENV="/Users/yarden/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/yarden/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/yarden/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/yarden/go/go1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/yarden/go/go1.18/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6y/b_gs76zj0bl0frr40g1hrp080000gn/T/go-build2100507712=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I'm trying to use the LineToPC function in the gosym package. This is my parsing code:
https://go.dev/play/p/U1Rqy7nmrxd
You will have to use your own macho file to parse (pass to getTable) and fix the filename/lineno accordingly.
The macho file I try to parse was built with this command:
go build -gcflags="-N -l" -o helloWorld main.go

What did you expect to see?

The pc for the given filename and lineno

What did you see instead?

The filename and line I pass exist, but the error I am getting is:

no code at /Users/yarden/GolandProjects/playground/helloWorld/main.go

When I run the same code but try to parse an elf (I pass an elf to getTable), everything works as expected. The problem only occurs on macho files.

@mknyszek
Copy link
Contributor

CC @aclements @cherrymui maybe?

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 23, 2022
@mknyszek
Copy link
Contributor

Does this reproduce with older releases as well, or is this a regression in 1.18?

@mknyszek mknyszek added this to the Backlog milestone Mar 23, 2022
@yardenlai
Copy link
Author

Works in 1.15, but not in 1.16 and 1.17

@gopherbot
Copy link

Change https://go.dev/cl/395074 mentions this issue: debug/gosym: skip non-real functions in LineToPC lookup

@cherrymui cherrymui changed the title gosym/LineToPC: Doesn't work on macho files debug/gosym: LineToPC doesn't work on macho files Mar 23, 2022
@jeremyfaller
Copy link
Contributor

feels like this should be backported too.

@golang golang locked and limited conversation to collaborators Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants