aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/report/linux.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-07-23 09:15:43 +0200
committerDmitry Vyukov <dvyukov@google.com>2019-07-23 09:15:43 +0200
commitd9ec038e02b467c11141dc238037ac7413ee6c1f (patch)
tree6876fd8e0fec335c2d893b5bfd19447bd3750690 /pkg/report/linux.go
parentb858e6fb5f220b97655fd23bc5f099c42ef4b159 (diff)
pkg/report: refactor argument passing
We now pass 5 arguments through a bunch of functions, this is quite inconvinient when the set of arguments changes. Incapsulate all arguments in a struct and pass/store it as a whole.
Diffstat (limited to 'pkg/report/linux.go')
-rw-r--r--pkg/report/linux.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/pkg/report/linux.go b/pkg/report/linux.go
index 61f92ef5d..384f3fa5f 100644
--- a/pkg/report/linux.go
+++ b/pkg/report/linux.go
@@ -16,16 +16,12 @@ import (
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/pkg/symbolizer"
- "github.com/google/syzkaller/sys/targets"
)
type linux struct {
- kernelSrc string
- kernelBuildSrc string
- kernelObj string
+ *config
vmlinux string
symbols map[string][]symbolizer.Symbol
- ignores []*regexp.Regexp
consoleOutputRe *regexp.Regexp
questionableRes []*regexp.Regexp
taskContext *regexp.Regexp
@@ -36,11 +32,11 @@ type linux struct {
eoi []byte
}
-func ctorLinux(target *targets.Target, kernelSrc, kernelBuildSrc, kernelObj string, ignores []*regexp.Regexp) (Reporter, []string, error) {
+func ctorLinux(cfg *config) (Reporter, []string, error) {
var symbols map[string][]symbolizer.Symbol
vmlinux := ""
- if kernelObj != "" {
- vmlinux = filepath.Join(kernelObj, target.KernelObject)
+ if cfg.kernelObj != "" {
+ vmlinux = filepath.Join(cfg.kernelObj, cfg.target.KernelObject)
var err error
symbols, err = symbolizer.ReadSymbols(vmlinux)
if err != nil {
@@ -48,12 +44,9 @@ func ctorLinux(target *targets.Target, kernelSrc, kernelBuildSrc, kernelObj stri
}
}
ctx := &linux{
- kernelSrc: kernelSrc,
- kernelBuildSrc: kernelBuildSrc,
- kernelObj: kernelObj,
- vmlinux: vmlinux,
- symbols: symbols,
- ignores: ignores,
+ config: cfg,
+ vmlinux: vmlinux,
+ symbols: symbols,
}
ctx.consoleOutputRe = regexp.MustCompile(`^(?:\*\* [0-9]+ printk messages dropped \*\* )?(?:.* login: )?(?:\<[0-9]+\>)?\[ *[0-9]+\.[0-9]+\](\[ *(?:C|T)[0-9]+\])? `)
ctx.questionableRes = []*regexp.Regexp{