//===- FuzzerTracePC.h - Internal header for the Fuzzer ---------*- C++ -* ===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // fuzzer::TracePC //===----------------------------------------------------------------------===// #ifndef LLVM_FUZZER_TRACE_PC #define LLVM_FUZZER_TRACE_PC #include "FuzzerDefs.h" #include "FuzzerDictionary.h" #include "FuzzerValueBitMap.h" #include <set> #include <unordered_map> namespace fuzzer { // TableOfRecentCompares (TORC) remembers the most recently performed // comparisons of type T. // We record the arguments of CMP instructions in this table unconditionally // because it seems cheaper this way than to compute some expensive // conditions inside __sanitizer_cov_trace_cmp*. // After the unit has been executed we may decide to use the contents of // this table to populate a Dictionary. template<class T, size_t kSizeT> struct TableOfRecentCompares { … }; template <size_t kSizeT> struct MemMemTable { … }; class TracePC { … }; template <class Callback> // void Callback(size_t FirstFeature, size_t Idx, uint8_t Value); ATTRIBUTE_NO_SANITIZE_ALL size_t ForEachNonZeroByte(const uint8_t *Begin, const uint8_t *End, size_t FirstFeature, Callback Handle8bitCounter) { … } // Given a non-zero Counter returns a number in the range [0,7]. template<class T> unsigned CounterToFeature(T Counter) { … } template <class Callback> // void Callback(uint32_t Feature) ATTRIBUTE_NO_SANITIZE_ADDRESS ATTRIBUTE_NOINLINE size_t TracePC::CollectFeatures(Callback HandleFeature) const { … } extern TracePC TPC; } // namespace fuzzer #endif // LLVM_FUZZER_TRACE_PC