go tool pprof
不支持位置无关代码(PIE二进制文件或共享库)的反汇编。值得注意的是,在Windows上,PIE是默认的,因此默认情况下反汇编不起作用:
gopher@SERVER-2016-V7- c:\workdir>go\bin\go build cpu.go
gopher@SERVER-2016-V7- c:\workdir>cpu.exe -output cpu.pprof
gopher@SERVER-2016-V7- c:\workdir>pprof.exe -top cpu.exe cpu.pprof
File: cpu.exe
Type: cpu
Time: Jun 7, 2021 at 9:19pm (GMT)
Duration: 1.11s, Total samples = 990ms (89.48%)
Showing nodes accounting for 990ms, 100% of 990ms total
flat flat% sum% cum cum%
330ms 33.33% 33.33% 840ms 84.85% time.Since
280ms 28.28% 61.62% 280ms 28.28% time.Time.Sub
150ms 15.15% 76.77% 990ms 100% main.main
130ms 13.13% 89.90% 130ms 13.13% runtime.nanotime1
100ms 10.10% 100% 230ms 23.23% runtime.nanotime
0 0% 100% 990ms 100% runtime.main
gopher@SERVER-2016-V7- c:\workdir>pprof.exe -disasm . cpu.exe cpu.pprof
Total: 990ms
没有PIE的情况下:
gopher@SERVER-2016-V7- c:\workdir>go\bin\go build -buildmode=exe cpu.go
gopher@SERVER-2016-V7- c:\workdir>cpu.exe -output cpu.pprof
gopher@SERVER-2016-V7- c:\workdir>pprof.exe -disasm . cpu.exe cpu.pprof
Total: 990ms
ROUTINE ======================== time.Time.Sub
310ms 310ms (flat, cum) 31.31% of Total
...
上游pprof的binutils后端支持基地址计算以处理位置无关代码,但我们的实现完全跳过了这一点。
"binutils"实现似乎并不特别针对binutils,所以在我们的实际实现中支持它可能不会太困难。
cc @cherrymui@mknyszek
3条答案
按热度按时间1sbrub3j1#
See also #17883 .
23c0lvtd2#
https://go.dev/cl/416976提到了这个问题:
cmd/pprof: fix addr calculation for Windows
liwlm1x93#
https://go.dev/cl/227483提到了这个问题:
cmd/internal/objfile: read file/line information for ELF PIE binaries