diff options
Diffstat (limited to 'lib/Fuzzer/FuzzerTracePC.h')
-rw-r--r-- | lib/Fuzzer/FuzzerTracePC.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/Fuzzer/FuzzerTracePC.h b/lib/Fuzzer/FuzzerTracePC.h new file mode 100644 index 0000000000000..47280ba7faa06 --- /dev/null +++ b/lib/Fuzzer/FuzzerTracePC.h @@ -0,0 +1,37 @@ +//===- FuzzerTracePC.h - INTERNAL - Path tracer. --------*- C++ -* ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// Trace PCs. +// This module implements __sanitizer_cov_trace_pc, a callback required +// for -fsanitize-coverage=trace-pc instrumentation. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_FUZZER_TRACE_PC_H +#define LLVM_FUZZER_TRACE_PC_H + +namespace fuzzer { +struct PcCoverageMap { + static const size_t kMapSizeInBits = 65371; // Prime. + static const size_t kMapSizeInBitsAligned = 65536; // 2^16 + static const size_t kBitsInWord = (sizeof(uintptr_t) * 8); + static const size_t kMapSizeInWords = kMapSizeInBitsAligned / kBitsInWord; + + void Reset(); + inline void Update(uintptr_t Addr); + size_t MergeFrom(const PcCoverageMap &Other); + + uintptr_t Map[kMapSizeInWords] __attribute__((aligned(512))); +}; + +// Clears the current PC Map. +void PcMapResetCurrent(); +// Merges the current PC Map into the combined one, and clears the former. +size_t PcMapMergeInto(PcCoverageMap *Map); +} + +#endif |