Search code examples
gopprof

pprof fails to locate source files when running over http


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.


Solution

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

    Option --source_path may help.