aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-11-29 13:23:42 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-11-29 14:36:51 +0100
commit34f2c2332bedc41c5d22eaa35a555720cae3a1c7 (patch)
treebeb6f2d3d1399fef2c4f9d511e9d5d0804609261 /pkg
parent19d272a98fd5c705b0345798da1a3e3d5b37f91f (diff)
pkg/report: add Output to Report
Whole raw output is indivisble part of Report, currently we always pass Output separately along with Report. Make Output a Report field. Then, put whole Report into manager Crash and repro context and Result. There is little point in passing Report as aa bunch of separate fields.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/report/freebsd.go4
-rw-r--r--pkg/report/linux.go4
-rw-r--r--pkg/report/report.go2
-rw-r--r--pkg/repro/repro.go32
4 files changed, 19 insertions, 23 deletions
diff --git a/pkg/report/freebsd.go b/pkg/report/freebsd.go
index 46efea5d9..dd9c8178d 100644
--- a/pkg/report/freebsd.go
+++ b/pkg/report/freebsd.go
@@ -34,7 +34,9 @@ func (ctx *freebsd) ContainsCrash(output []byte) bool {
}
func (ctx *freebsd) Parse(output []byte) *Report {
- rep := new(Report)
+ rep := &Report{
+ Output: output,
+ }
var oops *oops
for pos := 0; pos < len(output); {
next := bytes.IndexByte(output[pos:], '\n')
diff --git a/pkg/report/linux.go b/pkg/report/linux.go
index 3804a134e..0efab7c16 100644
--- a/pkg/report/linux.go
+++ b/pkg/report/linux.go
@@ -78,7 +78,9 @@ func (ctx *linux) ContainsCrash(output []byte) bool {
func (ctx *linux) Parse(output []byte) *Report {
output = ctx.ExtractConsoleOutput(output)
- rep := new(Report)
+ rep := &Report{
+ Output: output,
+ }
var oops *oops
var textPrefix [][]byte
textLines := 0
diff --git a/pkg/report/report.go b/pkg/report/report.go
index 272c359ab..813e8ef3c 100644
--- a/pkg/report/report.go
+++ b/pkg/report/report.go
@@ -34,6 +34,8 @@ type Report struct {
Title string
// Report contains whole oops text.
Report []byte
+ // Output contains whole raw kernel output.
+ Output []byte
// StartPos/EndPos denote region of output with oops message(s).
StartPos int
EndPos int
diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go
index 35dd51628..1d9b51493 100644
--- a/pkg/repro/repro.go
+++ b/pkg/repro/repro.go
@@ -35,12 +35,9 @@ type Result struct {
Opts csource.Options
CRepro bool
Stats Stats
- // Title, Log and Report of the final crash that we reproduced.
+ // Information about the final crash that we reproduced.
// Can be different from what we started reproducing.
- Title string
- Log []byte
- Report []byte
- Corrupted bool
+ Report *report.Report
}
type context struct {
@@ -50,10 +47,7 @@ type context struct {
instances chan *instance
bootRequests chan int
stats Stats
- title string
- log []byte
- report []byte
- corrupted bool
+ report *report.Report
}
type instance struct {
@@ -153,10 +147,11 @@ func Run(crashLog []byte, cfg *mgrconfig.Config, reporter report.Reporter, vmPoo
return nil, err
}
if res != nil {
- ctx.reproLog(3, "repro crashed as (corrupted=%v):\n%s", ctx.corrupted, ctx.report)
+ ctx.reproLog(3, "repro crashed as (corrupted=%v):\n%s",
+ ctx.report.Corrupted, ctx.report.Report)
// Try to rerun the repro if the report is corrupted.
- for attempts := 0; ctx.corrupted && attempts < 3; attempts++ {
- ctx.reproLog(3, "report is corrupted, running repro again\n")
+ for attempts := 0; ctx.report.Corrupted && attempts < 3; attempts++ {
+ ctx.reproLog(3, "report is corrupted, running repro again")
if res.CRepro {
_, err = ctx.testCProg(res.Prog, res.Duration, res.Opts)
} else {
@@ -166,11 +161,9 @@ func Run(crashLog []byte, cfg *mgrconfig.Config, reporter report.Reporter, vmPoo
return nil, err
}
}
- ctx.reproLog(3, "final repro crashed as (corrupted=%v):\n%s", ctx.corrupted, ctx.report)
- res.Title = ctx.title
- res.Log = ctx.log
+ ctx.reproLog(3, "final repro crashed as (corrupted=%v):\n%s",
+ ctx.report.Corrupted, ctx.report.Report)
res.Report = ctx.report
- res.Corrupted = ctx.corrupted
res.Stats = ctx.stats
}
@@ -616,15 +609,12 @@ func (ctx *context) testImpl(inst *vm.Instance, command string, duration time.Du
if err != nil {
return false, fmt.Errorf("failed to run command in VM: %v", err)
}
- rep, output := vm.MonitorExecution(outc, errc, ctx.reporter, true)
+ rep := vm.MonitorExecution(outc, errc, ctx.reporter, true)
if rep == nil {
ctx.reproLog(2, "program did not crash")
return false, nil
}
- ctx.title = rep.Title
- ctx.log = output
- ctx.report = rep.Report
- ctx.corrupted = rep.Corrupted
+ ctx.report = rep
ctx.reproLog(2, "program crashed: %v", rep.Title)
return true, nil
}