diff --git a/perffile/format.go b/perffile/format.go index 2710b87..18f9323 100644 --- a/perffile/format.go +++ b/perffile/format.go @@ -1098,6 +1098,8 @@ type RecordSample struct { CodePageSize uint64 // if SampleFormatCodePageSize Aux []byte // if SampleFormatAux + + Raw []byte // if SampleFormatRaw } func (r *RecordSample) Type() RecordType { @@ -1177,6 +1179,9 @@ func (r *RecordSample) String() string { if f&SampleFormatWeightStruct != 0 { s += fmt.Sprintf(" Weights:%v", r.Weights) } + if f&SampleFormatRaw != 0 { + s += fmt.Sprintf(" Raw:%v", r.Raw) + } return s + "}" } @@ -1254,6 +1259,9 @@ func (r *RecordSample) Fields() []string { if f&SampleFormatWeightStruct != 0 { fs = append(fs, "Weights") } + if f&SampleFormatRaw != 0 { + fs = append(fs, "Raw") + } return fs } diff --git a/perffile/records.go b/perffile/records.go index bafba8c..7422c2a 100644 --- a/perffile/records.go +++ b/perffile/records.go @@ -534,8 +534,17 @@ func (r *Records) parseSample(bd *bufDecoder, hdr *recordHeader, common *RecordC o.Callchain = nil } - rawSize := bd.u32If(t&SampleFormatRaw != 0) - bd.skip(int(rawSize)) + if t&SampleFormatRaw != 0 { + rawSize := int(bd.u32()) + if o.Raw == nil || cap(o.Raw) < rawSize { + o.Raw = make([]byte, rawSize) + } else { + o.Raw = o.Raw[:rawSize] + } + bd.bytes(o.Raw) + } else { + o.Raw = nil + } o.BranchHWIndex = bd.i64If(o.EventAttr.BranchSampleType&BranchSampleHWIndex != 0)