[libFuzzer] don't print large artifacts to stderr
authorKostya Serebryany <kcc@google.com>
Fri, 9 Oct 2015 04:03:14 +0000 (04:03 +0000)
committerKostya Serebryany <kcc@google.com>
Fri, 9 Oct 2015 04:03:14 +0000 (04:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249808 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerLoop.cpp

index 76f65deb249855420ce0b5ac6870bfbf94137564..ec0b1176e2854fa5f004f616d3dd7446028e31de 100644 (file)
@@ -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;