Golang profiler cannot find source code

1,581 views
Skip to first unread message

Oliver

unread,
May 4, 2015, 9:33:41 AM5/4/15
to golan...@googlegroups.com

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? How can I see the report on the line-of-code level?

Matthew Zimmerman

unread,
May 4, 2015, 12:46:37 PM5/4/15
to Oliver, golan...@googlegroups.com
I recently made this error too after prior successful usage of the profiler and was extremely confused for a while.

You (and I) forgot to specify your binary.

e.g., go tool pprof mybinaryhere http://localhost:9000/debug/pprof/profile

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Oliver

unread,
May 4, 2015, 2:05:34 PM5/4/15
to golan...@googlegroups.com, olive...@gmail.com
This is great! Tried it and it works. Thanks a lot!

Cem Ezberci

unread,
Dec 29, 2015, 12:44:30 PM12/29/15
to golang-nuts, olive...@gmail.com
this does not seem to work when the binary is running remotely even if the local binary path is provided when the command is issued.. resulting output looks like this:

.......

(pprof) top
32.23MB of 32.23MB total (  100%)
      flat  flat%   sum%        cum   cum%
   32.23MB   100%   100%    32.23MB   100%  [mybinary]

any thoughts on how this can be done for a remote program?

Thanks,
-Cem

Cem Ezberci

unread,
Jan 12, 2016, 3:24:09 AM1/12/16
to golang-nuts, olive...@gmail.com
solved this problem and leaving this here in case anyone else runs into it.. the problem was that the remote binary was compiled for linux and local binary was compiled for mac.. once I cross compiled on mac for linux, I was able to see the source when issuing list command..
Reply all
Reply to author
Forward
0 new messages