Why does `go tool pprof` show addresses instead of function names?

huangapple go评论98阅读模式
英文:

Why does `go tool pprof` show addresses instead of function names?

问题

$ go tool pprof pgears.go profilefile.prof
addr2line: crackhdr: 未知的头类型
欢迎使用pprof!要获取帮助,请输入'help'。
(pprof) top
总共:8个样本
5 62.5% 62.5% 5 62.5% 0000000000028a8b
1 12.5% 75.0% 1 12.5% 000000000002295c
1 12.5% 87.5% 1 12.5% 000000000009375a
1 12.5% 100.0% 1 12.5% 00000000000d278a
0 0.0% 100.0% 1 12.5% 000000000000252a
0 0.0% 100.0% 1 12.5% 000000000000259d
0 0.0% 100.0% 2 25.0% 0000000000017d9e
0 0.0% 100.0% 2 25.0% 000000000001a2bf
0 0.0% 100.0% 6 75.0% 000000000001b630
0 0.0% 100.0% 1 12.5% 0000000000045401
(pprof)
为什么go tool pprof显示的是地址而不是函数名?
来源:http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html
或者:http://blog.golang.org/profiling-go-programs
我们知道应该是函数名。

或者我如何将字节信息更改为函数名?

操作系统:Mac OS 10.9.2
Go版本:go1.2 darwin/amd64

英文:
$ go tool pprof pgears.go profilefile.prof
addr2line: crackhdr: unknown header type
Welcome to pprof!  For help, type 'help'.
(pprof) top
Total: 8 samples
       5  62.5%  62.5%        5  62.5% 0000000000028a8b
       1  12.5%  75.0%        1  12.5% 000000000002295c
       1  12.5%  87.5%        1  12.5% 000000000009375a
       1  12.5% 100.0%        1  12.5% 00000000000d278a
       0   0.0% 100.0%        1  12.5% 000000000000252a
       0   0.0% 100.0%        1  12.5% 000000000000259d
       0   0.0% 100.0%        2  25.0% 0000000000017d9e
       0   0.0% 100.0%        2  25.0% 000000000001a2bf
       0   0.0% 100.0%        6  75.0% 000000000001b630
       0   0.0% 100.0%        1  12.5% 0000000000045401
(pprof)

Why go tool pprof shows addresses instead of function names?
from http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html
or http://blog.golang.org/profiling-go-programs
We know it must be function name.

Or how can I change the byte information to function name?

Operation System: Mac OS 10.9.2
Go Version: go1.2 darwin/amd64

答案1

得分: 7

pprof的第一个参数必须是一个二进制文件,而不是一个源文件。

因此,你需要编译这个二进制文件:

$ go build -o ppears

然后将其作为pprof的输入:

$ go tool pprof pgears
英文:

The first argument to pprof must be a binary, not a source file.

So you must compile the binary:

$ go build -o ppears

and use it as the input to pprof:

$ go tool pprof pgears

答案2

得分: 1

go build -o bin // 构建二进制文件

go tool pprof bin profilefile.prof

英文:
go build -o bin // build the binary file

go tool pprof bin profilefile.prof

huangapple
  • 本文由 发表于 2014年3月5日 16:31:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/22192367.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定