diff --git a/lib/fuzzer/index.html b/lib/fuzzer/index.html
index fc3f1fe4d2..f4c9753471 100644
--- a/lib/fuzzer/index.html
+++ b/lib/fuzzer/index.html
@@ -129,6 +129,7 @@
- Total Runs:
- Unique Runs:
+ - Coverage:
- Lowest Stack:
diff --git a/lib/fuzzer/main.js b/lib/fuzzer/main.js
index fa90d4c8dd..88485b9390 100644
--- a/lib/fuzzer/main.js
+++ b/lib/fuzzer/main.js
@@ -5,6 +5,7 @@
const domSourceText = document.getElementById("sourceText");
const domStatTotalRuns = document.getElementById("statTotalRuns");
const domStatUniqueRuns = document.getElementById("statUniqueRuns");
+ const domStatCoverage = document.getElementById("statCoverage");
const domStatLowestStack = document.getElementById("statLowestStack");
let wasm_promise = fetch("main.wasm");
@@ -112,8 +113,11 @@
function renderStats() {
const totalRuns = wasm_exports.totalRuns();
const uniqueRuns = wasm_exports.uniqueRuns();
+ const totalSourceLocations = wasm_exports.totalSourceLocations();
+ const coveredSourceLocations = wasm_exports.coveredSourceLocations();
domStatTotalRuns.innerText = totalRuns;
domStatUniqueRuns.innerText = uniqueRuns + " (" + percent(uniqueRuns, totalRuns) + "%)";
+ domStatCoverage.innerText = coveredSourceLocations + " / " + totalSourceLocations + " (" + percent(coveredSourceLocations, totalSourceLocations) + "%)";
domStatLowestStack.innerText = unwrapString(wasm_exports.lowestStack());
domSectStats.classList.remove("hidden");
diff --git a/lib/fuzzer/wasm/main.zig b/lib/fuzzer/wasm/main.zig
index adbe3e5646..4ffb7808f3 100644
--- a/lib/fuzzer/wasm/main.zig
+++ b/lib/fuzzer/wasm/main.zig
@@ -110,6 +110,17 @@ export fn lowestStack() String {
return String.init(string_result.items);
}
+export fn totalSourceLocations() usize {
+ return coverage_source_locations.items.len;
+}
+
+export fn coveredSourceLocations() usize {
+ const covered_bits = recent_coverage_update.items[@sizeOf(abi.CoverageUpdateHeader)..];
+ var count: usize = 0;
+ for (covered_bits) |byte| count += @popCount(byte);
+ return count;
+}
+
export fn totalRuns() u64 {
const header: *abi.CoverageUpdateHeader = @ptrCast(recent_coverage_update.items[0..@sizeOf(abi.CoverageUpdateHeader)]);
return header.n_runs;