Skip to content

Commit

Permalink
print logs periodically
Browse files Browse the repository at this point in the history
  • Loading branch information
marctrem committed Aug 20, 2024
1 parent 6009708 commit 68bd3e3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions compiler-rt/lib/fuzzer/FuzzerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
Entropic.NumberOfRarestFeatures = Options.EntropicNumberOfRarestFeatures;
Entropic.ScalePerExecTime = Options.EntropicScalePerExecTime;

Printf("INFO: Stats reporting: linear\n");

unsigned Seed = Flags.seed;
// Initialize Seed.
if (Seed == 0)
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/fuzzer/FuzzerInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class Fuzzer final {
size_t TotalNumberOfRuns = 0;
size_t NumberOfNewUnitsAdded = 0;

size_t LastSecondPrinted = 0;

size_t LastCorpusUpdateRun = 0;

bool HasMoreMallocsThanFrees = false;
Expand Down
16 changes: 14 additions & 2 deletions compiler-rt/lib/fuzzer/FuzzerLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,24 @@ void Fuzzer::RereadOutputCorpus(size_t MaxSize) {
PrintStats("RELOAD");
}

// static bool isPowerOfTwo(size_t val) {
// return !(val & (val - 1));
// }

void Fuzzer::PrintPulseAndReportSlowInput(const uint8_t *Data, size_t Size) {
this->CB;
auto TimeOfUnit =
duration_cast<seconds>(UnitStopTime - UnitStartTime).count();
if (!(TotalNumberOfRuns & (TotalNumberOfRuns - 1)) &&
secondsSinceProcessStartUp() >= 2)

// if (isPowerOfTwo(TotalNumberOfRuns) &&
// secondsSinceProcessStartUp() >= 2)

size_t secondsSinceStartup = secondsSinceProcessStartUp();
if (secondsSinceStartup >= 5 && secondsSinceStartup - LastSecondPrinted >= 5) {
LastSecondPrinted = secondsSinceStartup;
PrintStats("pulse ");
}

auto Threshhold =
static_cast<long>(static_cast<double>(TimeOfLongestUnitInSeconds) * 1.1);
if (TimeOfUnit > Threshhold && TimeOfUnit >= Options.ReportSlowUnits) {
Expand Down

0 comments on commit 68bd3e3

Please sign in to comment.