[llvm] r249808 - [libFuzzer] don't print large artifacts to stderr

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 21:03:15 PDT 2015


Author: kcc
Date: Thu Oct  8 23:03:14 2015
New Revision: 249808

URL: http://llvm.org/viewvc/llvm-project?rev=249808&view=rev
Log:
[libFuzzer] don't print large artifacts to stderr

Modified:
    llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp

Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=249808&r1=249807&r2=249808&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Thu Oct  8 23:03:14 2015
@@ -48,8 +48,10 @@ void Fuzzer::StaticDeathCallback() {
 
 void Fuzzer::DeathCallback() {
   Printf("DEATH:\n");
-  Print(CurrentUnit, "\n");
-  PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
+  if (CurrentUnit.size() <= kMaxUnitSizeToPrint) {
+    Print(CurrentUnit, "\n");
+    PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
+  }
   WriteUnitToFileWithPrefix(CurrentUnit, "crash-");
 }
 
@@ -69,9 +71,10 @@ void Fuzzer::AlarmCallback() {
     Printf("ALARM: working on the last Unit for %zd seconds\n", Seconds);
     Printf("       and the timeout value is %d (use -timeout=N to change)\n",
            Options.UnitTimeoutSec);
-    if (CurrentUnit.size() <= kMaxUnitSizeToPrint)
+    if (CurrentUnit.size() <= kMaxUnitSizeToPrint) {
       Print(CurrentUnit, "\n");
-    PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
+      PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
+    }
     WriteUnitToFileWithPrefix(CurrentUnit, "timeout-");
     exit(1);
   }
@@ -164,8 +167,6 @@ size_t Fuzzer::RunOne(const Unit &U) {
       TimeOfUnit >= Options.ReportSlowUnits) {
     TimeOfLongestUnitInSeconds = TimeOfUnit;
     Printf("Slowest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
-    if (U.size() <= kMaxUnitSizeToPrint)
-      Print(U, "\n");
     WriteUnitToFileWithPrefix(U, "slow-unit-");
   }
   return Res;




More information about the llvm-commits mailing list