[libFuzzer] cleaner implementation of -print_pcs=1

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290739 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kostya Serebryany 2016-12-30 01:13:07 +00:00
parent 4f67d55a96
commit f178652c93
3 changed files with 14 additions and 7 deletions

View File

@ -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);

View File

@ -79,14 +79,19 @@ static bool IsInterestingCoverageFile(std::string &File) {
return true;
}
void TracePC::InitializePrintNewPCs() {
assert(!PrintedPCs);
PrintedPCs = new std::set<uintptr_t>;
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<uintptr_t>;
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() {

View File

@ -85,6 +85,7 @@ class TracePC {
TableOfRecentCompares<uint64_t, kTORCSize> TORC8;
void PrintNewPCs();
void InitializePrintNewPCs();
size_t GetNumPCs() const { return Min(kNumPCs, NumGuards + 1); }
uintptr_t GetPC(size_t Idx) {
assert(Idx < GetNumPCs());