I've included the net/http/pprof
package in my code. I can then comfortably run the pprof
profiler (on Debian):
go tool pprof http://localhost:9000/debug/pprof/profile
Commands such as top10
or even generating call graphs work as expected. However, as soon as I try to go into a function, it fails:
(pprof) list MyFunc
No source information for mypkg.MyFunc
My GOPATH
is set to my project's directory. Do I need any special flags or environment variables while building my source code or while running pprof?
Found the answer with the help of the golang-nuts people. I needed to specify the binary:
go tool pprof mybinary http://localhost:9000/debug/pprof/profile
This way the source code is found and can be listed with the "list" command.
I had the same problem with "net/http/pprof"
, albeit on windows. Using "runtime/pprof"
instead, with pprof.StartCPUProfile / StopCPUProfile
solved it.