aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/repro
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-07-04 11:05:48 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-07-05 13:14:00 +0200
commit538df42ec716cdd5c5b619bda7704d71c9200621 (patch)
tree089e995c4f8103627db65d05829367feef870447 /pkg/repro
parentea88000dd91165202906aef5974ac91322d57ac2 (diff)
pkg/repro: provide stats even for failed repro
Provide stats and logs for failed repro and save it in manager. In particular log is useful for failed repros, currently there is no visibility into why bugs failed to reproduce.
Diffstat (limited to 'pkg/repro')
-rw-r--r--pkg/repro/repro.go37
-rw-r--r--pkg/repro/repro_test.go4
2 files changed, 21 insertions, 20 deletions
diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go
index 039f9cca7..83eac9bde 100644
--- a/pkg/repro/repro.go
+++ b/pkg/repro/repro.go
@@ -20,33 +20,32 @@ import (
"github.com/google/syzkaller/vm"
)
-type Stats struct {
- Log []byte
- ExtractProgTime time.Duration
- MinimizeProgTime time.Duration
- SimplifyProgTime time.Duration
- ExtractCTime time.Duration
- SimplifyCTime time.Duration
-}
-
type Result struct {
Prog *prog.Prog
Duration time.Duration
Opts csource.Options
CRepro bool
- Stats Stats
// Information about the final (non-symbolized) crash that we reproduced.
// Can be different from what we started reproducing.
Report *report.Report
}
+type Stats struct {
+ Log []byte
+ ExtractProgTime time.Duration
+ MinimizeProgTime time.Duration
+ SimplifyProgTime time.Duration
+ ExtractCTime time.Duration
+ SimplifyCTime time.Duration
+}
+
type context struct {
cfg *mgrconfig.Config
reporter report.Reporter
crashTitle string
instances chan *instance
bootRequests chan int
- stats Stats
+ stats *Stats
report *report.Report
}
@@ -58,17 +57,17 @@ type instance struct {
}
func Run(crashLog []byte, cfg *mgrconfig.Config, reporter report.Reporter, vmPool *vm.Pool,
- vmIndexes []int) (*Result, error) {
+ vmIndexes []int) (*Result, *Stats, error) {
if len(vmIndexes) == 0 {
- return nil, fmt.Errorf("no VMs provided")
+ return nil, nil, fmt.Errorf("no VMs provided")
}
target, err := prog.GetTarget(cfg.TargetOS, cfg.TargetArch)
if err != nil {
- return nil, err
+ return nil, nil, err
}
entries := target.ParseLog(crashLog)
if len(entries) == 0 {
- return nil, fmt.Errorf("crash log does not contain any programs")
+ return nil, nil, fmt.Errorf("crash log does not contain any programs")
}
crashStart := len(crashLog) // assuming VM hanged
crashTitle := "hang"
@@ -83,6 +82,7 @@ func Run(crashLog []byte, cfg *mgrconfig.Config, reporter report.Reporter, vmPoo
crashTitle: crashTitle,
instances: make(chan *instance, len(vmIndexes)),
bootRequests: make(chan int, len(vmIndexes)),
+ stats: new(Stats),
}
ctx.reproLog(0, "%v programs, %v VMs", len(entries), len(vmIndexes))
var wg sync.WaitGroup
@@ -144,7 +144,7 @@ func Run(crashLog []byte, cfg *mgrconfig.Config, reporter report.Reporter, vmPoo
res, err := ctx.repro(entries, crashStart)
if err != nil {
- return nil, err
+ return nil, nil, err
}
if res != nil {
ctx.reproLog(3, "repro crashed as (corrupted=%v):\n%s",
@@ -158,20 +158,19 @@ func Run(crashLog []byte, cfg *mgrconfig.Config, reporter report.Reporter, vmPoo
_, err = ctx.testProg(res.Prog, res.Duration, res.Opts)
}
if err != nil {
- return nil, err
+ return nil, nil, err
}
}
ctx.reproLog(3, "final repro crashed as (corrupted=%v):\n%s",
ctx.report.Corrupted, ctx.report.Report)
res.Report = ctx.report
- res.Stats = ctx.stats
}
close(ctx.bootRequests)
for inst := range ctx.instances {
inst.Close()
}
- return res, err
+ return res, ctx.stats, nil
}
func (ctx *context) repro(entries []*prog.LogEntry, crashStart int) (*Result, error) {
diff --git a/pkg/repro/repro_test.go b/pkg/repro/repro_test.go
index 91d71e84d..dc53e437b 100644
--- a/pkg/repro/repro_test.go
+++ b/pkg/repro/repro_test.go
@@ -24,7 +24,9 @@ func initTest(t *testing.T) (*rand.Rand, int) {
}
func TestBisect(t *testing.T) {
- ctx := &context{}
+ ctx := &context{
+ stats: new(Stats),
+ }
rd, iters := initTest(t)
for n := 0; n < iters; n++ {