From db32fed8a15b542f3f4db9014b9dc6b03b93a979 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 28 Sep 2016 17:37:42 +0200 Subject: report: always extract the first oops as description If there are several oops messages, we need to extract and use the first one. --- report/report.go | 17 +++++++++++++---- report/report_test.go | 10 ++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'report') diff --git a/report/report.go b/report/report.go index 211e49281..72a5d037d 100644 --- a/report/report.go +++ b/report/report.go @@ -248,16 +248,25 @@ func Parse(output []byte) (desc string, text []byte, start int, end int) { } func extractDescription(output []byte, oops *oops) string { + result := "" + startPos := -1 for _, format := range oops.formats { - match := format.re.FindSubmatch(output) + match := format.re.FindSubmatchIndex(output) if match == nil { continue } + if startPos != -1 && startPos <= match[0] { + continue + } + startPos = match[0] var args []interface{} - for i := 1; i < len(match); i++ { - args = append(args, string(match[i])) + for i := 2; i < len(match); i += 2 { + args = append(args, string(output[match[i]:match[i+1]])) } - return fmt.Sprintf(format.fmt, args...) + result = fmt.Sprintf(format.fmt, args...) + } + if result != "" { + return result } pos := bytes.Index(output, oops.header) if pos == -1 { diff --git a/report/report_test.go b/report/report_test.go index 4c9ae2729..ac77b4c39 100644 --- a/report/report_test.go +++ b/report/report_test.go @@ -332,6 +332,16 @@ BUG: spinlock lockup suspected on CPU#2, syz-executor/12636 ` BUG: soft lockup - CPU#3 stuck for 11s! [syz-executor:643] +`: `BUG: soft lockup`, + + ` +BUG: spinlock lockup suspected on CPU#2, syz-executor/12636 +BUG: soft lockup - CPU#3 stuck for 11s! [syz-executor:643] +`: `BUG: spinlock lockup suspected`, + + ` +BUG: soft lockup - CPU#3 stuck for 11s! [syz-executor:643] +BUG: spinlock lockup suspected on CPU#2, syz-executor/12636 `: `BUG: soft lockup`, ` -- cgit mrf-deployment