-
Notifications
You must be signed in to change notification settings - Fork 6
/
read.go
76 lines (68 loc) · 1.78 KB
/
read.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"flag"
"fmt"
pb "github.com/ZHYfeng/Dependency/03-syzkaller/pkg/dra"
"path/filepath"
"strings"
)
var cmd = flag.String("cmd", "read", "read data")
var path = flag.String("path", ".", "the path of data")
var a2i = flag.Bool("a2i", false, "enable a2i")
func main() {
flag.Parse()
switch *cmd {
case "read":
read(*path, *a2i)
}
}
func read(path string, a2i bool) {
path, _ = filepath.Abs(path)
baseName := filepath.Base(path)
if strings.HasPrefix(baseName, pb.NameDevice) {
fmt.Printf("nameDevice\n")
d := &device{}
d.read(path, a2i)
} else if strings.HasPrefix(baseName, pb.NameWithDra) || strings.HasPrefix(baseName, pb.NameWithoutDra) {
fmt.Printf("nameWithDra or NameWithoutDra\n")
r := &results{}
r.read(path)
} else {
fmt.Printf("readUnstableInput\n")
readUnstableInput(path)
}
}
func readUnstableInput(path string) {
//in, err := ioutil.ReadFile(path)
//if err != nil {
// log.Fatalln("Error reading file:", err)
//}
//ui := &pb.UnstableInput{}
//if err := proto.Unmarshal(in, ui); err != nil {
// log.Fatalln("Failed to parse ui:", err)
//}
//fmt.Printf("0xffffffff%x\n", ui.Address-5)
//fmt.Printf("%d\n", ui.Idx)
//fmt.Printf("%s\n", ui.Program)
//for idx, path := range ui.NewPath {
// fmt.Printf("check %d NewPath\n", idx)
// for index, p := range path.Path {
// fmt.Printf("check %d path\n", index)
// for _, a := range p.Address {
// if a == ui.Address {
// fmt.Printf("find address in %d newpath %d path\n", idx, index)
// }
// }
// }
//}
//
//fmt.Printf("check UnstablePath\n")
//for index, p := range ui.UnstablePath {
// fmt.Printf("check %d path\n", index)
// for _, a := range p.Address {
// if a == ui.Address {
// fmt.Printf("find address in UnstablePath %d path\n", index)
// }
// }
//}
}