aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-05-13 20:49:07 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-05-13 20:49:07 +0200
commit50749f54cde9f63ddd99e65a6a2d45f89f237019 (patch)
tree9636206e19fbf0e4367413047aed1a6b7903e7a4
parent1e61c8bc14f84ca8680c5a636514fb1ef2f7e091 (diff)
pkg/report: add ParseAll
ParseAll returns all reports in output. Use it in syz-symbolize.
-rw-r--r--pkg/report/report.go12
-rw-r--r--tools/syz-symbolize/symbolize.go35
2 files changed, 34 insertions, 13 deletions
diff --git a/pkg/report/report.go b/pkg/report/report.go
index e6d13b930..ac464a177 100644
--- a/pkg/report/report.go
+++ b/pkg/report/report.go
@@ -224,6 +224,18 @@ func IsSuppressed(reporter Reporter, output []byte) bool {
bytes.Contains(output, gceConsoleHangup)
}
+// ParseAll returns all successive reports in output.
+func ParseAll(reporter Reporter, output []byte) (reports []*Report) {
+ for {
+ rep := reporter.Parse(output)
+ if rep == nil {
+ return
+ }
+ reports = append(reports, rep)
+ output = output[rep.SkipPos:]
+ }
+}
+
// GCE console connection sometimes fails with this message.
// The message frequently happens right after a kernel panic.
// So if we see it in output where we recognized a crash, we mark the report as corrupted
diff --git a/tools/syz-symbolize/symbolize.go b/tools/syz-symbolize/symbolize.go
index 299531ced..a98ffcf3c 100644
--- a/tools/syz-symbolize/symbolize.go
+++ b/tools/syz-symbolize/symbolize.go
@@ -50,21 +50,30 @@ func main() {
fmt.Fprintf(os.Stderr, "failed to open input file: %v\n", err)
os.Exit(1)
}
- rep := reporter.Parse(text)
- if rep == nil {
- rep = &report.Report{Report: text}
- } else if *flagOutDir != "" {
- saveCrash(rep, *flagOutDir)
+ reps := report.ParseAll(reporter, text)
+ if len(reps) == 0 {
+ rep := &report.Report{Report: text}
+ if err := reporter.Symbolize(rep); err != nil {
+ fmt.Fprintf(os.Stderr, "failed to symbolize report: %v\n", err)
+ os.Exit(1)
+ }
+ os.Stdout.Write(rep.Report)
+ return
}
- if err := reporter.Symbolize(rep); err != nil {
- fmt.Fprintf(os.Stderr, "failed to symbolize report: %v\n", err)
- os.Exit(1)
+ for _, rep := range reps {
+ if *flagOutDir != "" {
+ saveCrash(rep, *flagOutDir)
+ }
+ if err := reporter.Symbolize(rep); err != nil {
+ fmt.Fprintf(os.Stderr, "failed to symbolize report: %v\n", err)
+ }
+ fmt.Printf("TITLE: %v\n", rep.Title)
+ fmt.Printf("CORRUPTED: %v (%v)\n", rep.Corrupted, rep.CorruptedReason)
+ fmt.Printf("MAINTAINERS: %v\n", rep.Maintainers)
+ fmt.Printf("\n")
+ os.Stdout.Write(rep.Report)
+ fmt.Printf("\n\n")
}
- fmt.Printf("TITLE: %v\n", rep.Title)
- fmt.Printf("CORRUPTED: %v (%v)\n", rep.Corrupted, rep.CorruptedReason)
- fmt.Printf("MAINTAINERS: %v\n", rep.Maintainers)
- fmt.Printf("\n")
- os.Stdout.Write(rep.Report)
}
func saveCrash(rep *report.Report, path string) {