diff --git a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp --- a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp @@ -37,6 +37,7 @@ namespace fuzzer { static const size_t kMaxUnitSizeToPrint = 256; +static const size_t kMaxMutationsToPrint = 10; thread_local bool Fuzzer::IsMyThread; @@ -600,7 +601,11 @@ PrintStats(Text, ""); if (Options.Verbosity) { Printf(" L: %zd/%zd ", U.size(), Corpus.MaxInputSize()); - MD.PrintMutationSequence(); + int32_t maxLength = kMaxMutationsToPrint; + if (Options.Verbosity >= 2) { + maxLength = -1; + } + MD.PrintMutationSequence(maxLength); Printf("\n"); } } diff --git a/compiler-rt/lib/fuzzer/FuzzerMutate.h b/compiler-rt/lib/fuzzer/FuzzerMutate.h --- a/compiler-rt/lib/fuzzer/FuzzerMutate.h +++ b/compiler-rt/lib/fuzzer/FuzzerMutate.h @@ -24,8 +24,9 @@ ~MutationDispatcher() {} /// Indicate that we are about to start a new sequence of mutations. void StartMutationSequence(); - /// Print the current sequence of mutations. - void PrintMutationSequence(); + /// Print the current sequence (up to a length) of mutations. + /// If the maxLength is negative, print them all. + void PrintMutationSequence(int32_t maxLength = -1); /// Indicate that the current sequence of mutations was successful. void RecordSuccessfulMutationSequence(); /// Mutates data by invoking user-provided mutator. diff --git a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp --- a/compiler-rt/lib/fuzzer/FuzzerMutate.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerMutate.cpp @@ -481,15 +481,23 @@ Printf("###### End of recommended dictionary. ######\n"); } -void MutationDispatcher::PrintMutationSequence() { +void MutationDispatcher::PrintMutationSequence(int32_t maxLength) { Printf("MS: %zd ", CurrentMutatorSequence.size()); - for (auto M : CurrentMutatorSequence) - Printf("%s-", M.Name); + size_t entriesToPrint = CurrentMutatorSequence.size(); + if (maxLength > 0 && maxLength < entriesToPrint) { + entriesToPrint = maxLength; + } + for (size_t i = 0; i < entriesToPrint; i++) + Printf("%s-", CurrentMutatorSequence[i].Name); if (!CurrentDictionaryEntrySequence.empty()) { Printf(" DE: "); - for (auto DE : CurrentDictionaryEntrySequence) { + entriesToPrint = CurrentDictionaryEntrySequence.size(); + if (maxLength > 0 && maxLength < entriesToPrint) { + entriesToPrint = maxLength; + } + for (size_t i = 0; i < entriesToPrint; i++) { Printf("\""); - PrintASCII(DE->GetW(), "\"-"); + PrintASCII(CurrentDictionaryEntrySequence[i]->GetW(), "\"-"); } } }