go: cmd/pprof: disasm not working on darwin
On my Mac, if I run go test -cpuprofile=x.prof anything, and then go tool pprof x.prof, then the disasm command in pprof does not work, for any function at all:
% go test -cpuprofile=x.prof strings
ok strings 1.059s
% go tool pprof x.prof
Type: cpu
Time: Jan 28, 2022 at 2:06pm (EST)
Duration: 805.01ms, Total samples = 540ms (67.08%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top10
Showing nodes accounting for 540ms, 100% of 540ms total
Showing top 10 nodes out of 27
flat flat% sum% cum cum%
210ms 38.89% 38.89% 210ms 38.89% cmpbody
170ms 31.48% 70.37% 170ms 31.48% memeqbody
50ms 9.26% 79.63% 50ms 9.26% unicode.to
50ms 9.26% 88.89% 50ms 9.26% unicode/utf8.EncodeRune
30ms 5.56% 94.44% 140ms 25.93% strings.Map
10ms 1.85% 96.30% 10ms 1.85% runtime.decoderune
10ms 1.85% 98.15% 10ms 1.85% runtime.madvise
10ms 1.85% 100% 390ms 72.22% strings_test.TestCompareStrings
0 0% 100% 10ms 1.85% runtime.(*mcache).allocLarge
0 0% 100% 10ms 1.85% runtime.(*mheap).alloc
(pprof) disasm cmpbody
no matches found for regexp: cmpbody
(pprof) disasm unicode.to
no matches found for regexp: unicode.to
(pprof) disasm .*
no matches found for regexp: .*
(pprof)
I have not checked whether this is Mac-specific.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 38 (31 by maintainers)
Commits related to this issue
- cmd/link: handle dynamic import variables on Darwin Currently, on darwin, we only support cgo_dynamic_import for functions, but not variables, as we don't need it before. mach_task_self_ is a variabl... — committed to golang/go by cherrymui a year ago
- runtime/pprof: correct field alignment in machVMRegionBasicInfoData The type machVMRegionBasicInfoData is generated from C type vm_region_basic_info_data_64_t, which is a packed struct with a 64-bit ... — committed to golang/go by cherrymui a year ago
- doc: add release notes for runtime/pprof changes For #50891. For #61015. For #61422. Change-Id: I30d580814ac02fe9f3fbd1a101b2cc05947a9aaa Reviewed-on: https://go-review.googlesource.com/c/go/+/5464... — committed to golang/go by mknyszek 7 months ago
I stub my toe on this UX about every other time I use pprof.
Getting the same problem on Windows:
go env
Outputgo test -cpuprofile=x.prof strings
will leave astrings.test
binary in the working directory. If pprof is invoked asgo tool pprof x.prof
,disasm
fails because it’s looking for the binary in /tmp/, and it’s not there:but if the binary (which is in wd) is explicitly passed as
go tool pprof strings.test x.prof
, thendisasm
works correctly.FWIW, I see the same behaviour with go1.17.5 (above tests are from tip).
(This is on Linux).
Take a look at https://go-review.googlesource.com/c/go/+/503919 when you have a moment, it includes your changes too.
FYI, I have the arm version of vm_region_info working. What are your plans for merging the linker changes and how should I construct the PRs for my changes - i.e. would you like to see one PR with the mach_vm_region assembly code and a second one with the pprof mapping changes, or would you prefer one? I would assume one, but lmk.
Yep - it does indeed work for arm64! Thanks! I’ll try the intel version when I get back home in a week or so and have access to an intel mbp.