Source File
proto.go
Belonging Package
runtime/pprof
package pprof
import (
)
func () { () }
type symbolizeFlag uint8
const (
lookupTried symbolizeFlag = 1 << iota
lookupFailed symbolizeFlag = 1 << iota
)
tagProfile_SampleType = 1 // repeated ValueType
tagProfile_Sample = 2 // repeated Sample
tagProfile_Mapping = 3 // repeated Mapping
tagProfile_Location = 4 // repeated Location
tagProfile_Function = 5 // repeated Function
tagProfile_StringTable = 6 // repeated string
tagProfile_DropFrames = 7 // int64 (string table index)
tagProfile_KeepFrames = 8 // int64 (string table index)
tagProfile_TimeNanos = 9 // int64
tagProfile_DurationNanos = 10 // int64
tagProfile_PeriodType = 11 // ValueType (really optional string???)
tagProfile_Period = 12 // int64
tagProfile_Comment = 13 // repeated int64
tagProfile_DefaultSampleType = 14 // int64
tagValueType_Type = 1 // int64 (string table index)
tagValueType_Unit = 2 // int64 (string table index)
tagSample_Location = 1 // repeated uint64
tagSample_Value = 2 // repeated int64
tagSample_Label = 3 // repeated Label
tagLabel_Key = 1 // int64 (string table index)
tagLabel_Str = 2 // int64 (string table index)
tagLabel_Num = 3 // int64
tagMapping_ID = 1 // uint64
tagMapping_Start = 2 // uint64
tagMapping_Limit = 3 // uint64
tagMapping_Offset = 4 // uint64
tagMapping_Filename = 5 // int64 (string table index)
tagMapping_BuildID = 6 // int64 (string table index)
tagMapping_HasFunctions = 7 // bool
tagMapping_HasFilenames = 8 // bool
tagMapping_HasLineNumbers = 9 // bool
tagMapping_HasInlineFrames = 10 // bool
tagLocation_ID = 1 // uint64
tagLocation_MappingID = 2 // uint64
tagLocation_Address = 3 // uint64
tagLocation_Line = 4 // repeated Line
tagLine_FunctionID = 1 // uint64
tagLine_Line = 2 // int64
tagFunction_ID = 1 // uint64
tagFunction_Name = 2 // int64 (string table index)
tagFunction_SystemName = 3 // int64 (string table index)
tagFunction_Filename = 4 // int64 (string table index)
tagFunction_StartLine = 5 // int64
)
func ( *profileBuilder) ( int, , string) {
:= .pb.startMessage()
.pb.int64(tagValueType_Type, .stringIndex())
.pb.int64(tagValueType_Unit, .stringIndex())
.pb.endMessage(, )
}
func ( *profileBuilder) ( []int64, []uint64, func()) {
:= .pb.startMessage()
.pb.int64s(tagSample_Value, )
.pb.uint64s(tagSample_Location, )
if != nil {
()
}
.pb.endMessage(tagProfile_Sample, )
.flush()
}
func ( *profileBuilder) ( int, , string, int64) {
:= .pb.startMessage()
.pb.int64Opt(tagLabel_Key, .stringIndex())
.pb.int64Opt(tagLabel_Str, .stringIndex())
.pb.int64Opt(tagLabel_Num, )
.pb.endMessage(, )
}
func ( *profileBuilder) ( int, uint64, int64) {
:= .pb.startMessage()
.pb.uint64Opt(tagLine_FunctionID, )
.pb.int64Opt(tagLine_Line, )
.pb.endMessage(, )
}
func ( *profileBuilder) ( int, , , , uint64, , string, bool) {
:= .pb.startMessage()
.pb.uint64Opt(tagMapping_ID, )
.pb.uint64Opt(tagMapping_Start, )
.pb.uint64Opt(tagMapping_Limit, )
.pb.uint64Opt(tagMapping_Offset, )
.pb.int64Opt(tagMapping_Filename, .stringIndex())
if {
.pb.bool(tagMapping_HasFunctions, true)
}
.pb.endMessage(, )
}
:= runtime.CallersFrames([]uintptr{})
, := .Next()
return nil, 0
}
:= lookupTried
if .PC == 0 || .Function == "" || .File == "" || .Line == 0 {
|= lookupFailed
}
func ( *profileBuilder) ( []uint64, []unsafe.Pointer) error {
.period = 1e9 / int64([2])
.havePeriod = true
= [3:]
}
= uint64([0])
func ( *profileBuilder) () {
.end = time.Now()
.pb.int64Opt(tagProfile_TimeNanos, .start.UnixNano())
if .havePeriod { // must be CPU profile
.pbValueType(tagProfile_SampleType, "samples", "count")
.pbValueType(tagProfile_SampleType, "cpu", "nanoseconds")
.pb.int64Opt(tagProfile_DurationNanos, .end.Sub(.start).Nanoseconds())
.pbValueType(tagProfile_PeriodType, "cpu", "nanoseconds")
.pb.int64Opt(tagProfile_Period, .period)
}
:= []int64{0, 0}
var []uint64
for := .m.all; != nil; = .nextAll {
[0] = .count
[1] = .count * .period
var func()
if .tag != nil {
= func() {
for , := range *(*labelMap)(.tag) {
.pbLabel(tagSample_Label, , , 0)
}
}
}
= .appendLocsForStack([:0], .stk)
.pbSample(, , )
}
for , := range .mem {
:= .funcs == lookupTried // lookupTried but not lookupFailed
.pbMapping(tagProfile_Mapping, uint64(+1), uint64(.start), uint64(.end), .offset, .file, .buildID, )
}
= runtime_expandFinalInlineFrame()
for len() > 0 {
:= [0]
if := .emitLocation(); > 0 {
= append(, )
}
if := .emitLocation(); > 0 {
= append(, )
}
type pcDeck struct {
pcs []uintptr
frames []runtime.Frame
symbolizeResult symbolizeFlag
}
func ( *pcDeck) () {
.pcs = .pcs[:0]
.frames = .frames[:0]
.symbolizeResult = 0
}
:= [0]
:= .frames[-1]
if .Func != nil { // the last frame can't be inlined. Flush.
return false
}
if .Entry == 0 || .Entry == 0 { // Possibly not a Go function. Don't try to merge.
return false
}
if .Entry != .Entry { // newFrame is for a different function.
return false
}
if .Function == .Function { // maybe recursion.
return false
}
}
.pcs = append(.pcs, )
.frames = append(.frames, ...)
.symbolizeResult |=
return true
}
:= uint64(.funcs[.Function])
if == 0 {
= uint64(len(.funcs)) + 1
.funcs[.Function] = int()
= append(, {, .Function, .File})
}
.pbLine(tagLocation_Line, , int64(.Line))
}
for := range .mem {
if .mem[].start <= && < .mem[].end || .mem[].fake {
.pb.uint64Opt(tagLocation_MappingID, uint64(+1))
:= .mem[]
.funcs |= .deck.symbolizeResult
.mem[] =
break
}
}
.pb.endMessage(tagProfile_Location, )
for , := range {
:= .pb.startMessage()
.pb.uint64Opt(tagFunction_ID, .)
.pb.int64Opt(tagFunction_Name, .stringIndex(.))
.pb.int64Opt(tagFunction_SystemName, .stringIndex(.))
.pb.int64Opt(tagFunction_Filename, .stringIndex(.))
.pb.endMessage(tagProfile_Function, )
}
.flush()
return
}
func ( *profileBuilder) () {
, := os.ReadFile("/proc/self/maps")
parseProcSelfMaps(, .addMapping)
if len(.mem) == 0 { // pprof expects a map entry, so fake one.
}
}
:= func() []byte {
:= bytes.IndexByte(, ' ')
if < 0 {
:=
= nil
return
}
:= [:]
= [+1:]
for len() > 0 && [0] == ' ' {
= [1:]
}
return
}
for len() > 0 {
:= bytes.IndexByte(, '\n')
if < 0 {
, = , nil
} else {
, = [:], [+1:]
}
:= ()
= bytes.IndexByte(, '-')
if < 0 {
continue
}
, := strconv.ParseUint(string([:]), 16, 64)
if != nil {
continue
}
, := strconv.ParseUint(string([+1:]), 16, 64)
if != nil {
continue
}
:= ()
continue
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |