Mike Aizatsky | 1aa501e | 2016-05-10 23:43:15 +0000 | [diff] [blame] | 1 | //===- FuzzerTracePC.h - INTERNAL - Path tracer. --------*- C++ -* ===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // Trace PCs. |
| 10 | // This module implements __sanitizer_cov_trace_pc, a callback required |
| 11 | // for -fsanitize-coverage=trace-pc instrumentation. |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_FUZZER_TRACE_PC_H |
| 15 | #define LLVM_FUZZER_TRACE_PC_H |
| 16 | |
| 17 | namespace fuzzer { |
| 18 | struct PcCoverageMap { |
| 19 | static const size_t kMapSizeInBits = 65371; // Prime. |
| 20 | static const size_t kMapSizeInBitsAligned = 65536; // 2^16 |
| 21 | static const size_t kBitsInWord = (sizeof(uintptr_t) * 8); |
| 22 | static const size_t kMapSizeInWords = kMapSizeInBitsAligned / kBitsInWord; |
| 23 | |
| 24 | void Reset(); |
| 25 | inline void Update(uintptr_t Addr); |
| 26 | size_t MergeFrom(const PcCoverageMap &Other); |
| 27 | |
| 28 | uintptr_t Map[kMapSizeInWords] __attribute__((aligned(512))); |
| 29 | }; |
| 30 | |
| 31 | // Clears the current PC Map. |
| 32 | void PcMapResetCurrent(); |
| 33 | // Merges the current PC Map into the combined one, and clears the former. |
| 34 | size_t PcMapMergeInto(PcCoverageMap *Map); |
| 35 | } |
| 36 | |
| 37 | #endif |