diff options
| author | Kostya Serebryany <kcc@google.com> | 2016-02-26 22:42:23 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2016-02-26 22:42:23 +0000 |
| commit | 66ff0756e421f0d702b1eeb8debee5c8903e1540 (patch) | |
| tree | 4ce50c79e614c1333e53b1adc2c35dedaea05566 /llvm/lib/Fuzzer/FuzzerLoop.cpp | |
| parent | 4d1a0883234d00a710269bb97471d29384e9b6af (diff) | |
| download | bcm5719-llvm-66ff0756e421f0d702b1eeb8debee5c8903e1540.tar.gz bcm5719-llvm-66ff0756e421f0d702b1eeb8debee5c8903e1540.zip | |
[libFuzzer] add -print_final_stats=1 flag
llvm-svn: 262084
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerLoop.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp index 82f1828064f..f2d24ce680d 100644 --- a/llvm/lib/Fuzzer/FuzzerLoop.cpp +++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp @@ -92,6 +92,7 @@ void Fuzzer::DeathCallback() { } WriteUnitToFileWithPrefix( {CurrentUnitData, CurrentUnitData + CurrentUnitSize}, "crash-"); + PrintFinalStats(); } void Fuzzer::StaticAlarmCallback() { @@ -124,6 +125,7 @@ void Fuzzer::AlarmCallback() { if (__sanitizer_print_stack_trace) __sanitizer_print_stack_trace(); Printf("SUMMARY: libFuzzer: timeout\n"); + PrintFinalStats(); if (Options.AbortOnTimeout) abort(); exit(Options.TimeoutExitCode); @@ -131,9 +133,7 @@ void Fuzzer::AlarmCallback() { } void Fuzzer::PrintStats(const char *Where, const char *End) { - size_t Seconds = secondsSinceProcessStartUp(); - size_t ExecPerSec = (Seconds ? TotalNumberOfRuns / Seconds : 0); - + size_t ExecPerSec = execPerSec(); if (Options.OutputCSV) { static bool csvHeaderPrinted = false; if (!csvHeaderPrinted) { @@ -163,6 +163,16 @@ void Fuzzer::PrintStats(const char *Where, const char *End) { Printf("%s", End); } +void Fuzzer::PrintFinalStats() { + if (!Options.PrintFinalStats) return; + size_t ExecPerSec = execPerSec(); + Printf("stat::number_of_executed_units: %zd\n", TotalNumberOfRuns); + Printf("stat::average_exec_per_sec: %zd\n", ExecPerSec); + Printf("stat::new_units_added: %zd\n", NumberOfNewUnitsAdded); + Printf("stat::slowest_unit_time_sec: %zd\n", TimeOfLongestUnitInSeconds); + Printf("stat::peak_rss_mb: %zd\n", GetPeakRSSMb()); +} + void Fuzzer::RereadOutputCorpus() { if (Options.OutputCorpus.empty()) return; @@ -382,6 +392,7 @@ void Fuzzer::ReportNewCoverage(const Unit &U) { MD.RecordSuccessfulMutationSequence(); PrintStatusForNewUnit(U); WriteToOutputCorpus(U); + NumberOfNewUnitsAdded++; if (Options.ExitOnFirst) exit(0); } |

