From b7c826d2c4576dbe04a79ab7d0dfa03c722c0ab9 Mon Sep 17 00:00:00 2001 From: Cosmos Nicolaou Date: Wed, 14 Jun 2023 14:33:43 -0700 Subject: runtime,runtime/pprof: get memory mappings on darwin. Displaying assembly language has never worked for Apple Silicon macs (see #50891). This change uses mach_vm_region to obtain the necessary VM mappings to allow for locating assembly instructions for a cpu profile. Fixes #50891 Change-Id: Ib968c55a19b481b82f63337276b552f3b18f69d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/503919 Run-TryBot: Cherry Mui Reviewed-by: Cherry Mui TryBot-Result: Gopher Robot Reviewed-by: David Chase --- src/cmd/internal/objfile/macho.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmd/internal/objfile') diff --git a/src/cmd/internal/objfile/macho.go b/src/cmd/internal/objfile/macho.go index 1d6963f7c4..c92497527a 100644 --- a/src/cmd/internal/objfile/macho.go +++ b/src/cmd/internal/objfile/macho.go @@ -128,6 +128,9 @@ func (x uint64s) Swap(i, j int) { x[i], x[j] = x[j], x[i] } func (x uint64s) Less(i, j int) bool { return x[i] < x[j] } func (f *machoFile) loadAddress() (uint64, error) { + if seg := f.macho.Segment("__TEXT"); seg != nil { + return seg.Addr, nil + } return 0, fmt.Errorf("unknown load address") } -- cgit v1.3-6-g1900