Golang 分析器找不到源代码
Golang profiler cannot find source code
我在我的代码中包含了 net/http/pprof
包。然后我可以舒适地 运行 pprof
分析器(在 Debian 上):
go tool pprof http://localhost:9000/debug/pprof/profile
top10
等命令甚至生成调用图都按预期工作。但是,一旦我尝试进入一个函数,它就会失败:
(pprof) list MyFunc
No source information for mypkg.MyFunc
我的 GOPATH
设置为我的项目目录。在构建源代码或 运行ning pprof 时,我是否需要任何特殊标志或环境变量?
我在 "net/http/pprof"
上遇到了同样的问题,尽管是在 windows 上。
使用 "runtime/pprof"
代替,pprof.StartCPUProfile / StopCPUProfile
解决了它。
在golang-nuts人的帮助下找到了答案。我需要指定二进制文件:
go tool pprof mybinary http://localhost:9000/debug/pprof/profile
通过这种方式可以找到源代码并可以使用 "list" 命令列出。
我在我的代码中包含了 net/http/pprof
包。然后我可以舒适地 运行 pprof
分析器(在 Debian 上):
go tool pprof http://localhost:9000/debug/pprof/profile
top10
等命令甚至生成调用图都按预期工作。但是,一旦我尝试进入一个函数,它就会失败:
(pprof) list MyFunc
No source information for mypkg.MyFunc
我的 GOPATH
设置为我的项目目录。在构建源代码或 运行ning pprof 时,我是否需要任何特殊标志或环境变量?
我在 "net/http/pprof"
上遇到了同样的问题,尽管是在 windows 上。
使用 "runtime/pprof"
代替,pprof.StartCPUProfile / StopCPUProfile
解决了它。
在golang-nuts人的帮助下找到了答案。我需要指定二进制文件:
go tool pprof mybinary http://localhost:9000/debug/pprof/profile
通过这种方式可以找到源代码并可以使用 "list" 命令列出。