mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-23 19:39:40 +00:00
pkg/ifuzz: use serializer
Simplifies code and reduces size of generated code from 820K to 310K.
This commit is contained in:
parent
dbb49d0211
commit
b5c5217623
@ -14,6 +14,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/syzkaller/pkg/ifuzz"
|
||||
"github.com/google/syzkaller/pkg/serializer"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -138,6 +139,10 @@ func main() {
|
||||
var deduped []*ifuzz.Insn
|
||||
nextInsn:
|
||||
for _, insn := range insns {
|
||||
if insn.Extension == "AVX512VEX" || insn.Extension == "AVX512EVEX" {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
mod0 := insn.Mod
|
||||
for j := len(deduped) - 1; j >= 0; j-- {
|
||||
insn1 := deduped[j]
|
||||
@ -159,19 +164,8 @@ nextInsn:
|
||||
|
||||
fmt.Printf("// AUTOGENERATED FILE\n")
|
||||
fmt.Printf("package ifuzz\n\n")
|
||||
fmt.Printf("var Insns = []*Insn{\n")
|
||||
for _, insn := range insns {
|
||||
if insn.Extension == "AVX512VEX" || insn.Extension == "AVX512EVEX" {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
|
||||
text := fmt.Sprintf("%#v", insn)
|
||||
text = strings.Replace(text, "ifuzz.Insn", "Insn", -1)
|
||||
text = strings.Replace(text, ", generator:(func(*ifuzz.Config, *rand.Rand) []uint8)(nil)", "", -1)
|
||||
fmt.Printf(" %v,\n", text)
|
||||
}
|
||||
fmt.Printf("}\n")
|
||||
fmt.Printf("var Insns = ")
|
||||
serializer.Write(os.Stdout, insns)
|
||||
|
||||
fmt.Fprintf(os.Stderr, "handled %v, skipped %v\n", len(insns), skipped)
|
||||
}
|
||||
|
4340
pkg/ifuzz/insns.go
4340
pkg/ifuzz/insns.go
File diff suppressed because it is too large
Load Diff
@ -102,6 +102,8 @@ func (w *writer) do(v reflect.Value, sliceElem bool) {
|
||||
fmt.Fprintf(w.w, "%v", v.Uint())
|
||||
case reflect.String:
|
||||
fmt.Fprintf(w.w, "%q", v.String())
|
||||
case reflect.Func:
|
||||
// Skip, no way to serialize this.
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported type: %#v", v.Type().String()))
|
||||
}
|
||||
@ -159,6 +161,8 @@ func isDefaultValue(v reflect.Value) bool {
|
||||
return v.Uint() == 0
|
||||
case reflect.String:
|
||||
return v.String() == ""
|
||||
case reflect.Func:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user