diff options
| author | Kostya Serebryany <kcc@google.com> | 2016-10-08 22:12:14 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2016-10-08 22:12:14 +0000 |
| commit | 9adc7c8b4a624a9b5424ade22ccd85544238e503 (patch) | |
| tree | a352ccfc213424ace1a6a383a0775cd9436258e9 /llvm/lib/Fuzzer/FuzzerLoop.cpp | |
| parent | cd04ec25dd825a5d21a76cc23826137323f68c98 (diff) | |
| download | bcm5719-llvm-9adc7c8b4a624a9b5424ade22ccd85544238e503.tar.gz bcm5719-llvm-9adc7c8b4a624a9b5424ade22ccd85544238e503.zip | |
[libFuzzer] control the reload interval by a flag, make it 10 seconds by default
llvm-svn: 283676
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerLoop.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp index 49b58ddf5d5..be006ce7cdc 100644 --- a/llvm/lib/Fuzzer/FuzzerLoop.cpp +++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp @@ -149,7 +149,7 @@ Fuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD, if (Options.Verbosity) TPC.PrintModuleInfo(); - if (!Options.OutputCorpus.empty() && Options.Reload) + if (!Options.OutputCorpus.empty() && Options.ReloadIntervalSec) EpochOfLastReadOfOutputCorpus = GetEpoch(Options.OutputCorpus); MaxInputLen = MaxMutationLen = Options.MaxLen; AllocateCurrentUnitData(); @@ -383,22 +383,25 @@ void Fuzzer::CheckExitOnSrcPos() { } void Fuzzer::RereadOutputCorpus(size_t MaxSize) { - if (Options.OutputCorpus.empty() || !Options.Reload) return; + if (Options.OutputCorpus.empty() || !Options.ReloadIntervalSec) return; std::vector<Unit> AdditionalCorpus; ReadDirToVectorOfUnits(Options.OutputCorpus.c_str(), &AdditionalCorpus, &EpochOfLastReadOfOutputCorpus, MaxSize); if (Options.Verbosity >= 2) Printf("Reload: read %zd new units.\n", AdditionalCorpus.size()); + bool Reloaded = false; for (auto &U : AdditionalCorpus) { if (U.size() > MaxSize) U.resize(MaxSize); if (!Corpus.HasUnit(U)) { if (size_t NumFeatures = RunOne(U)) { Corpus.AddToCorpus(U, NumFeatures); - PrintStats("RELOAD"); + Reloaded = true; } } } + if (Reloaded) + PrintStats("RELOAD"); } void Fuzzer::ShuffleCorpus(UnitVector *V) { @@ -705,7 +708,8 @@ void Fuzzer::Loop() { MD.SetCorpus(&Corpus); while (true) { auto Now = system_clock::now(); - if (duration_cast<seconds>(Now - LastCorpusReload).count()) { + if (duration_cast<seconds>(Now - LastCorpusReload).count() >= + Options.ReloadIntervalSec) { RereadOutputCorpus(MaxInputLen); LastCorpusReload = Now; } |

