package profile
import (
)
func ( *Profile) () []decoder {
return profileDecoder
}
func ( *Profile) () {
:= make(map[string]int)
addString(, "")
for , := range .SampleType {
.typeX = addString(, .Type)
.unitX = addString(, .Unit)
}
for , := range .Sample {
.labelX = nil
var []string
for := range .Label {
= append(, )
}
sort.Strings()
for , := range {
:= .Label[]
for , := range {
.labelX = append(.labelX,
Label{
keyX: addString(, ),
strX: addString(, ),
},
)
}
}
var []string
for := range .NumLabel {
= append(, )
}
sort.Strings()
for , := range {
:= .NumLabel[]
for , := range {
.labelX = append(.labelX,
Label{
keyX: addString(, ),
numX: ,
},
)
}
}
.locationIDX = nil
for , := range .Location {
.locationIDX = append(.locationIDX, .ID)
}
}
for , := range .Mapping {
.fileX = addString(, .File)
.buildIDX = addString(, .BuildID)
}
for , := range .Location {
for , := range .Line {
if .Function != nil {
.Line[].functionIDX = .Function.ID
} else {
.Line[].functionIDX = 0
}
}
if .Mapping != nil {
.mappingIDX = .Mapping.ID
} else {
.mappingIDX = 0
}
}
for , := range .Function {
.nameX = addString(, .Name)
.systemNameX = addString(, .SystemName)
.filenameX = addString(, .Filename)
}
.dropFramesX = addString(, .DropFrames)
.keepFramesX = addString(, .KeepFrames)
if := .PeriodType; != nil {
.typeX = addString(, .Type)
.unitX = addString(, .Unit)
}
.stringTable = make([]string, len())
for , := range {
.stringTable[] =
}
}
func ( *Profile) ( *buffer) {
for , := range .SampleType {
encodeMessage(, 1, )
}
for , := range .Sample {
encodeMessage(, 2, )
}
for , := range .Mapping {
encodeMessage(, 3, )
}
for , := range .Location {
encodeMessage(, 4, )
}
for , := range .Function {
encodeMessage(, 5, )
}
encodeStrings(, 6, .stringTable)
encodeInt64Opt(, 7, .dropFramesX)
encodeInt64Opt(, 8, .keepFramesX)
encodeInt64Opt(, 9, .TimeNanos)
encodeInt64Opt(, 10, .DurationNanos)
if := .PeriodType; != nil && (.typeX != 0 || .unitX != 0) {
encodeMessage(, 11, .PeriodType)
}
encodeInt64Opt(, 12, .Period)
}
var profileDecoder = []decoder{
nil,
func( *buffer, message) error {
:= new(ValueType)
:= .(*Profile)
.SampleType = append(.SampleType, )
return decodeMessage(, )
},
func( *buffer, message) error {
:= new(Sample)
:= .(*Profile)
.Sample = append(.Sample, )
return decodeMessage(, )
},
func( *buffer, message) error {
:= new(Mapping)
:= .(*Profile)
.Mapping = append(.Mapping, )
return decodeMessage(, )
},
func( *buffer, message) error {
:= new(Location)
:= .(*Profile)
.Location = append(.Location, )
return decodeMessage(, )
},
func( *buffer, message) error {
:= new(Function)
:= .(*Profile)
.Function = append(.Function, )
return decodeMessage(, )
},
func( *buffer, message) error {
:= decodeStrings(, &.(*Profile).stringTable)
if != nil {
return
}
if *&.(*Profile).stringTable[0] != "" {
return errors.New("string_table[0] must be ''")
}
return nil
},
func( *buffer, message) error { return decodeInt64(, &.(*Profile).dropFramesX) },
func( *buffer, message) error { return decodeInt64(, &.(*Profile).keepFramesX) },
func( *buffer, message) error { return decodeInt64(, &.(*Profile).TimeNanos) },
func( *buffer, message) error { return decodeInt64(, &.(*Profile).DurationNanos) },
func( *buffer, message) error {
:= new(ValueType)
:= .(*Profile)
.PeriodType =
return decodeMessage(, )
},
func( *buffer, message) error { return decodeInt64(, &.(*Profile).Period) },
func( *buffer, message) error { return decodeInt64s(, &.(*Profile).commentX) },
func( *buffer, message) error { return decodeInt64(, &.(*Profile).defaultSampleTypeX) },
}
func ( *Profile) () error {
var error
:= make(map[uint64]*Mapping)
for , := range .Mapping {
.File, = getString(.stringTable, &.fileX, )
.BuildID, = getString(.stringTable, &.buildIDX, )
[.ID] =
}
:= make(map[uint64]*Function)
for , := range .Function {
.Name, = getString(.stringTable, &.nameX, )
.SystemName, = getString(.stringTable, &.systemNameX, )
.Filename, = getString(.stringTable, &.filenameX, )
[.ID] =
}
:= make(map[uint64]*Location)
for , := range .Location {
.Mapping = [.mappingIDX]
.mappingIDX = 0
for , := range .Line {
if := .functionIDX; != 0 {
.Line[].Function = []
if .Line[].Function == nil {
return fmt.Errorf("Function ID %d not found", )
}
.Line[].functionIDX = 0
}
}
[.ID] =
}
for , := range .SampleType {
.Type, = getString(.stringTable, &.typeX, )
.Unit, = getString(.stringTable, &.unitX, )
}
for , := range .Sample {
:= make(map[string][]string)
:= make(map[string][]int64)
for , := range .labelX {
var , string
, = getString(.stringTable, &.keyX, )
if .strX != 0 {
, = getString(.stringTable, &.strX, )
[] = append([], )
} else {
[] = append([], .numX)
}
}
if len() > 0 {
.Label =
}
if len() > 0 {
.NumLabel =
}
.Location = nil
for , := range .locationIDX {
.Location = append(.Location, [])
}
.locationIDX = nil
}
.DropFrames, = getString(.stringTable, &.dropFramesX, )
.KeepFrames, = getString(.stringTable, &.keepFramesX, )
if := .PeriodType; == nil {
.PeriodType = &ValueType{}
}
if := .PeriodType; != nil {
.Type, = getString(.stringTable, &.typeX, )
.Unit, = getString(.stringTable, &.unitX, )
}
for , := range .commentX {
var string
, = getString(.stringTable, &, )
.Comments = append(.Comments, )
}
.commentX = nil
.DefaultSampleType, = getString(.stringTable, &.defaultSampleTypeX, )
.stringTable = nil
return nil
}
func ( *ValueType) () []decoder {
return valueTypeDecoder
}
func ( *ValueType) ( *buffer) {
encodeInt64Opt(, 1, .typeX)
encodeInt64Opt(, 2, .unitX)
}
var valueTypeDecoder = []decoder{
nil,
func( *buffer, message) error { return decodeInt64(, &.(*ValueType).typeX) },
func( *buffer, message) error { return decodeInt64(, &.(*ValueType).unitX) },
}
func ( *Sample) () []decoder {
return sampleDecoder
}
func ( *Sample) ( *buffer) {
encodeUint64s(, 1, .locationIDX)
for , := range .Value {
encodeInt64(, 2, )
}
for , := range .labelX {
encodeMessage(, 3, )
}
}
var sampleDecoder = []decoder{
nil,
func( *buffer, message) error { return decodeUint64s(, &.(*Sample).locationIDX) },
func( *buffer, message) error { return decodeInt64s(, &.(*Sample).Value) },
func( *buffer, message) error {
:= .(*Sample)
:= len(.labelX)
.labelX = append(.labelX, Label{})
return decodeMessage(, &.labelX[])
},
}
func ( Label) () []decoder {
return labelDecoder
}
func ( Label) ( *buffer) {
encodeInt64Opt(, 1, .keyX)
encodeInt64Opt(, 2, .strX)
encodeInt64Opt(, 3, .numX)
}
var labelDecoder = []decoder{
nil,
func( *buffer, message) error { return decodeInt64(, &.(*Label).keyX) },
func( *buffer, message) error { return decodeInt64(, &.(*Label).strX) },
func( *buffer, message) error { return decodeInt64(, &.(*Label).numX) },
}
func ( *Mapping) () []decoder {
return mappingDecoder
}
func ( *Mapping) ( *buffer) {
encodeUint64Opt(, 1, .ID)
encodeUint64Opt(, 2, .Start)
encodeUint64Opt(, 3, .Limit)
encodeUint64Opt(, 4, .Offset)
encodeInt64Opt(, 5, .fileX)
encodeInt64Opt(, 6, .buildIDX)
encodeBoolOpt(, 7, .HasFunctions)
encodeBoolOpt(, 8, .HasFilenames)
encodeBoolOpt(, 9, .HasLineNumbers)
encodeBoolOpt(, 10, .HasInlineFrames)
}
var mappingDecoder = []decoder{
nil,
func( *buffer, message) error { return decodeUint64(, &.(*Mapping).ID) },
func( *buffer, message) error { return decodeUint64(, &.(*Mapping).Start) },
func( *buffer, message) error { return decodeUint64(, &.(*Mapping).Limit) },
func( *buffer, message) error { return decodeUint64(, &.(*Mapping).Offset) },
func( *buffer, message) error { return decodeInt64(, &.(*Mapping).fileX) },
func( *buffer, message) error { return decodeInt64(, &.(*Mapping).buildIDX) },
func( *buffer, message) error { return decodeBool(, &.(*Mapping).HasFunctions) },
func( *buffer, message) error { return decodeBool(, &.(*Mapping).HasFilenames) },
func( *buffer, message) error { return decodeBool(, &.(*Mapping).HasLineNumbers) },
func( *buffer, message) error { return decodeBool(, &.(*Mapping).HasInlineFrames) },
}
func ( *Location) () []decoder {
return locationDecoder
}
func ( *Location) ( *buffer) {
encodeUint64Opt(, 1, .ID)
encodeUint64Opt(, 2, .mappingIDX)
encodeUint64Opt(, 3, .Address)
for := range .Line {
encodeMessage(, 4, &.Line[])
}
}
var locationDecoder = []decoder{
nil,
func( *buffer, message) error { return decodeUint64(, &.(*Location).ID) },
func( *buffer, message) error { return decodeUint64(, &.(*Location).mappingIDX) },
func( *buffer, message) error { return decodeUint64(, &.(*Location).Address) },
func( *buffer, message) error {
:= .(*Location)
:= len(.Line)
.Line = append(.Line, Line{})
return decodeMessage(, &.Line[])
},
}
func ( *Line) () []decoder {
return lineDecoder
}
func ( *Line) ( *buffer) {
encodeUint64Opt(, 1, .functionIDX)
encodeInt64Opt(, 2, .Line)
}
var lineDecoder = []decoder{
nil,
func( *buffer, message) error { return decodeUint64(, &.(*Line).functionIDX) },
func( *buffer, message) error { return decodeInt64(, &.(*Line).Line) },
}
func ( *Function) () []decoder {
return functionDecoder
}
func ( *Function) ( *buffer) {
encodeUint64Opt(, 1, .ID)
encodeInt64Opt(, 2, .nameX)
encodeInt64Opt(, 3, .systemNameX)
encodeInt64Opt(, 4, .filenameX)
encodeInt64Opt(, 5, .StartLine)
}
var functionDecoder = []decoder{
nil,
func( *buffer, message) error { return decodeUint64(, &.(*Function).ID) },
func( *buffer, message) error { return decodeInt64(, &.(*Function).nameX) },
func( *buffer, message) error { return decodeInt64(, &.(*Function).systemNameX) },
func( *buffer, message) error { return decodeInt64(, &.(*Function).filenameX) },
func( *buffer, message) error { return decodeInt64(, &.(*Function).StartLine) },
}
func ( map[string]int, string) int64 {
, := []
if ! {
= len()
[] =
}
return int64()
}
func ( []string, *int64, error) (string, error) {
if != nil {
return "",
}
:= int(*)
if < 0 || >= len() {
return "", errMalformed
}
* = 0
return [], nil
}