7

I am running remote profiling of my golang application on a remote server using "net/http/pprof".
I have set PPROF_BINARY_PATH env variable for go tool to be able to find my the local binary on my machine.
When I use the "list" keyword in the go tool pprof cli - I get a "no such file or directory" when the go tool is looking for the .go source files.

Error: open /go/src/github.com/foo/bar/baz.go: no such file or directory

it looks like it is looking for the source files in the remote machine's GOPATH which is "/go/" while on my personal machine it is in my home directory so that file is in .

/Users/myuser/go/src/github.com/foo/bar/baz.go

When I copied the desired source code file outside my GOPATH and to the directory the go tool is searching for - the "list" keyword works as expected but this is of course not optimal.

OhadBasan
  • 797
  • 6
  • 15

2 Answers2

3
menghan@gram:/opt$ go tool pprof --help 2>&1 | grep source_path
    -source_path     Search path for source files

Option --source_path may help.

menghan
  • 1,098
  • 9
  • 14
0

I was running into a similar issue on command line, and used a pairing of trim_path to remove an absolute path as it failed to find the source to annotate.

go tool pprof -trim_path=/go/src/ -source_path=. -alloc_objects /tmp/ingest /tmp/heap.profile
(pprof) top3
Showing top 3 nodes out of 81
      flat  flat%   sum%        cum   cum%
  83976474 25.04% 25.04%   84461263 25.18%  github.com/<employer>/encoding/json.decoder.decodeString
  42240178 12.59% 37.63%   97645601 29.11%  github.com/<employer>/encoding/json.decoder.decodeInterface
  41605355 12.40% 50.03%  147466331 43.96%  github.com/<employer>/encoding/json.decoder.decodeMapStringInterface
list github.com/<employer>/encoding/json.decoder.decodeString

before: error: open /go/src/vendor/github.com/<rest of file path> 
after: (lists the code & allocs)
Mike Graf
  • 5,077
  • 4
  • 45
  • 58