summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/fuzzer
diff options
context:
space:
mode:
authorMax Moroz <mmoroz@chromium.org>2018-08-06 23:14:13 +0000
committerMax Moroz <mmoroz@chromium.org>2018-08-06 23:14:13 +0000
commit84a48271d4bc4120df4cf01715bc722449686766 (patch)
treeabcaa36a019a3bbb7b7a2ed0a190e5f2bd2d3e00 /compiler-rt/lib/fuzzer
parent673269edd78453a00637799958a575498e40e524 (diff)
downloadbcm5719-llvm-84a48271d4bc4120df4cf01715bc722449686766.tar.gz
bcm5719-llvm-84a48271d4bc4120df4cf01715bc722449686766.zip
[libFuzzer] Add unstable function printing to print_unstable_stats flag
Summary: There may be cases in which a user wants to know which part of their code is unstable. We use ObservedFuncs and UnstableCounters to print at exit which of the ObservedFunctions are unstable under the -print_unstable_stats flag. Patch by Kyungtak Woo (@kevinwkt). Reviewers: Dor1s, metzman, morehouse Reviewed By: Dor1s, metzman, morehouse Subscribers: delcypher, #sanitizers, llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D50264 llvm-svn: 339081
Diffstat (limited to 'compiler-rt/lib/fuzzer')
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerTracePC.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
index 37b32b76ae1..7874f1315aa 100644
--- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
@@ -351,9 +351,21 @@ void TracePC::DumpCoverage() {
void TracePC::PrintUnstableStats() {
size_t count = 0;
- for (size_t i = 0; i < NumInline8bitCounters; i++)
- if (UnstableCounters[i].IsUnstable)
+ Printf("UNSTABLE_FUNCTIONS:\n");
+ IterateInline8bitCounters([&](int i, int j, int UnstableIdx) {
+ const PCTableEntry &TE = ModulePCTable[i].Start[j];
+ if (UnstableCounters[UnstableIdx].IsUnstable) {
count++;
+ if (ObservedFuncs.count(TE.PC)) {
+ auto VisualizePC = GetNextInstructionPc(TE.PC);
+ std::string FunctionStr = DescribePC("%F", VisualizePC);
+ if (FunctionStr.find("in ") == 0)
+ FunctionStr = FunctionStr.substr(3);
+ Printf("%s\n", FunctionStr.c_str());
+ }
+ }
+ });
+
Printf("stat::stability_rate: %.2f\n",
100 - static_cast<float>(count * 100) / NumInline8bitCounters);
}
OpenPOWER on IntegriCloud