diff --git a/cmd/memlat/database.go b/cmd/memlat/database.go index fad1bb9..617d92d 100644 --- a/cmd/memlat/database.go +++ b/cmd/memlat/database.go @@ -175,6 +175,11 @@ func parsePerf(fileName string) *database { } } + if err := rs.Err(); err != nil { + fmt.Printf("error while reading record: %s\n", err) + os.Exit(1) + } + if numSamples == 0 { fmt.Printf("no memory latency samples in %s (did you use \"perf mem record\"?)\n", fileName) os.Exit(1) diff --git a/perffile/records.go b/perffile/records.go index 6ce00b5..af8c0af 100644 --- a/perffile/records.go +++ b/perffile/records.go @@ -105,11 +105,18 @@ func (r *Records) Next() bool { // Parse common sample_id fields if r.f.sampleIDAll && hdr.Type != RecordTypeSample && hdr.Type < recordTypeUserStart { - // mmap records in the prologue don't have eventAttrs + // some records in the prologue don't have eventAttrs // in recent perf versions, but that's okay. // // TODO: When is perf okay with missing eventAttrs? - r.parseCommon(bd, &common, hdr.Type == RecordTypeMmap) + missingOk := (hdr.Type == RecordTypeMmap) || + (hdr.Type == RecordTypeFork) || + (hdr.Type == RecordTypeComm) || + (hdr.Type == recordTypeMmap2) + r.parseCommon(bd, &common, missingOk) + if r.err != nil { + return false + } } // Parse record