[llvm] r244152 - [libFuzzer] add option -report_slow_units=Nsec to control when slow units are printed
Kostya Serebryany
kcc at google.com
Wed Aug 5 14:43:49 PDT 2015
Author: kcc
Date: Wed Aug 5 16:43:48 2015
New Revision: 244152
URL: http://llvm.org/viewvc/llvm-project?rev=244152&view=rev
Log:
[libFuzzer] add option -report_slow_units=Nsec to control when slow units are printed
Modified:
llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp
llvm/trunk/lib/Fuzzer/FuzzerFlags.def
llvm/trunk/lib/Fuzzer/FuzzerInternal.h
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
Modified: llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp?rev=244152&r1=244151&r2=244152&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerDriver.cpp Wed Aug 5 16:43:48 2015
@@ -247,6 +247,7 @@ int FuzzerDriver(int argc, char **argv,
if (Flags.sync_command)
Options.SyncCommand = Flags.sync_command;
Options.SyncTimeout = Flags.sync_timeout;
+ Options.ReportSlowUnits = Flags.report_slow_units;
Fuzzer F(USF, Options);
if (Flags.apply_tokens)
Modified: llvm/trunk/lib/Fuzzer/FuzzerFlags.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerFlags.def?rev=244152&r1=244151&r2=244152&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerFlags.def (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerFlags.def Wed Aug 5 16:43:48 2015
@@ -58,3 +58,5 @@ FUZZER_FLAG_STRING(sync_command, "Execut
"\"<sync_command> <test_corpus>\" "
"to synchronize the test corpus.")
FUZZER_FLAG_INT(sync_timeout, 600, "Minimum timeout between syncs.")
+FUZZER_FLAG_INT(report_slow_units, 10,
+ "Report slowest units if they run for more than this number of seconds.")
Modified: llvm/trunk/lib/Fuzzer/FuzzerInternal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerInternal.h?rev=244152&r1=244151&r2=244152&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerInternal.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerInternal.h Wed Aug 5 16:43:48 2015
@@ -79,6 +79,7 @@ class Fuzzer {
int PreferSmallDuringInitialShuffle = -1;
size_t MaxNumberOfRuns = ULONG_MAX;
int SyncTimeout = 600;
+ int ReportSlowUnits = 10;
std::string OutputCorpus;
std::string SyncCommand;
std::vector<std::string> Tokens;
Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=244152&r1=244151&r2=244152&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Wed Aug 5 16:43:48 2015
@@ -159,12 +159,13 @@ size_t Fuzzer::RunOne(const Unit &U) {
auto UnitStopTime = system_clock::now();
auto TimeOfUnit =
duration_cast<seconds>(UnitStopTime - UnitStartTime).count();
- if (TimeOfUnit > TimeOfLongestUnitInSeconds) {
+ if (TimeOfUnit > TimeOfLongestUnitInSeconds &&
+ TimeOfUnit >= Options.ReportSlowUnits) {
TimeOfLongestUnitInSeconds = TimeOfUnit;
- Printf("Longest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
+ Printf("Slowest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
if (U.size() <= kMaxUnitSizeToPrint)
Print(U, "\n");
- WriteUnitToFileWithPrefix(U, "long-running-unit-");
+ WriteUnitToFileWithPrefix(U, "slow-unit-");
}
return Res;
}
More information about the llvm-commits
mailing list