summaryrefslogtreecommitdiff
path: root/lib/fuzzer/FuzzerLoop.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-12-01 19:18:38 +0000
committerKostya Serebryany <kcc@google.com>2017-12-01 19:18:38 +0000
commit470dc9637d4f767d38502b812bea863ea68beeec (patch)
tree241435e7e76b246ebe4fc6ee3402d82f40c7d111 /lib/fuzzer/FuzzerLoop.cpp
parent15710b9f14290d44e9a297f6398d3ac7b6fee1c0 (diff)
[libFuzzer] add an experimental search heuristic flag -reduce_depth
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/fuzzer/FuzzerLoop.cpp')
-rw-r--r--lib/fuzzer/FuzzerLoop.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/fuzzer/FuzzerLoop.cpp b/lib/fuzzer/FuzzerLoop.cpp
index 81e609e33..51d37c3ee 100644
--- a/lib/fuzzer/FuzzerLoop.cpp
+++ b/lib/fuzzer/FuzzerLoop.cpp
@@ -433,7 +433,7 @@ void Fuzzer::PrintPulseAndReportSlowInput(const uint8_t *Data, size_t Size) {
}
bool Fuzzer::RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile,
- InputInfo *II) {
+ InputInfo *II, bool *FoundUniqFeatures) {
if (!Size)
return false;
@@ -451,6 +451,8 @@ bool Fuzzer::RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile,
II->UniqFeatureSet.end(), Feature))
FoundUniqFeaturesOfII++;
});
+ if (FoundUniqFeatures)
+ *FoundUniqFeatures = FoundUniqFeaturesOfII;
PrintPulseAndReportSlowInput(Data, Size);
size_t NumNewFeatures = Corpus.NumFeatureUpdates() - NumUpdatesBefore;
if (NumNewFeatures) {
@@ -642,11 +644,18 @@ void Fuzzer::MutateAndTestOne() {
Size = NewSize;
II.NumExecutedMutations++;
- bool NewCov = RunOne(CurrentUnitData, Size, /*MayDeleteFile=*/true, &II);
+ bool FoundUniqFeatures = false;
+ bool NewCov = RunOne(CurrentUnitData, Size, /*MayDeleteFile=*/true, &II,
+ &FoundUniqFeatures);
+ // Printf("FUF[%d] %d\n", i, FoundUniqFeatures);
TryDetectingAMemoryLeak(CurrentUnitData, Size,
/*DuringInitialCorpusExecution*/ false);
- if (NewCov)
+ if (NewCov) {
ReportNewCoverage(&II, {CurrentUnitData, CurrentUnitData + Size});
+ break; // We will mutate this input more in the next rounds.
+ }
+ if (Options.ReduceDepth && !FoundUniqFeatures)
+ break;
}
}