diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerTracePC.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerTracePC.h | 10 | ||||
-rw-r--r-- | llvm/lib/Fuzzer/test/fuzzer-traces-hooks.test | 2 |
3 files changed, 21 insertions, 3 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.cpp b/llvm/lib/Fuzzer/FuzzerTracePC.cpp index 07be441244c..bf2a6110e85 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.cpp +++ b/llvm/lib/Fuzzer/FuzzerTracePC.cpp @@ -309,6 +309,14 @@ static size_t InternalStrnlen2(const char *S1, const char *S2) { return Len; } +void TracePC::ClearInlineCounters() { + for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) { + uint8_t *Beg = ModuleCounters[i].Start; + size_t Size = ModuleCounters[i].Stop - Beg; + memset(Beg, 0, Size); + } +} + } // namespace fuzzer extern "C" { @@ -345,6 +353,10 @@ void __sanitizer_cov_8bit_counters_init(uint8_t *Start, uint8_t *Stop) { } ATTRIBUTE_INTERFACE +void __sanitizer_cov_pcs_init(const uint8_t *pcs_beg, const uint8_t *pcs_end) { +} + +ATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_ALL void __sanitizer_cov_trace_pc_indir(uintptr_t Callee) { uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0)); diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.h b/llvm/lib/Fuzzer/FuzzerTracePC.h index fac2b2b9cc8..28301d17b2c 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.h +++ b/llvm/lib/Fuzzer/FuzzerTracePC.h @@ -87,8 +87,11 @@ class TracePC { ValueProfileMap.Reset(); memset(Counters(), 0, GetNumPCs()); ClearExtraCounters(); + ClearInlineCounters(); } + void ClearInlineCounters(); + void UpdateFeatureSet(size_t CurrentElementIdx, size_t CurrentElementSize); void PrintFeatureSet(); @@ -201,8 +204,11 @@ void TracePC::CollectFeatures(Callback HandleFeature) const { }; size_t FirstFeature = 0; - ForEachNonZeroByte(Counters, Counters + N, FirstFeature, Handle8bitCounter); - FirstFeature += N * 8; + if (!NumInline8bitCounters) { + ForEachNonZeroByte(Counters, Counters + N, FirstFeature, Handle8bitCounter); + FirstFeature += N * 8; + } + for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) { ForEachNonZeroByte(ModuleCounters[i].Start, ModuleCounters[i].Stop, FirstFeature, Handle8bitCounter); diff --git a/llvm/lib/Fuzzer/test/fuzzer-traces-hooks.test b/llvm/lib/Fuzzer/test/fuzzer-traces-hooks.test index 77ca4b47bd0..3f9f89e461f 100644 --- a/llvm/lib/Fuzzer/test/fuzzer-traces-hooks.test +++ b/llvm/lib/Fuzzer/test/fuzzer-traces-hooks.test @@ -3,7 +3,7 @@ UNSUPPORTED: windows CHECK: BINGO -RUN: not LLVMFuzzer-MemcmpTest -seed=1 -runs=2000000 2>&1 | FileCheck %s +RUN: not LLVMFuzzer-MemcmpTest -seed=1 -runs=10000000 2>&1 | FileCheck %s RUN: not LLVMFuzzer-StrncmpTest -seed=1 -runs=2000000 2>&1 | FileCheck %s RUN: not LLVMFuzzer-StrcmpTest -seed=1 -runs=2000000 2>&1 | FileCheck %s RUN: not LLVMFuzzer-StrstrTest -seed=1 -runs=2000000 2>&1 | FileCheck %s |