aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/corpus/corpus.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/corpus/corpus.go')
-rw-r--r--pkg/corpus/corpus.go66
1 files changed, 38 insertions, 28 deletions
diff --git a/pkg/corpus/corpus.go b/pkg/corpus/corpus.go
index 54c8d96cd..e6569dbc6 100644
--- a/pkg/corpus/corpus.go
+++ b/pkg/corpus/corpus.go
@@ -94,13 +94,14 @@ type ItemUpdate struct {
// too hard to synchonize accesses to them across the whole project.
// When Corpus updates one of its items, it saves a copy of it.
type Item struct {
- Sig string
- Call int
- Prog *prog.Prog
- HasAny bool // whether the prog contains squashed arguments
- Signal signal.Signal
- Cover []uint64
- Updates []ItemUpdate
+ Sig string
+ Call int
+ Prog *prog.Prog
+ HasAny bool // whether the prog contains squashed arguments
+ Signal signal.Signal
+ StableSignal signal.Signal
+ Cover []uint64
+ Updates []ItemUpdate
areas map[*focusAreaState]struct{}
}
@@ -110,16 +111,19 @@ func (item Item) StringCall() string {
}
type NewInput struct {
- Prog *prog.Prog
- Call int
- Signal signal.Signal
- Cover []uint64
- RawCover []uint64
+ Prog *prog.Prog
+ Call int
+ Signal signal.Signal
+ StableSignal signal.Signal
+ Cover []uint64
+ RawCover []uint64
+ ProbOnly bool
}
type NewItemEvent struct {
Sig string
Exists bool
+ ProbOnly bool
ProgData []byte
NewCover []uint64
}
@@ -141,18 +145,21 @@ func (corpus *Corpus) Save(inp NewInput) {
exists = true
newSignal := old.Signal.Copy()
newSignal.Merge(inp.Signal)
+ newStableSignal := old.StableSignal.Copy()
+ newStableSignal.Merge(inp.StableSignal)
var newCover cover.Cover
newCover.Merge(old.Cover)
newCover.Merge(inp.Cover)
newItem = &Item{
- Sig: sig,
- Prog: old.Prog,
- Call: old.Call,
- HasAny: old.HasAny,
- Signal: newSignal,
- Cover: newCover.Serialize(),
- Updates: append([]ItemUpdate{}, old.Updates...),
- areas: maps.Clone(old.areas),
+ Sig: sig,
+ Prog: old.Prog,
+ Call: old.Call,
+ HasAny: old.HasAny,
+ Signal: newSignal,
+ StableSignal: newStableSignal,
+ Cover: newCover.Serialize(),
+ Updates: append([]ItemUpdate{}, old.Updates...),
+ areas: maps.Clone(old.areas),
}
const maxUpdates = 32
if len(newItem.Updates) < maxUpdates {
@@ -160,18 +167,20 @@ func (corpus *Corpus) Save(inp NewInput) {
}
} else {
newItem = &Item{
- Sig: sig,
- Call: inp.Call,
- Prog: inp.Prog,
- HasAny: inp.Prog.ContainsAny(),
- Signal: inp.Signal,
- Cover: inp.Cover,
- Updates: []ItemUpdate{update},
+ Sig: sig,
+ Call: inp.Call,
+ Prog: inp.Prog,
+ HasAny: inp.Prog.ContainsAny(),
+ Signal: inp.Signal,
+ StableSignal: inp.StableSignal,
+ Cover: inp.Cover,
+ Updates: []ItemUpdate{update},
}
}
+
corpus.progsMap[sig] = newItem
corpus.applyFocusAreas(newItem, newItem.Cover)
- corpus.saveProgram(inp.Prog, newItem.Signal)
+ corpus.saveProgram(inp.Prog, newItem.StableSignal)
corpus.signal.Merge(inp.Signal)
newCover := corpus.cover.MergeDiff(inp.Cover)
@@ -181,6 +190,7 @@ func (corpus *Corpus) Save(inp NewInput) {
case corpus.updates <- NewItemEvent{
Sig: sig,
Exists: exists,
+ ProbOnly: inp.ProbOnly,
ProgData: progData,
NewCover: newCover,
}: