aboutsummaryrefslogtreecommitdiffstats
path: root/sys/syz-extract
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-08-26 21:36:08 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-08-27 11:51:40 +0200
commita3857c4e90fa4a3fbe78bd4b53cdc77aa91533cf (patch)
tree8bc28379a29112de7bc11c57f3d91d0baba84594 /sys/syz-extract
parent9ec49e082f811482ecdccc837c27961d68247d25 (diff)
pkg/compiler, sys/syz-sysgen: move const handling to pkg/compiler
Now pkg/compiler deals with consts.
Diffstat (limited to 'sys/syz-extract')
-rw-r--r--sys/syz-extract/extract.go10
-rw-r--r--sys/syz-extract/fetch.go7
2 files changed, 11 insertions, 6 deletions
diff --git a/sys/syz-extract/extract.go b/sys/syz-extract/extract.go
index d3547dbcb..5f978a37e 100644
--- a/sys/syz-extract/extract.go
+++ b/sys/syz-extract/extract.go
@@ -68,12 +68,12 @@ func main() {
failf("failed to read input file: %v", err)
}
- top, ok := ast.Parse(indata, filepath.Dir(inname), nil)
- if !ok {
+ desc := ast.Parse(indata, filepath.Dir(inname), nil)
+ if desc == nil {
os.Exit(1)
}
- consts := compileConsts(archs[*flagArch], top)
+ consts := compileConsts(archs[*flagArch], desc)
out := new(bytes.Buffer)
generateConsts(*flagArch, consts, out)
@@ -95,8 +95,8 @@ func generateConsts(arch string, consts map[string]uint64, out io.Writer) {
}
}
-func compileConsts(arch *Arch, top []interface{}) map[string]uint64 {
- valArr, includes, incdirs, defines := compiler.ExtractConsts(top)
+func compileConsts(arch *Arch, desc *ast.Description) map[string]uint64 {
+ valArr, includes, incdirs, defines := compiler.ExtractConsts(desc)
if len(valArr) == 0 {
return nil
}
diff --git a/sys/syz-extract/fetch.go b/sys/syz-extract/fetch.go
index c480b8563..2340395cc 100644
--- a/sys/syz-extract/fetch.go
+++ b/sys/syz-extract/fetch.go
@@ -58,8 +58,13 @@ func fetchValues(arch string, vals []string, includes []string, incdirs []string
}
flagVals := strings.Split(string(out), " ")
+ if len(out) == 0 {
+ flagVals = nil
+ }
if len(flagVals) != len(vals)-len(undeclared) {
- failf("fetched wrong number of values %v != %v - %v", len(flagVals), len(vals), len(undeclared))
+ failf("fetched wrong number of values %v != %v - %v\nflagVals: %q\nvals: %q\nundeclared: %q",
+ len(flagVals), len(vals), len(undeclared),
+ flagVals, vals, undeclared)
}
res := make(map[string]uint64)
j := 0