diff options
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerMutate.h')
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerMutate.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerMutate.h b/compiler-rt/lib/fuzzer/FuzzerMutate.h index 828ecc13d86..d89667cc41c 100644 --- a/compiler-rt/lib/fuzzer/FuzzerMutate.h +++ b/compiler-rt/lib/fuzzer/FuzzerMutate.h @@ -93,9 +93,22 @@ public: Random &GetRand() { return Rand; } + /// Records tally of mutations resulting in new coverage, for usefulness + /// metric. + void RecordUsefulMutations(); + + /// Outputs usefulness stats on command line if option is enabled. void PrintMutationStats(); - void RecordUsefulMutations(); + /// Recalculates mutation stats based on latest run data. + void UpdateMutationStats(); + + /// Sets weights based on mutation performance during fuzzer run. + void UpdateDistribution(); + + /// Returns the index of a mutation based on how useful it has been. + /// Favors mutations with higher usefulness ratios but can return any index. + size_t WeightedIndex(); private: struct Mutator { @@ -156,6 +169,10 @@ public: Vector<Mutator> Mutators; Vector<Mutator> DefaultMutators; + + // Used to weight mutations based on usefulness. + Vector<double> Stats; + std::discrete_distribution<size_t> Distribution; }; } // namespace fuzzer |

