mirror of
https://github.com/golang/go
synced 2024-11-18 05:54:49 -07:00
runtime/pprof: set Function.start_line field
Now that we plumb the start line to the runtime, we can include in pprof files. Since runtime.Frame.startLine is not (currently) exported, we need a runtime helper to get the value. For #55022. Updates #56135. Change-Id: Ifc5b68a7b7170fd7895e4099deb24df7977b22ea Reviewed-on: https://go-review.googlesource.com/c/go/+/438255 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
f2656f20ea
commit
a401468b00
@ -590,6 +590,7 @@ func (b *profileBuilder) emitLocation() uint64 {
|
|||||||
type newFunc struct {
|
type newFunc struct {
|
||||||
id uint64
|
id uint64
|
||||||
name, file string
|
name, file string
|
||||||
|
startLine int64
|
||||||
}
|
}
|
||||||
newFuncs := make([]newFunc, 0, 8)
|
newFuncs := make([]newFunc, 0, 8)
|
||||||
|
|
||||||
@ -610,7 +611,12 @@ func (b *profileBuilder) emitLocation() uint64 {
|
|||||||
if funcID == 0 {
|
if funcID == 0 {
|
||||||
funcID = uint64(len(b.funcs)) + 1
|
funcID = uint64(len(b.funcs)) + 1
|
||||||
b.funcs[frame.Function] = int(funcID)
|
b.funcs[frame.Function] = int(funcID)
|
||||||
newFuncs = append(newFuncs, newFunc{funcID, frame.Function, frame.File})
|
newFuncs = append(newFuncs, newFunc{
|
||||||
|
id: funcID,
|
||||||
|
name: frame.Function,
|
||||||
|
file: frame.File,
|
||||||
|
startLine: int64(runtime_FrameStartLine(&frame)),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
b.pbLine(tagLocation_Line, funcID, int64(frame.Line))
|
b.pbLine(tagLocation_Line, funcID, int64(frame.Line))
|
||||||
}
|
}
|
||||||
@ -633,6 +639,7 @@ func (b *profileBuilder) emitLocation() uint64 {
|
|||||||
b.pb.int64Opt(tagFunction_Name, b.stringIndex(fn.name))
|
b.pb.int64Opt(tagFunction_Name, b.stringIndex(fn.name))
|
||||||
b.pb.int64Opt(tagFunction_SystemName, b.stringIndex(fn.name))
|
b.pb.int64Opt(tagFunction_SystemName, b.stringIndex(fn.name))
|
||||||
b.pb.int64Opt(tagFunction_Filename, b.stringIndex(fn.file))
|
b.pb.int64Opt(tagFunction_Filename, b.stringIndex(fn.file))
|
||||||
|
b.pb.int64Opt(tagFunction_StartLine, fn.startLine)
|
||||||
b.pb.endMessage(tagProfile_Function, start)
|
b.pb.endMessage(tagProfile_Function, start)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,13 @@ package pprof
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// runtime_FrameStartLine is defined in runtime/symtab.go.
|
||||||
|
func runtime_FrameStartLine(f *runtime.Frame) int
|
||||||
|
|
||||||
// runtime_expandFinalInlineFrame is defined in runtime/symtab.go.
|
// runtime_expandFinalInlineFrame is defined in runtime/symtab.go.
|
||||||
func runtime_expandFinalInlineFrame(stk []uintptr) []uintptr
|
func runtime_expandFinalInlineFrame(stk []uintptr) []uintptr
|
||||||
|
|
||||||
|
@ -170,6 +170,13 @@ func (ci *Frames) Next() (frame Frame, more bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runtime_FrameStartLine returns the start line of the function in a Frame.
|
||||||
|
//
|
||||||
|
//go:linkname runtime_FrameStartLine runtime/pprof.runtime_FrameStartLine
|
||||||
|
func runtime_FrameStartLine(f *Frame) int {
|
||||||
|
return f.startLine
|
||||||
|
}
|
||||||
|
|
||||||
// runtime_expandFinalInlineFrame expands the final pc in stk to include all
|
// runtime_expandFinalInlineFrame expands the final pc in stk to include all
|
||||||
// "callers" if pc is inline.
|
// "callers" if pc is inline.
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user