diff --git a/lib/Fuzzer/FuzzerDriver.cpp b/lib/Fuzzer/FuzzerDriver.cpp index 8bbafd3a43a..c5de16b1251 100644 --- a/lib/Fuzzer/FuzzerDriver.cpp +++ b/lib/Fuzzer/FuzzerDriver.cpp @@ -530,14 +530,10 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) { if (Flags.merge) { if (Options.MaxLen == 0) F->SetMaxInputLen(kMaxSaneLen); - if (TPC.UsingTracePcGuard()) { - if (Flags.merge_control_file) - F->CrashResistantMergeInternalStep(Flags.merge_control_file); - else - F->CrashResistantMerge(Args, *Inputs); - } else { - F->Merge(*Inputs); - } + if (Flags.merge_control_file) + F->CrashResistantMergeInternalStep(Flags.merge_control_file); + else + F->CrashResistantMerge(Args, *Inputs); exit(0); } diff --git a/lib/Fuzzer/FuzzerInternal.h b/lib/Fuzzer/FuzzerInternal.h index 798ee641cb6..347228ebc42 100644 --- a/lib/Fuzzer/FuzzerInternal.h +++ b/lib/Fuzzer/FuzzerInternal.h @@ -72,8 +72,6 @@ public: void CrashResistantMerge(const std::vector &Args, const std::vector &Corpora); void CrashResistantMergeInternalStep(const std::string &ControlFilePath); - // Returns a subset of 'Extra' that adds coverage to 'Initial'. - UnitVector FindExtraUnits(const UnitVector &Initial, const UnitVector &Extra); MutationDispatcher &GetMD() { return MD; } void PrintFinalStats(); void SetMaxInputLen(size_t MaxInputLen); diff --git a/lib/Fuzzer/FuzzerLoop.cpp b/lib/Fuzzer/FuzzerLoop.cpp index f4a2929a39f..bed28d84e6a 100644 --- a/lib/Fuzzer/FuzzerLoop.cpp +++ b/lib/Fuzzer/FuzzerLoop.cpp @@ -535,76 +535,6 @@ void Fuzzer::ReportNewCoverage(InputInfo *II, const Unit &U) { TPC.PrintNewPCs(); } -// Finds minimal number of units in 'Extra' that add coverage to 'Initial'. -// We do it by actually executing the units, sometimes more than once, -// because we may be using different coverage-like signals and the only -// common thing between them is that we can say "this unit found new stuff". -UnitVector Fuzzer::FindExtraUnits(const UnitVector &Initial, - const UnitVector &Extra) { - UnitVector Res = Extra; - UnitVector Tmp; - size_t OldSize = Res.size(); - for (int Iter = 0; Iter < 10; Iter++) { - ShuffleCorpus(&Res); - TPC.ResetMaps(); - Corpus.ResetFeatureSet(); - - for (auto &U : Initial) { - TPC.ResetMaps(); - RunOne(U); - } - - Tmp.clear(); - for (auto &U : Res) { - TPC.ResetMaps(); - if (RunOne(U)) - Tmp.push_back(U); - } - - char Stat[7] = "MIN "; - Stat[3] = '0' + Iter; - PrintStats(Stat, "\n", Tmp.size()); - - size_t NewSize = Tmp.size(); - assert(NewSize <= OldSize); - Res.swap(Tmp); - - if (NewSize + 5 >= OldSize) - break; - OldSize = NewSize; - } - return Res; -} - -void Fuzzer::Merge(const std::vector &Corpora) { - if (Corpora.size() <= 1) { - Printf("Merge requires two or more corpus dirs\n"); - return; - } - InMergeMode = true; - std::vector ExtraCorpora(Corpora.begin() + 1, Corpora.end()); - - assert(MaxInputLen > 0); - UnitVector Initial, Extra; - ReadDirToVectorOfUnits(Corpora[0].c_str(), &Initial, nullptr, MaxInputLen, - true); - for (auto &C : ExtraCorpora) - ReadDirToVectorOfUnits(C.c_str(), &Extra, nullptr, MaxInputLen, true); - - if (!Initial.empty()) { - Printf("=== Minimizing the initial corpus of %zd units\n", Initial.size()); - Initial = FindExtraUnits({}, Initial); - } - - Printf("=== Merging extra %zd units\n", Extra.size()); - auto Res = FindExtraUnits(Initial, Extra); - - for (auto &U: Res) - WriteToOutputCorpus(U); - - Printf("=== Merge: written %zd units\n", Res.size()); -} - // Tries detecting a memory leak on the particular input that we have just // executed before calling this function. void Fuzzer::TryDetectingAMemoryLeak(const uint8_t *Data, size_t Size, diff --git a/lib/Fuzzer/FuzzerTracePC.h b/lib/Fuzzer/FuzzerTracePC.h index 05d03e960c9..1fbd0158b1d 100644 --- a/lib/Fuzzer/FuzzerTracePC.h +++ b/lib/Fuzzer/FuzzerTracePC.h @@ -75,8 +75,6 @@ class TracePC { void AddValueForMemcmp(void *caller_pc, const void *s1, const void *s2, size_t n, bool StopAtZero); - bool UsingTracePcGuard() const {return NumModules; } - TableOfRecentCompares TORC4; TableOfRecentCompares TORC8; TableOfRecentCompares TORCW; @@ -112,7 +110,6 @@ private: template size_t TracePC::CollectFeatures(Callback CB) const { - if (!UsingTracePcGuard()) return 0; size_t Res = 0; const size_t Step = 8; uint8_t *Counters = this->Counters();