uint8_t *CounterPtr = &Counters[Idx % kNumCounters];
uint8_t Counter = *CounterPtr;
if (Counter == 0) {
- if (!PCs[Idx]) {
+ if (!PCs[Idx % kNumPCs]) {
AddNewPCID(Idx);
TotalPCCoverage++;
- PCs[Idx] = PC;
+ PCs[Idx % kNumPCs] = PC;
}
}
if (UseCounters) {
__attribute__((visibility("default")))
void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases) {
- // TODO(kcc): support value profile here.
+ uint64_t N = Cases[0];
+ uint64_t *Vals = Cases + 2;
+ char *PC = (char*)__builtin_return_address(0);
+ for (size_t i = 0; i < N; i++)
+ if (Val != Vals[i])
+ fuzzer::AddValueForCmp(PC + i, Val, Vals[i]);
}
__attribute__((visibility("default")))
static const size_t kNumCounters = 1 << 14;
alignas(8) uint8_t Counters[kNumCounters];
- static const size_t kNumPCs = 1 << 20;
+ static const size_t kNumPCs = 1 << 24;
uintptr_t PCs[kNumPCs];
ValueBitMap ValueProfileMap;