mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-27 21:30:33 +00:00
1c801e8512
It will be needed to reproduction tool.
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
// Copyright 2015 syzkaller project authors. All rights reserved.
|
|
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
|
|
|
|
package prog
|
|
|
|
import (
|
|
"bytes"
|
|
"strconv"
|
|
)
|
|
|
|
// 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
|
|
}
|
|
|
|
func ParseLog(data []byte) []*LogEntry {
|
|
var entries []*LogEntry
|
|
ent := &LogEntry{}
|
|
var cur []byte
|
|
for pos := 0; pos < len(data); {
|
|
nl := bytes.IndexByte(data[pos:], '\n')
|
|
if nl == -1 {
|
|
nl = len(data)
|
|
} else {
|
|
nl += pos
|
|
}
|
|
line := data[pos : nl+1]
|
|
pos0 := pos
|
|
pos = nl + 1
|
|
const delim = "executing program "
|
|
if delimPos := bytes.Index(line, []byte(delim)); delimPos != -1 {
|
|
if ent.P != nil && len(ent.P.Calls) != 0 {
|
|
ent.End = pos0
|
|
entries = append(entries, ent)
|
|
}
|
|
procStart := delimPos + len(delim)
|
|
procEnd := procStart
|
|
for procEnd != len(line) && line[procEnd] >= '0' && line[procEnd] <= '9' {
|
|
procEnd++
|
|
}
|
|
proc, _ := strconv.Atoi(string(line[procStart:procEnd]))
|
|
ent = &LogEntry{
|
|
Proc: proc,
|
|
Start: pos0,
|
|
}
|
|
cur = nil
|
|
continue
|
|
}
|
|
if ent == nil {
|
|
continue
|
|
}
|
|
tmp := append(cur, line...)
|
|
p, err := Deserialize(tmp)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
cur = tmp
|
|
ent.P = p
|
|
}
|
|
if ent.P != nil && len(ent.P.Calls) != 0 {
|
|
ent.End = len(data)
|
|
entries = append(entries, ent)
|
|
}
|
|
return entries
|
|
}
|