diff options
author | Matt Morehouse <mascasa@google.com> | 2020-09-01 12:49:00 -0700 |
---|---|---|
committer | Matt Morehouse <mascasa@google.com> | 2020-09-01 12:49:41 -0700 |
commit | 7139736261e047e9cca030e2ee5912bf2a16f816 (patch) | |
tree | 2f132c68247bebfdfb7dfbfb05417bb43392479e | |
parent | d7e16ca28f48000d4fb3e3388d782cbd9ad02e62 (diff) | |
download | llvm-7139736261e047e9cca030e2ee5912bf2a16f816.tar.gz |
Revert "[libfuzzer] Reduce default verbosity when printing large mutation sequences"
This reverts commit 2665425908e00618074e42155ec922a37f7c9002 due to
buildbot failure.
-rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerLoop.cpp | 2 | ||||
-rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerMutate.cpp | 17 | ||||
-rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerMutate.h | 5 | ||||
-rw-r--r-- | compiler-rt/test/fuzzer/CustomMutatorWithLongSequencesTest.cpp | 40 | ||||
-rw-r--r-- | compiler-rt/test/fuzzer/fuzzer-custommutator.test | 10 |
5 files changed, 8 insertions, 66 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp index 3912656f9127..02db6d27b0a3 100644 --- a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp @@ -600,7 +600,7 @@ void Fuzzer::PrintStatusForNewUnit(const Unit &U, const char *Text) { PrintStats(Text, ""); if (Options.Verbosity) { Printf(" L: %zd/%zd ", U.size(), Corpus.MaxInputSize()); - MD.PrintMutationSequence(Options.Verbosity >= 2); + MD.PrintMutationSequence(); Printf("\n"); } } diff --git a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp index ac17d9978cc6..df9ada45bb03 100644 --- a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp @@ -18,7 +18,6 @@ namespace fuzzer { const size_t Dictionary::kMaxDictSize; -static const size_t kMaxMutationsToPrint = 10; static void PrintASCII(const Word &W, const char *PrintAfter) { PrintASCII(W.data(), W.size(), PrintAfter); @@ -482,21 +481,15 @@ void MutationDispatcher::PrintRecommendedDictionary() { Printf("###### End of recommended dictionary. ######\n"); } -void MutationDispatcher::PrintMutationSequence(bool Verbose) { +void MutationDispatcher::PrintMutationSequence() { Printf("MS: %zd ", CurrentMutatorSequence.size()); - size_t EntriesToPrint = - Verbose ? CurrentMutatorSequence.size() - : std::min(kMaxMutationsToPrint, CurrentMutatorSequence.size()); - for (size_t i = 0; i < EntriesToPrint; i++) - Printf("%s-", CurrentMutatorSequence[i].Name); + for (auto M : CurrentMutatorSequence) + Printf("%s-", M.Name); if (!CurrentDictionaryEntrySequence.empty()) { Printf(" DE: "); - EntriesToPrint = Verbose ? CurrentDictionaryEntrySequence.size() - : std::min(kMaxMutationsToPrint, - CurrentDictionaryEntrySequence.size()); - for (size_t i = 0; i < EntriesToPrint; i++) { + for (auto DE : CurrentDictionaryEntrySequence) { Printf("\""); - PrintASCII(CurrentDictionaryEntrySequence[i]->GetW(), "\"-"); + PrintASCII(DE->GetW(), "\"-"); } } } diff --git a/compiler-rt/lib/fuzzer/FuzzerMutate.h b/compiler-rt/lib/fuzzer/FuzzerMutate.h index e44621a7f114..6cbce8027624 100644 --- a/compiler-rt/lib/fuzzer/FuzzerMutate.h +++ b/compiler-rt/lib/fuzzer/FuzzerMutate.h @@ -24,9 +24,8 @@ public: ~MutationDispatcher() {} /// Indicate that we are about to start a new sequence of mutations. void StartMutationSequence(); - /// Print the current sequence of mutations. Only prints the full sequence - /// when Verbose is true. - void PrintMutationSequence(bool Verbose = true); + /// Print the current sequence of mutations. + void PrintMutationSequence(); /// Indicate that the current sequence of mutations was successful. void RecordSuccessfulMutationSequence(); /// Mutates data by invoking user-provided mutator. diff --git a/compiler-rt/test/fuzzer/CustomMutatorWithLongSequencesTest.cpp b/compiler-rt/test/fuzzer/CustomMutatorWithLongSequencesTest.cpp deleted file mode 100644 index 4c9714788f56..000000000000 --- a/compiler-rt/test/fuzzer/CustomMutatorWithLongSequencesTest.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -// Simple test for a cutom mutator that results in long sequences of mutations. -#include <assert.h> -#include <cstddef> -#include <cstdint> -#include <cstdlib> -#include <iostream> -#include <ostream> - -#include "FuzzerInterface.h" - -static volatile int Sink; - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { - assert(Data); - if (Size > 0 && Data[0] == 'H') { - Sink = 1; - if (Size > 1 && Data[1] == 'i') { - Sink = 2; - if (Size > 2 && Data[2] == '!') { - std::cout << "BINGO; Found the target, exiting\n" - << std::flush; - exit(1); - } - } - } - return 0; -} - -extern "C" size_t LLVMFuzzerCustomMutator(uint8_t *Data, size_t Size, - size_t MaxSize, unsigned int Seed) { - // Run this 25 times to generate a large mutation sequence. - for (size_t i = 0; i < 25; i++) { - LLVMFuzzerMutate(Data, Size, MaxSize); - } - return LLVMFuzzerMutate(Data, Size, MaxSize); -} diff --git a/compiler-rt/test/fuzzer/fuzzer-custommutator.test b/compiler-rt/test/fuzzer/fuzzer-custommutator.test index ddfb5bc51021..25f5fe697b43 100644 --- a/compiler-rt/test/fuzzer/fuzzer-custommutator.test +++ b/compiler-rt/test/fuzzer/fuzzer-custommutator.test @@ -11,13 +11,3 @@ LLVMFuzzerCustomMutatorWithLenControl: INFO: found LLVMFuzzerCustomMutator LLVMFuzzerCustomMutatorWithLenControl: In LLVMFuzzerCustomMutator LLVMFuzzerCustomMutatorWithLenControl: {{.*}} lim: {{[1-9][0-9]?}} {{.*}} LLVMFuzzerCustomMutatorWithLenControl: BINGO - -# sanity check: verify that we do get long lines with verbose printing on -RUN: %cpp_compiler %S/CustomMutatorWithLongSequencesTest.cpp -o %t-CustomMutatorWithLongSequencesTest -RUN: not %run %t-CustomMutatorWithLongSequencesTest -verbosity=2 2> %t-mutate-verbose-log -RUN: grep "NEW" %t-mutate-verbose-log | grep '.\{1024\}' - -# check a target that prints long mutation sequences and verifies the printed -# output does not get too large -RUN: not %run %t-CustomMutatorWithLongSequencesTest 2> %t-mutate-log -RUN: grep "NEW" %t-mutate-log | grep -v '.\{1024\}' |