summaryrefslogtreecommitdiff
path: root/lib/fuzzer/FuzzerTracePC.h
diff options
context:
space:
mode:
authorMax Moroz <mmoroz@chromium.org>2018-07-16 16:01:31 +0000
committerMax Moroz <mmoroz@chromium.org>2018-07-16 16:01:31 +0000
commit45febc9161404adb6326ae66f4e052a5512d57c2 (patch)
tree64d867cf01595f41da2de4780af2ccca185a678f /lib/fuzzer/FuzzerTracePC.h
parent4e220e7fbaa478309f9cec8b2decad24ec954ef6 (diff)
[libFuzzer] Implement stat::stability_rate based on the percentage of unstable edges.
Summary: Created a -print_unstable_stats flag. When -print_unstable_stats=1, we run it 2 more times on interesting inputs poisoning unstable edges in an array. On program termination, we run PrintUnstableStats() which will print a line with a stability percentage like AFL does. Patch by Kyungtak Woo (@kevinwkt). Reviewers: metzman, Dor1s, kcc, morehouse Reviewed By: metzman, Dor1s, morehouse Subscribers: delcypher, llvm-commits, #sanitizers, kcc, morehouse, Dor1s Differential Revision: https://reviews.llvm.org/D49212 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337187 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/fuzzer/FuzzerTracePC.h')
-rw-r--r--lib/fuzzer/FuzzerTracePC.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/fuzzer/FuzzerTracePC.h b/lib/fuzzer/FuzzerTracePC.h
index d397bedf8..424c20722 100644
--- a/lib/fuzzer/FuzzerTracePC.h
+++ b/lib/fuzzer/FuzzerTracePC.h
@@ -103,6 +103,7 @@ class TracePC {
void PrintCoverage();
void DumpCoverage();
+ void PrintUnstableStats();
template<class CallBack>
void IterateCoveredFunctions(CallBack CB);
@@ -135,7 +136,17 @@ class TracePC {
void SetFocusFunction(const std::string &FuncName);
bool ObservedFocusFunction();
+ void InitializeUnstableCounters();
+ void UpdateUnstableCounters();
+
private:
+ // Value used to represent unstable edge.
+ static constexpr int16_t kUnstableCounter = -1;
+
+ // Uses 16-bit signed type to be able to accommodate any possible value from
+ // uint8_t counter and -1 constant as well.
+ int16_t UnstableCounters[kNumPCs];
+
bool UseCounters = false;
uint32_t UseValueProfileMask = false;
bool DoPrintNewPCs = false;