diff --git a/lib/Fuzzer/FuzzerLoop.cpp b/lib/Fuzzer/FuzzerLoop.cpp index 8c8afeab8b5..1336f5e4aee 100644 --- a/lib/Fuzzer/FuzzerLoop.cpp +++ b/lib/Fuzzer/FuzzerLoop.cpp @@ -764,6 +764,7 @@ void Fuzzer::ResetCoverage() { } void Fuzzer::Loop() { + TPC.InitializePrintNewPCs(); system_clock::time_point LastCorpusReload = system_clock::now(); if (Options.DoCrossOver) MD.SetCorpus(&Corpus); diff --git a/lib/Fuzzer/FuzzerTracePC.cpp b/lib/Fuzzer/FuzzerTracePC.cpp index ad5f9f09d1e..01c0b8c2ddb 100644 --- a/lib/Fuzzer/FuzzerTracePC.cpp +++ b/lib/Fuzzer/FuzzerTracePC.cpp @@ -79,14 +79,19 @@ static bool IsInterestingCoverageFile(std::string &File) { return true; } +void TracePC::InitializePrintNewPCs() { + assert(!PrintedPCs); + PrintedPCs = new std::set; + for (size_t i = 1; i < GetNumPCs(); i++) + if (PCs[i]) + PrintedPCs->insert(PCs[i]); +} + void TracePC::PrintNewPCs() { - if (DoPrintNewPCs) { - if (!PrintedPCs) - PrintedPCs = new std::set; - for (size_t i = 1; i < GetNumPCs(); i++) - if (PCs[i] && PrintedPCs->insert(PCs[i]).second) - PrintPC("\tNEW_PC: %p %F %L\n", "\tNEW_PC: %p\n", PCs[i]); - } + assert(PrintedPCs); + for (size_t i = 1; i < GetNumPCs(); i++) + if (PCs[i] && PrintedPCs->insert(PCs[i]).second) + PrintPC("\tNEW_PC: %p %F %L\n", "\tNEW_PC: %p\n", PCs[i]); } void TracePC::PrintCoverage() { diff --git a/lib/Fuzzer/FuzzerTracePC.h b/lib/Fuzzer/FuzzerTracePC.h index 68827f80cbd..b6b26b6c9af 100644 --- a/lib/Fuzzer/FuzzerTracePC.h +++ b/lib/Fuzzer/FuzzerTracePC.h @@ -85,6 +85,7 @@ class TracePC { TableOfRecentCompares TORC8; void PrintNewPCs(); + void InitializePrintNewPCs(); size_t GetNumPCs() const { return Min(kNumPCs, NumGuards + 1); } uintptr_t GetPC(size_t Idx) { assert(Idx < GetNumPCs());