libgo: delay applying profile stack-frame skip until fixup

When the runtime collects a stack trace to associate it with some
profiling event (mem alloc, mutex, etc) there is a skip count passed
to runtime.Callers (or equivalent) to skip some known count of frames
in order to get to the "interesting" frame corresponding to the
profile event. Now that the profiling mechanism uses lazy fixup (when
removing compiler artifacts like thunks, morestack calls etc), we also
need to move the frame skipping logic after the fixup, so as to insure
that the skip count isn't thrown off by these artifacts.

Fixes golang/go#32290.

Change-Id: I109b3e8b30d4e2955da4af4235f8965717fba7cb
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179740
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 files changed