summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerLoop.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-09-23 01:58:51 +0000
committerKostya Serebryany <kcc@google.com>2016-09-23 01:58:51 +0000
commit16a145fd0ff30a2ae0a94de0bfc1e5b4828ddcdd (patch)
tree244f248da12a4110426c5ab70b93371085fe9a3e /llvm/lib/Fuzzer/FuzzerLoop.cpp
parente88bbc34c6c13b1ac1a76183afa04b327fc1abc0 (diff)
downloadbcm5719-llvm-16a145fd0ff30a2ae0a94de0bfc1e5b4828ddcdd.tar.gz
bcm5719-llvm-16a145fd0ff30a2ae0a94de0bfc1e5b4828ddcdd.zip
[libFuzzer] fix merging with trace-pc-guard
llvm-svn: 282224
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerLoop.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp
index 0ca03c5fea9..c376d10dd51 100644
--- a/llvm/lib/Fuzzer/FuzzerLoop.cpp
+++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp
@@ -163,6 +163,7 @@ Fuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,
assert(!F);
F = this;
TPC.ResetTotalPCCoverage();
+ TPC.Reset();
ResetCoverage();
IsMyThread = true;
if (Options.DetectLeaks && EF->__sanitizer_install_malloc_and_free_hooks)
@@ -309,7 +310,7 @@ void Fuzzer::RssLimitCallback() {
_Exit(Options.ErrorExitCode); // Stop right now.
}
-void Fuzzer::PrintStats(const char *Where, const char *End) {
+void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units) {
size_t ExecPerSec = execPerSec();
if (Options.OutputCSV) {
static bool csvHeaderPrinted = false;
@@ -337,7 +338,11 @@ void Fuzzer::PrintStats(const char *Where, const char *End) {
Printf(" bits: %zd", MaxCoverage.TPCMap.GetNumBitsSinceLastMerge());
if (MaxCoverage.CallerCalleeCoverage)
Printf(" indir: %zd", MaxCoverage.CallerCalleeCoverage);
- Printf(" units: %zd exec/s: %zd", Corpus.size(), ExecPerSec);
+ if (size_t N = Corpus.size())
+ Printf(" units: %zd", N);
+ if (Units)
+ Printf(" units: %zd", Units);
+ Printf(" exec/s: %zd", ExecPerSec);
Printf("%s", End);
}
@@ -381,9 +386,7 @@ void Fuzzer::RereadOutputCorpus(size_t MaxSize) {
X.resize(MaxSize);
if (!Corpus.HasUnit(X)) {
if (RunOne(X)) {
- uintptr_t *NewPCIDs;
- size_t NumNewPCIDs = TPC.GetNewPCIDs(&NewPCIDs);
- Corpus.AddToCorpus(X, NewPCIDs, NumNewPCIDs);
+ Corpus.AddToCorpus(X);
PrintStats("RELOAD");
}
}
@@ -406,9 +409,7 @@ void Fuzzer::ShuffleAndMinimize(UnitVector *InitialCorpus) {
for (const auto &U : *InitialCorpus) {
bool NewCoverage = RunOne(U);
if (!Options.PruneCorpus || NewCoverage) {
- uintptr_t *NewPCIDs;
- size_t NumNewPCIDs = TPC.GetNewPCIDs(&NewPCIDs);
- Corpus.AddToCorpus(U, NewPCIDs, NumNewPCIDs);
+ Corpus.AddToCorpus(U);
if (Options.Verbosity >= 2)
Printf("NEW0: %zd L %zd\n", MaxCoverage.BlockCoverage, U.size());
}
@@ -545,9 +546,7 @@ void Fuzzer::PrintNewPCs() {
void Fuzzer::ReportNewCoverage(InputInfo *II, const Unit &U) {
II->NumSuccessfullMutations++;
- uintptr_t *NewPCIDs;
- size_t NumNewPCIDs = TPC.GetNewPCIDs(&NewPCIDs);
- Corpus.AddToCorpus(U, NewPCIDs, NumNewPCIDs);
+ Corpus.AddToCorpus(U);
MD.RecordSuccessfulMutationSequence();
PrintStatusForNewUnit(U);
WriteToOutputCorpus(U);
@@ -566,6 +565,7 @@ UnitVector Fuzzer::FindExtraUnits(const UnitVector &Initial,
size_t OldSize = Res.size();
for (int Iter = 0; Iter < 10; Iter++) {
ShuffleCorpus(&Res);
+ TPC.Reset();
ResetCoverage();
for (auto &U : Initial)
@@ -578,7 +578,7 @@ UnitVector Fuzzer::FindExtraUnits(const UnitVector &Initial,
char Stat[7] = "MIN ";
Stat[3] = '0' + Iter;
- PrintStats(Stat);
+ PrintStats(Stat, "\n", Tmp.size());
size_t NewSize = Tmp.size();
assert(NewSize <= OldSize);
@@ -691,7 +691,6 @@ void Fuzzer::MutateAndTestOne() {
void Fuzzer::ResetCoverage() {
ResetEdgeCoverage();
MaxCoverage.Reset();
- TPC.Reset();
PrepareCounters(&MaxCoverage);
}
OpenPOWER on IntegriCloud