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