Slight improvements to the software-based counters
diff --git a/fuzz.c b/fuzz.c
index 15c1f65..4264169 100644
--- a/fuzz.c
+++ b/fuzz.c
@@ -436,22 +436,28 @@
int64_t diff1 = hfuzz->linux.hwCnts.cpuBranchCnt - fuzzer->linux.hwCnts.cpuBranchCnt;
int64_t diff2 = hfuzz->linux.hwCnts.customCnt - fuzzer->linux.hwCnts.customCnt;
+ uint64_t *softCntPtr = (uint64_t *) & hfuzz->bbMap[_HF_PERF_BITMAP_SIZE];
+ uint64_t softCnt = ATOMIC_GET(softCntPtr[fuzzer->pid]);
+ ATOMIC_CLEAR(softCntPtr[fuzzer->pid]);
+
/*
* Coverage is the primary counter, the rest is secondary, and taken into consideration only
* if the coverage counter has not been changed
*/
- if (fuzzer->linux.hwCnts.newBBCnt > 0 || (diff0 < 0 || diff1 < 0 || diff2 < 0)) {
+ if (fuzzer->linux.hwCnts.newBBCnt > 0 || softCnt > 0 || diff0 < 0 || diff1 < 0 || diff2 < 0) {
LOG_I
("New file size: %zu, Perf feedback new/cur (instr,branch): %" PRIu64 "/%" PRIu64 ",%"
- PRIu64 "/%" PRIu64 ", BBcnt new/total: %" PRIu64 "/%" PRIu64, fuzzer->dynamicFileSz,
- fuzzer->linux.hwCnts.cpuInstrCnt, hfuzz->linux.hwCnts.cpuInstrCnt,
- fuzzer->linux.hwCnts.cpuBranchCnt, hfuzz->linux.hwCnts.cpuBranchCnt,
- fuzzer->linux.hwCnts.newBBCnt, hfuzz->linux.hwCnts.bbCnt);
+ PRIu64 "/%" PRIu64 "/%" PRIu64 ", BBcnt new/total: %" PRIu64 "/%" PRIu64 "/%" PRIu64,
+ fuzzer->dynamicFileSz, fuzzer->linux.hwCnts.cpuInstrCnt,
+ hfuzz->linux.hwCnts.cpuInstrCnt, fuzzer->linux.hwCnts.cpuBranchCnt, softCnt,
+ hfuzz->linux.hwCnts.cpuBranchCnt, fuzzer->linux.hwCnts.newBBCnt,
+ hfuzz->linux.hwCnts.bbCnt, hfuzz->linux.hwCnts.softCnt);
hfuzz->linux.hwCnts.cpuInstrCnt = fuzzer->linux.hwCnts.cpuInstrCnt;
hfuzz->linux.hwCnts.cpuBranchCnt = fuzzer->linux.hwCnts.cpuBranchCnt;
hfuzz->linux.hwCnts.customCnt = fuzzer->linux.hwCnts.customCnt;
hfuzz->linux.hwCnts.bbCnt += fuzzer->linux.hwCnts.newBBCnt;
+ hfuzz->linux.hwCnts.softCnt += softCnt;
fuzz_addFileToFileQLocked(hfuzz, fuzzer->dynamicFile, fuzzer->dynamicFileSz,
fuzzer->linux.hwCnts.newBBCnt);