diff options
author | Kostya Serebryany <kcc@google.com> | 2017-07-18 18:47:36 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2017-07-18 18:47:36 +0000 |
commit | 9c21c1e832cfd254aa2f29e67f5b27dd71cb7975 (patch) | |
tree | 4ae3f780bf6547d936b5bbccfd48cc808eda9f4c /lib/Fuzzer | |
parent | 4ea9a7811e00a8caef17bb09967cf85ae96677fe (diff) |
[libFuzzer] when adding a reduced input print REDUCED instead of NEW
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Fuzzer')
-rw-r--r-- | lib/Fuzzer/FuzzerCorpus.h | 4 | ||||
-rw-r--r-- | lib/Fuzzer/FuzzerInternal.h | 2 | ||||
-rw-r--r-- | lib/Fuzzer/FuzzerLoop.cpp | 7 |
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/Fuzzer/FuzzerCorpus.h b/lib/Fuzzer/FuzzerCorpus.h index 5d2a47d2fe70..bae0aea78f13 100644 --- a/lib/Fuzzer/FuzzerCorpus.h +++ b/lib/Fuzzer/FuzzerCorpus.h @@ -34,6 +34,7 @@ struct InputInfo { size_t NumExecutedMutations = 0; size_t NumSuccessfullMutations = 0; bool MayDeleteFile = false; + bool Reduced = false; std::vector<uint32_t> UniqFeatureSet; }; @@ -126,12 +127,13 @@ class InputCorpus { } void Replace(InputInfo *II, const Unit &U) { - assert(II->U.size()); + assert(II->U.size() > U.size()); Hashes.erase(Sha1ToString(II->Sha1)); DeleteFile(*II); ComputeSHA1(U.data(), U.size(), II->Sha1); Hashes.insert(Sha1ToString(II->Sha1)); II->U = U; + II->Reduced = true; } bool HasUnit(const Unit &U) { return Hashes.count(Hash(U)); } diff --git a/lib/Fuzzer/FuzzerInternal.h b/lib/Fuzzer/FuzzerInternal.h index 8993f2cdaf01..3fc3fe004cef 100644 --- a/lib/Fuzzer/FuzzerInternal.h +++ b/lib/Fuzzer/FuzzerInternal.h @@ -99,7 +99,7 @@ private: void WriteToOutputCorpus(const Unit &U); void WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix); void PrintStats(const char *Where, const char *End = "\n", size_t Units = 0); - void PrintStatusForNewUnit(const Unit &U); + void PrintStatusForNewUnit(const Unit &U, const char *Text); void ShuffleCorpus(UnitVector *V); void CheckExitOnSrcPosOrItem(); diff --git a/lib/Fuzzer/FuzzerLoop.cpp b/lib/Fuzzer/FuzzerLoop.cpp index 046816c5d771..8ac7a847aef7 100644 --- a/lib/Fuzzer/FuzzerLoop.cpp +++ b/lib/Fuzzer/FuzzerLoop.cpp @@ -507,10 +507,10 @@ void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) { Printf("Base64: %s\n", Base64(U).c_str()); } -void Fuzzer::PrintStatusForNewUnit(const Unit &U) { +void Fuzzer::PrintStatusForNewUnit(const Unit &U, const char *Text) { if (!Options.PrintNEW) return; - PrintStats("NEW ", ""); + PrintStats(Text, ""); if (Options.Verbosity) { Printf(" L: %zd ", U.size()); MD.PrintMutationSequence(); @@ -521,7 +521,8 @@ void Fuzzer::PrintStatusForNewUnit(const Unit &U) { void Fuzzer::ReportNewCoverage(InputInfo *II, const Unit &U) { II->NumSuccessfullMutations++; MD.RecordSuccessfulMutationSequence(); - PrintStatusForNewUnit(U); + PrintStatusForNewUnit(U, II->Reduced ? "REDUCE" : + "NEW "); WriteToOutputCorpus(U); NumberOfNewUnitsAdded++; TPC.PrintNewPCs(); |