For generic functions, the previous CL makes it record the full
instantiated symbol name in the runtime func table. This CL
changes the pprof package to use that name in CPU profile. This
way, it matches the symbol name the compiler sees, so it can apply
PGO.
TODO: add a test.
Fixes #58712.
Change-Id: If40db01cbef5f73c279adcc9c290a757ef6955b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/491678
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
b.funcs[frame.Function] = int(funcID)
newFuncs = append(newFuncs, newFunc{
id: funcID,
- name: frame.Function,
+ name: runtime_FrameSymbolName(&frame),
file: frame.File,
startLine: int64(runtime_FrameStartLine(&frame)),
})
)
// runtime_FrameStartLine is defined in runtime/symtab.go.
+//
+//go:noescape
func runtime_FrameStartLine(f *runtime.Frame) int
+// runtime_FrameSymbolName is defined in runtime/symtab.go.
+//
+//go:noescape
+func runtime_FrameSymbolName(f *runtime.Frame) string
+
// runtime_expandFinalInlineFrame is defined in runtime/symtab.go.
func runtime_expandFinalInlineFrame(stk []uintptr) []uintptr
return f.startLine
}
+// runtime_FrameSymbolName returns the full symbol name of the function in a Frame.
+// For generic functions this differs from f.Function in that this doesn't replace
+// the shape name to "...".
+//
+//go:linkname runtime_FrameSymbolName runtime/pprof.runtime_FrameSymbolName
+func runtime_FrameSymbolName(f *Frame) string {
+ if !f.funcInfo.valid() {
+ return f.Function
+ }
+ u, uf := newInlineUnwinder(f.funcInfo, f.PC, nil)
+ sf := u.srcFunc(uf)
+ return sf.name()
+}
+
// runtime_expandFinalInlineFrame expands the final pc in stk to include all
// "callers" if pc is inline.
//