[PATCH] D66030: [libFuzzer] Merge: print feature coverage number as well.

Max Moroz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 13:22:31 PDT 2019


This revision was automatically updated to reflect the committed changes.
Dor1s marked 4 inline comments as done.
Closed by commit rL368617: [libFuzzer] Merge: print feature coverage number as well. (authored by Dor1s, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66030/new/

https://reviews.llvm.org/D66030

Files:
  compiler-rt/trunk/lib/fuzzer/FuzzerInternal.h
  compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
  compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp


Index: compiler-rt/trunk/lib/fuzzer/FuzzerInternal.h
===================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerInternal.h
+++ compiler-rt/trunk/lib/fuzzer/FuzzerInternal.h
@@ -98,7 +98,8 @@
   void ReportNewCoverage(InputInfo *II, const Unit &U);
   void PrintPulseAndReportSlowInput(const uint8_t *Data, size_t Size);
   void WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix);
-  void PrintStats(const char *Where, const char *End = "\n", size_t Units = 0);
+  void PrintStats(const char *Where, const char *End = "\n", size_t Units = 0,
+                  size_t Features = 0);
   void PrintStatusForNewUnit(const Unit &U, const char *Text);
   void CheckExitOnSrcPosOrItem();
 
Index: compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
===================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
+++ compiler-rt/trunk/lib/fuzzer/FuzzerLoop.cpp
@@ -319,14 +319,15 @@
   _Exit(Options.OOMExitCode); // Stop right now.
 }
 
-void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units) {
+void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units,
+                        size_t Features) {
   size_t ExecPerSec = execPerSec();
   if (!Options.Verbosity)
     return;
   Printf("#%zd\t%s", TotalNumberOfRuns, Where);
   if (size_t N = TPC.GetTotalPCCoverage())
     Printf(" cov: %zd", N);
-  if (size_t N = Corpus.NumFeatures())
+  if (size_t N = Features ? Features : Corpus.NumFeatures())
     Printf(" ft: %zd", N);
   if (!Corpus.empty()) {
     Printf(" corp: %zd", Corpus.NumActiveUnits());
Index: compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp
===================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp
+++ compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp
@@ -210,6 +210,9 @@
 
   std::ofstream OF(CFPath, std::ofstream::out | std::ofstream::app);
   Set<size_t> AllFeatures;
+  auto PrintStatsWrapper = [this, &AllFeatures](const char* Where) {
+    this->PrintStats(Where, "\n", 0, AllFeatures.size());
+  };
   Set<const TracePC::PCTableEntry *> AllPCs;
   for (size_t i = M.FirstNotProcessedFile; i < M.Files.size(); i++) {
     Fuzzer::MaybeExitGracefully();
@@ -238,9 +241,9 @@
     TPC.UpdateObservedPCs();
     // Show stats.
     if (!(TotalNumberOfRuns & (TotalNumberOfRuns - 1)))
-      PrintStats("pulse ");
+      PrintStatsWrapper("pulse ");
     if (TotalNumberOfRuns == M.NumFilesInFirstCorpus)
-      PrintStats("LOADED");
+      PrintStatsWrapper("LOADED");
     // Write the post-run marker and the coverage.
     OF << "FT " << i;
     for (size_t F : UniqFeatures)
@@ -254,7 +257,7 @@
     OF << "\n";
     OF.flush();
   }
-  PrintStats("DONE  ");
+  PrintStatsWrapper("DONE  ");
 }
 
 static void WriteNewControlFile(const std::string &CFPath,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66030.214699.patch
Type: text/x-patch
Size: 2865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190812/c9451557/attachment.bin>


More information about the llvm-commits mailing list