diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-11-14 09:41:55 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-11-14 09:41:55 +0100 |
| commit | 7a53e7e35da7468b5a6291fa3b5e1db4bcdf402f (patch) | |
| tree | 62d7db4c53b8ab4da2fab89c25f528904d8bf517 /pkg/report/linux.go | |
| parent | f9a8d567eb3388d0909e0d3cb6df23d345911850 (diff) | |
pkg/report: combine report data into a struct
Parse returns 5 variables now. Later we may want to add crash "priority".
Introduce Report struct that holds all report data.
Diffstat (limited to 'pkg/report/linux.go')
| -rw-r--r-- | pkg/report/linux.go | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/pkg/report/linux.go b/pkg/report/linux.go index 9d8a90eea..8e4ed57b5 100644 --- a/pkg/report/linux.go +++ b/pkg/report/linux.go @@ -75,7 +75,8 @@ func (ctx *linux) ContainsCrash(output []byte) bool { return containsCrash(output, linuxOopses, ctx.ignores) } -func (ctx *linux) Parse(output []byte) (desc string, text []byte, start int, end int, corrupted bool) { +func (ctx *linux) Parse(output []byte) *Report { + rep := new(Report) var oops *oops var textPrefix [][]byte textLines := 0 @@ -94,10 +95,10 @@ func (ctx *linux) Parse(output []byte) (desc string, text []byte, start int, end } if oops == nil { oops = oops1 - start = pos - desc = string(output[pos+match : next]) + rep.Start = pos + rep.Desc = string(output[pos+match : next]) } - end = next + rep.End = next } if ctx.consoleOutputRe.Match(output[pos:next]) && (!ctx.questionableRe.Match(output[pos:next]) || @@ -116,8 +117,8 @@ func (ctx *linux) Parse(output []byte) (desc string, text []byte, start int, end // Prepend 5 lines preceding start of the report, // they can contain additional info related to the report. for _, prefix := range textPrefix { - text = append(text, prefix...) - text = append(text, '\n') + rep.Text = append(rep.Text, prefix...) + rep.Text = append(rep.Text, '\n') } textPrefix = nil textLines++ @@ -139,34 +140,33 @@ func (ctx *linux) Parse(output []byte) (desc string, text []byte, start int, end skipLine = true } if !skipLine { - text = append(text, ln...) - text = append(text, '\n') + rep.Text = append(rep.Text, ln...) + rep.Text = append(rep.Text, '\n') } } } pos = next + 1 } if oops == nil { - corrupted = isCorrupted("", string(text)) - return + return nil } - desc = extractDescription(output[start:], oops) + rep.Desc = extractDescription(output[rep.Start:], oops) // Executor PIDs are not interesting. - desc = executorRe.ReplaceAllLiteralString(desc, "syz-executor") + rep.Desc = executorRe.ReplaceAllLiteralString(rep.Desc, "syz-executor") // Replace that everything looks like an address with "ADDR", // addresses in descriptions can't be good regardless of the oops regexps. - desc = addrRe.ReplaceAllLiteralString(desc, "ADDR") + rep.Desc = addrRe.ReplaceAllLiteralString(rep.Desc, "ADDR") // Replace that everything looks like a decimal number with "NUM". - desc = decNumRe.ReplaceAllLiteralString(desc, "NUM") + rep.Desc = decNumRe.ReplaceAllLiteralString(rep.Desc, "NUM") // Replace that everything looks like a file line number with "LINE". - desc = lineNumRe.ReplaceAllLiteralString(desc, ":LINE") + rep.Desc = lineNumRe.ReplaceAllLiteralString(rep.Desc, ":LINE") // Replace all raw references to runctions (e.g. "ip6_fragment+0x1052/0x2d80") // with just function name ("ip6_fragment"). Offsets and sizes are not stable. - desc = funcRe.ReplaceAllString(desc, "$1") + rep.Desc = funcRe.ReplaceAllString(rep.Desc, "$1") // CPU numbers are not interesting. - desc = cpuRe.ReplaceAllLiteralString(desc, "CPU") - corrupted = isCorrupted(desc, string(text)) - return + rep.Desc = cpuRe.ReplaceAllLiteralString(rep.Desc, "CPU") + rep.Corrupted = isCorrupted(rep.Desc, string(rep.Text)) + return rep } func (ctx *linux) Symbolize(text []byte) ([]byte, error) { |
