aboutsummaryrefslogtreecommitdiffstats
path: root/prog/parse.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2021-09-03 16:20:07 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2021-09-22 15:40:02 +0200
commit1c202847db0380015a8920bfd21375c2d9f28ddb (patch)
tree6693da3a936398a9ac6678842ac181c5f0e3e429 /prog/parse.go
parenta7ce77be27d8e3728b97122a005bc5b23298cfc3 (diff)
all: refactor fault injection into call props
Now that call properties mechanism is implemented, we can refactor fault injection. Unfortunately, it is impossible to remove all traces of the previous apprach. In reprolist and while performing syz-ci jobs, syzkaller still needs to parse the old format. Remove the old prog options-based approach whenever possible and replace it with the use of call properties.
Diffstat (limited to 'prog/parse.go')
-rw-r--r--prog/parse.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/prog/parse.go b/prog/parse.go
index 7a46322df..77812f5b4 100644
--- a/prog/parse.go
+++ b/prog/parse.go
@@ -10,19 +10,17 @@ import (
// LogEntry describes one program in execution log.
type LogEntry struct {
- P *Prog
- Proc int // index of parallel proc
- Start int // start offset in log
- End int // end offset in log
- Fault bool // program was executed with fault injection in FaultCall/FaultNth
- FaultCall int
- FaultNth int
+ P *Prog
+ Proc int // index of parallel proc
+ Start int // start offset in log
+ End int // end offset in log
}
func (target *Target) ParseLog(data []byte) []*LogEntry {
var entries []*LogEntry
ent := &LogEntry{}
var cur []byte
+ faultCall, faultNth := -1, -1
for pos := 0; pos < len(data); {
nl := bytes.IndexByte(data[pos:], '\n')
if nl == -1 {
@@ -38,15 +36,17 @@ func (target *Target) ParseLog(data []byte) []*LogEntry {
if ent.P != nil && len(ent.P.Calls) != 0 {
ent.End = pos0
entries = append(entries, ent)
+ faultCall, faultNth = -1, -1
}
ent = &LogEntry{
Proc: proc,
Start: pos0,
}
- if faultCall, ok := extractInt(line, "fault-call:"); ok {
- ent.Fault = true
- ent.FaultCall = faultCall
- ent.FaultNth, _ = extractInt(line, "fault-nth:")
+ // We no longer print it this way, but we still parse such fragments to preserve
+ // the backward compatibility.
+ if parsedFaultCall, ok := extractInt(line, "fault-call:"); ok {
+ faultCall = parsedFaultCall
+ faultNth, _ = extractInt(line, "fault-nth:")
}
cur = nil
continue
@@ -55,10 +55,17 @@ func (target *Target) ParseLog(data []byte) []*LogEntry {
continue
}
tmp := append(cur, line...)
+
p, err := target.Deserialize(tmp, NonStrict)
if err != nil {
continue
}
+
+ if faultCall >= 0 && faultCall < len(p.Calls) {
+ // We add 1 because now the property is 1-based.
+ p.Calls[faultCall].Props.FailNth = faultNth + 1
+ }
+
cur = tmp
ent.P = p
}