12 #ifndef LLVM_FUZZER_TRACE_PC
13 #define LLVM_FUZZER_TRACE_PC
30 template<
class T,
size_t kSizeT>
32 static const size_t kSize = kSizeT;
37 void Insert(
size_t Idx,
const T &Arg1,
const T &Arg2) {
48 template <
size_t kSizeT>
50 static const size_t kSize = kSizeT;
54 void Add(
const uint8_t *Data,
size_t Size) {
55 if (Size <= 2)
return;
61 for (
size_t i = 0; i <
kSize; i++) {
63 if (W.
size())
return W;
79 template <
class T>
void HandleCmp(uintptr_t PC,
T Arg1,
T Arg2);
87 ValueProfileMap.
Reset();
101 size_t n,
bool StopAtZero);
119 bool UseCounters =
false;
120 bool UseValueProfile =
false;
121 bool DoPrintNewPCs =
false;
127 Module Modules[4096];
132 size_t NumModulesWithInline8bitCounters;
133 size_t NumInline8bitCounters;
135 uint8_t *Counters()
const;
136 uintptr_t *PCs()
const;
138 std::set<uintptr_t> *PrintedPCs;
143 template <
class Callback>
147 typedef uintptr_t LargeType;
148 const size_t Step =
sizeof(LargeType) /
sizeof(uint8_t);
149 const size_t StepMask = Step - 1;
152 for (;
reinterpret_cast<uintptr_t
>(
P) & StepMask &&
P < End;
P++)
157 for (;
P <
End;
P += Step)
158 if (LargeType Bundle = *reinterpret_cast<const LargeType *>(
P))
159 for (
size_t I = 0; I < Step; I++, Bundle >>= 8)
160 if (uint8_t V = Bundle & 0xff)
169 template <
class Callback>
172 void TracePC::CollectFeatures(Callback HandleFeature)
const {
174 size_t N = GetNumPCs();
179 else if (
Counter >= 32) Bit = 6;
180 else if (
Counter >= 16) Bit = 5;
181 else if (
Counter >= 8) Bit = 4;
182 else if (
Counter >= 4) Bit = 3;
183 else if (
Counter >= 3) Bit = 2;
184 else if (
Counter >= 2) Bit = 1;
185 HandleFeature(Idx * 8 + Bit);
190 FirstFeature += N * 8;
191 for (
size_t i = 0; i < NumModulesWithInline8bitCounters; i++) {
194 FirstFeature += 8 * (ModuleCounters[i].Stop - ModuleCounters[i].Start);
201 ValueProfileMap.ForEach([&](
size_t Idx) {
202 HandleFeature(N * 8 + Idx);
210 #endif // LLVM_FUZZER_TRACE_PC
ATTRIBUTE_NO_SANITIZE_ALL void ForEachNonZeroByte(const uint8_t *Begin, const uint8_t *End, size_t FirstFeature, Callback Handle8bitCounter)
void SetPrintNewPCs(bool P)
const Word & Get(size_t Idx)
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
uint8_t * ExtraCountersBegin()
void Add(const uint8_t *Data, size_t Size)
size_t SimpleFastHash(const uint8_t *Data, size_t Size)
void HandleCmp(uintptr_t PC, T Arg1, T Arg2)
static const size_t kSize
uintptr_t GetPC(size_t Idx)
__attribute__((weak)) int LLVMFuzzerInitialize(int *argc
static const size_t kNumPCs
void HandleInit(uint32_t *Start, uint32_t *Stop)
static const size_t kSize
void Set(const uint8_t *B, uint8_t S)
void UpdateFeatureSet(size_t CurrentElementIdx, size_t CurrentElementSize)
static const unsigned End
size_t GetTotalPCCoverage()
TableOfRecentCompares< Word, 32 > TORCW
ATTRIBUTE_NO_SANITIZE_ALL void Insert(size_t Idx, const T &Arg1, const T &Arg2)
void CollectFeatures(Callback CB) const
void SetUseCounters(bool UC)
void ClearExtraCounters()
ATTRIBUTE_NO_SANITIZE_ALL __attribute__((noinline)) void TracePC size_t N
#define ATTRIBUTE_NO_SANITIZE_ALL
static const size_t kTracePcBits
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static uint8_t Counters[N]
void InitializePrintNewPCs()
void HandleCallerCallee(uintptr_t Caller, uintptr_t Callee)
TableOfRecentCompares< uint64_t, 32 > TORC8
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void AddValueForMemcmp(void *caller_pc, const void *s1, const void *s2, size_t n, bool StopAtZero)
void HandleInline8bitCountersInit(uint8_t *Start, uint8_t *Stop)
void SetUseValueProfile(bool VP)
TableOfRecentCompares< uint32_t, 32 > TORC4
uint8_t * ExtraCountersEnd()
static size_t GetMaxSize()