llvm.org GIT mirror llvm / c1a030f
output_csv libfuzzer option Summary: The option outputs statistics in CSV format preceded by 1 header line. This is intended for machine processing of the output. -verbosity=0 should likely be set. Differential Revision: http://reviews.llvm.org/D14600 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252856 91177308-0d34-0410-b5e6-96231b3b80d8 Mike Aizatsky 4 years ago
4 changed file(s) with 25 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
244244 Options.OnlyASCII = Flags.only_ascii;
245245 Options.TBMDepth = Flags.tbm_depth;
246246 Options.TBMWidth = Flags.tbm_width;
247 Options.OutputCSV = Flags.output_csv;
247248 if (Flags.runs >= 0)
248249 Options.MaxNumberOfRuns = Flags.runs;
249250 if (!Inputs->empty())
6868 "$(artifact_prefix)file")
6969 FUZZER_FLAG_INT(drill, 0, "Experimental: fuzz using a single unit as the seed "
7070 "corpus, then merge with the initial corpus")
71 FUZZER_FLAG_INT(output_csv, 0, "Enable pulse output in CSV format.")
9595 std::string ArtifactPrefix = "./";
9696 bool SaveArtifacts = true;
9797 bool PrintNEW = true; // Print a status line when new units are found;
98 bool OutputCSV = false;
9899 };
99100 Fuzzer(UserSuppliedFuzzer &USF, FuzzingOptions Options);
100101 void AddToCorpus(const Unit &U) { Corpus.push_back(U); }
107107 }
108108
109109 void Fuzzer::PrintStats(const char *Where, const char *End) {
110 if (!Options.Verbosity) return;
111110 size_t Seconds = secondsSinceProcessStartUp();
112111 size_t ExecPerSec = (Seconds ? TotalNumberOfRuns / Seconds : 0);
112
113 if (Options.OutputCSV) {
114 static bool csvHeaderPrinted = false;
115 if (!csvHeaderPrinted) {
116 csvHeaderPrinted = true;
117 Printf("runs,block_cov,bits,cc_cov,corpus,execs_per_sec,tbms,reason\n");
118 }
119 Printf("%zd,%zd,%zd,%zd,%zd,%zd,%zd,%s\n", TotalNumberOfRuns,
120 LastRecordedBlockCoverage, TotalBits(),
121 LastRecordedCallerCalleeCoverage, Corpus.size(), ExecPerSec,
122 TotalNumberOfExecutedTraceBasedMutations, Where);
123 }
124
125 if (!Options.Verbosity)
126 return;
113127 Printf("#%zd\t%s", TotalNumberOfRuns, Where);
114128 if (LastRecordedBlockCoverage)
115129 Printf(" cov: %zd", LastRecordedBlockCoverage);
143157 CurrentUnit.insert(CurrentUnit.begin(), X.begin(), X.end());
144158 if (RunOne(CurrentUnit)) {
145159 Corpus.push_back(X);
146 if (Options.Verbosity >= 1)
147 PrintStats("RELOAD");
160 PrintStats("RELOAD");
148161 }
149162 }
150163 }
197210 auto UnitStopTime = system_clock::now();
198211 auto TimeOfUnit =
199212 duration_cast(UnitStopTime - UnitStartTime).count();
200 if (!(TotalNumberOfRuns & (TotalNumberOfRuns - 1))
201 && secondsSinceProcessStartUp() >= 2
202 && Options.Verbosity)
213 if (!(TotalNumberOfRuns & (TotalNumberOfRuns - 1)) &&
214 secondsSinceProcessStartUp() >= 2)
203215 PrintStats("pulse ");
204216 if (TimeOfUnit > TimeOfLongestUnitInSeconds &&
205217 TimeOfUnit >= Options.ReportSlowUnits) {
451463 SyncCorpus();
452464 RereadOutputCorpus();
453465 if (TotalNumberOfRuns >= Options.MaxNumberOfRuns)
454 return;
466 break;
455467 if (Options.MaxTotalTimeSec > 0 &&
456468 secondsSinceProcessStartUp() >
457469 static_cast(Options.MaxTotalTimeSec))
458 return;
470 break;
459471 CurrentUnit = Corpus[J1];
460472 // Optionally, cross with another unit.
461473 if (Options.DoCrossOver && USF.GetRand().RandBool()) {
475487 // Perform several mutations and runs.
476488 MutateAndTestOne(&CurrentUnit);
477489 }
490
491 PrintStats("DONE ", "\n");
478492 }
479493
480494 void Fuzzer::SyncCorpus() {