[libFuzzer] be more precise about what we reset in TracePC

llvm-svn: 282225
This commit is contained in:
Kostya Serebryany 2016-09-23 02:18:59 +00:00
parent 16a145fd0f
commit ce1cab169f
2 changed files with 8 additions and 6 deletions

View File

@ -68,7 +68,6 @@ void Fuzzer::ResetCounters() {
}
if (EF->__sanitizer_get_coverage_pc_buffer_pos)
PcBufferPos = EF->__sanitizer_get_coverage_pc_buffer_pos();
TPC.ResetNewPCIDs();
}
void Fuzzer::PrepareCounters(Fuzzer::Coverage *C) {
@ -163,7 +162,8 @@ Fuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,
assert(!F);
F = this;
TPC.ResetTotalPCCoverage();
TPC.Reset();
TPC.ResetMaps();
TPC.ResetGuards();
ResetCoverage();
IsMyThread = true;
if (Options.DetectLeaks && EF->__sanitizer_install_malloc_and_free_hooks)
@ -470,6 +470,7 @@ void Fuzzer::ExecuteCallback(const uint8_t *Data, size_t Size) {
AllocTracer.Start();
UnitStartTime = system_clock::now();
ResetCounters(); // Reset coverage right before the callback.
TPC.ResetMaps();
int Res = CB(DataCopy, Size);
UnitStopTime = system_clock::now();
(void)Res;
@ -565,7 +566,8 @@ UnitVector Fuzzer::FindExtraUnits(const UnitVector &Initial,
size_t OldSize = Res.size();
for (int Iter = 0; Iter < 10; Iter++) {
ShuffleCorpus(&Res);
TPC.Reset();
TPC.ResetMaps();
TPC.ResetGuards();
ResetCoverage();
for (auto &U : Initial)

View File

@ -43,13 +43,14 @@ class TracePC {
void ResetNewPCIDs() { NumNewPCIDs = 0; }
uintptr_t GetPCbyPCID(uintptr_t PCID) { return PCs[PCID]; }
void Reset() {
void ResetMaps() {
NumNewPCIDs = 0;
CounterMap.Reset();
ValueProfileMap.Reset();
ResetGuards();
}
void ResetGuards();
void PrintModuleInfo();
void PrintCoverage();
@ -66,7 +67,6 @@ private:
NewPCIDs[(NumNewPCIDs++) % kMaxNewPCIDs] = PCID;
}
void ResetGuards();
struct Module {
uintptr_t *Start, *Stop;