pkg/repro: save final crash log

Logs are useful in situations where we mess the report.
Since we try to report crashes with reproducers,
we need logs for reproducers.
This commit is contained in:
Dmitry Vyukov 2017-07-18 16:31:27 +02:00
parent 012622d3c9
commit 0107e4124d
2 changed files with 13 additions and 7 deletions

View File

@ -36,9 +36,10 @@ type Result struct {
Opts csource.Options
CRepro bool
Stats Stats
// Description and report of the final crash that we reproduced.
// Description, log and report of the final crash that we reproduced.
// Can be different from what we started reproducing.
Desc string
Log []byte
Report []byte
}
@ -49,6 +50,7 @@ type context struct {
bootRequests chan int
stats Stats
desc string
log []byte
report []byte
}
@ -142,6 +144,7 @@ func Run(crashLog []byte, cfg *mgrconfig.Config, vmPool *vm.Pool, vmIndexes []in
ctx.reproLog(3, "repro crashed as:\n%s", string(ctx.report))
res.Stats = ctx.stats
res.Desc = ctx.desc
res.Log = ctx.log
res.Report = ctx.report
}
@ -665,13 +668,13 @@ 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)
}
desc, report, output, crashed, timedout := vm.MonitorExecution(outc, errc, false, ctx.cfg.ParsedIgnores)
_, _, _ = report, output, timedout
desc, report, output, crashed, _ := vm.MonitorExecution(outc, errc, false, ctx.cfg.ParsedIgnores)
if !crashed {
ctx.reproLog(2, "program did not crash")
return false, nil
}
ctx.desc = desc
ctx.log = output
ctx.report = report
ctx.reproLog(2, "program crashed: %v", desc)
return true, nil

View File

@ -627,10 +627,13 @@ func (mgr *Manager) saveRepro(res *repro.Result) {
if len(mgr.cfg.Tag) > 0 {
osutil.WriteFile(filepath.Join(dir, "repro.tag"), []byte(mgr.cfg.Tag))
}
if len(res.Report) > 0 {
osutil.WriteFile(filepath.Join(dir, "repro.report"), []byte(res.Report))
if len(res.Log) > 0 {
osutil.WriteFile(filepath.Join(dir, "repro.log"), res.Log)
}
osutil.WriteFile(filepath.Join(dir, "repro.log"), res.Stats.Log)
if len(res.Report) > 0 {
osutil.WriteFile(filepath.Join(dir, "repro.report"), res.Report)
}
osutil.WriteFile(filepath.Join(dir, "repro.stats.log"), res.Stats.Log)
stats := fmt.Sprintf("Extracting prog: %s\nMinimizing prog: %s\nSimplifying prog options: %s\nExtracting C: %s\nSimplifying C: %s\n",
res.Stats.ExtractProgTime, res.Stats.MinimizeProgTime, res.Stats.SimplifyProgTime, res.Stats.ExtractCTime, res.Stats.SimplifyCTime)
osutil.WriteFile(filepath.Join(dir, "repro.stats"), []byte(stats))
@ -664,7 +667,7 @@ func (mgr *Manager) saveRepro(res *repro.Result) {
BuildID: mgr.cfg.Tag,
Title: res.Desc,
Maintainers: maintainers,
Log: nil,
Log: res.Log,
Report: res.Report,
ReproOpts: []byte(fmt.Sprintf("%+v", res.Opts)),
ReproSyz: []byte(res.Prog.Serialize()),