summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/fuzzer/FuzzerMutate.cpp
diff options
context:
space:
mode:
authorMatt Morehouse <mascasa@google.com>2018-07-09 22:31:26 +0000
committerMatt Morehouse <mascasa@google.com>2018-07-09 22:31:26 +0000
commita5bb6d53f2f4016a335e8dee310e76493ef3b825 (patch)
tree34fd74ad4eccd869f384e71aa19ae76004eea448 /compiler-rt/lib/fuzzer/FuzzerMutate.cpp
parentfed7382ef695ae81769620dbeee74a058615e148 (diff)
downloadbcm5719-llvm-a5bb6d53f2f4016a335e8dee310e76493ef3b825.tar.gz
bcm5719-llvm-a5bb6d53f2f4016a335e8dee310e76493ef3b825.zip
Revert "[libFuzzer] Mutation tracking and logging implemented"
This reverts r336597 due to bot breakage. llvm-svn: 336616
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerMutate.cpp')
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerMutate.cpp66
1 files changed, 20 insertions, 46 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp
index ef059fc22f6..865e598fdc8 100644
--- a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp
@@ -58,10 +58,6 @@ MutationDispatcher::MutationDispatcher(Random &Rand,
if (EF->LLVMFuzzerCustomCrossOver)
Mutators.push_back(
{&MutationDispatcher::Mutate_CustomCrossOver, "CustomCrossOver"});
-
- // Initialize mutation statistic counters.
- TotalMutations.resize(Mutators.size(), 0);
- UsefulMutations.resize(Mutators.size(), 0);
}
static char RandCh(Random &Rand) {
@@ -265,9 +261,9 @@ size_t MutationDispatcher::Mutate_AddWordFromTORC(
DE = MakeDictionaryEntryFromCMP(X.A, X.B, Data, Size);
} break;
case 3: if (Options.UseMemmem) {
- auto X = TPC.MMT.Get(Rand.Rand());
- DE = DictionaryEntry(X);
- } break;
+ auto X = TPC.MMT.Get(Rand.Rand());
+ DE = DictionaryEntry(X);
+ } break;
default:
assert(0);
}
@@ -435,18 +431,18 @@ size_t MutationDispatcher::Mutate_CrossOver(uint8_t *Data, size_t Size,
auto &U = MutateInPlaceHere;
size_t NewSize = 0;
switch(Rand(3)) {
- case 0:
- NewSize = CrossOver(Data, Size, O.data(), O.size(), U.data(), U.size());
- break;
- case 1:
- NewSize = InsertPartOf(O.data(), O.size(), U.data(), U.size(), MaxSize);
- if (!NewSize)
+ case 0:
+ NewSize = CrossOver(Data, Size, O.data(), O.size(), U.data(), U.size());
+ break;
+ case 1:
+ NewSize = InsertPartOf(O.data(), O.size(), U.data(), U.size(), MaxSize);
+ if (!NewSize)
+ NewSize = CopyPartOf(O.data(), O.size(), U.data(), U.size());
+ break;
+ case 2:
NewSize = CopyPartOf(O.data(), O.size(), U.data(), U.size());
- break;
- case 2:
- NewSize = CopyPartOf(O.data(), O.size(), U.data(), U.size());
- break;
- default: assert(0);
+ break;
+ default: assert(0);
}
assert(NewSize > 0 && "CrossOver returned empty unit");
assert(NewSize <= MaxSize && "CrossOver returned overisized unit");
@@ -455,7 +451,7 @@ size_t MutationDispatcher::Mutate_CrossOver(uint8_t *Data, size_t Size,
}
void MutationDispatcher::StartMutationSequence() {
- CurrentMutatorIdxSequence.clear();
+ CurrentMutatorSequence.clear();
CurrentDictionaryEntrySequence.clear();
}
@@ -469,7 +465,6 @@ void MutationDispatcher::RecordSuccessfulMutationSequence() {
if (!PersistentAutoDictionary.ContainsWord(DE->GetW()))
PersistentAutoDictionary.push_back({DE->GetW(), 1});
}
- RecordUsefulMutations();
}
void MutationDispatcher::PrintRecommendedDictionary() {
@@ -489,9 +484,9 @@ void MutationDispatcher::PrintRecommendedDictionary() {
}
void MutationDispatcher::PrintMutationSequence() {
- Printf("MS: %zd ", CurrentMutatorIdxSequence.size());
- for (auto M : CurrentMutatorIdxSequence)
- Printf("%s-", Mutators[M].Name);
+ Printf("MS: %zd ", CurrentMutatorSequence.size());
+ for (auto M : CurrentMutatorSequence)
+ Printf("%s-", M.Name);
if (!CurrentDictionaryEntrySequence.empty()) {
Printf(" DE: ");
for (auto DE : CurrentDictionaryEntrySequence) {
@@ -519,14 +514,12 @@ size_t MutationDispatcher::MutateImpl(uint8_t *Data, size_t Size,
// in which case they will return 0.
// Try several times before returning un-mutated data.
for (int Iter = 0; Iter < 100; Iter++) {
- size_t MutatorIdx = Rand(Mutators.size());
- auto M = Mutators[MutatorIdx];
+ auto M = Mutators[Rand(Mutators.size())];
size_t NewSize = (this->*(M.Fn))(Data, Size, MaxSize);
if (NewSize && NewSize <= MaxSize) {
if (Options.OnlyASCII)
ToASCII(Data, NewSize);
- CurrentMutatorIdxSequence.push_back(MutatorIdx);
- TotalMutations[MutatorIdx]++;
+ CurrentMutatorSequence.push_back(M);
return NewSize;
}
}
@@ -539,23 +532,4 @@ void MutationDispatcher::AddWordToManualDictionary(const Word &W) {
{W, std::numeric_limits<size_t>::max()});
}
-void MutationDispatcher::RecordUsefulMutations() {
- for (const size_t M : CurrentMutatorIdxSequence)
- UsefulMutations[M]++;
-}
-
-void MutationDispatcher::PrintMutationStats() {
- Printf("\nstat::mutation_usefulness: ");
- for (size_t i = 0; i < Mutators.size(); i++) {
- double UsefulPercentage =
- TotalMutations[i]
- ? (100.0 * UsefulMutations[i]) / TotalMutations[i]
- : 0;
- Printf("%.3f", UsefulPercentage);
- if (i < Mutators.size() - 1)
- Printf(",");
- }
- Printf("\n");
-}
-
} // namespace fuzzer
OpenPOWER on IntegriCloud