| 888 | } |
| 889 | |
| 890 | void Fuzzer::Loop(std::vector<SizedFile> &CorporaFiles) { |
| 891 | auto FocusFunctionOrAuto = Options.FocusFunction; |
| 892 | DFT.Init(Options.DataFlowTrace, &FocusFunctionOrAuto, CorporaFiles, |
| 893 | MD.GetRand()); |
| 894 | TPC.SetFocusFunction(FocusFunctionOrAuto); |
| 895 | ReadAndExecuteSeedCorpora(CorporaFiles); |
| 896 | DFT.Clear(); // No need for DFT any more. |
| 897 | TPC.SetPrintNewPCs(Options.PrintNewCovPcs); |
| 898 | TPC.SetPrintNewFuncs(Options.PrintNewCovFuncs); |
| 899 | system_clock::time_point LastCorpusReload = system_clock::now(); |
| 900 | |
| 901 | TmpMaxMutationLen = |
| 902 | Min(MaxMutationLen, Max(size_t(4), Corpus.MaxInputSize())); |
| 903 | |
| 904 | while (true) { |
| 905 | auto Now = system_clock::now(); |
| 906 | if (!Options.StopFile.empty() && |
| 907 | !FileToVector(Options.StopFile, 1, false).empty()) |
| 908 | break; |
| 909 | if (duration_cast<seconds>(Now - LastCorpusReload).count() >= |
| 910 | Options.ReloadIntervalSec) { |
| 911 | RereadOutputCorpus(MaxInputLen); |
| 912 | LastCorpusReload = system_clock::now(); |
| 913 | } |
| 914 | if (TotalNumberOfRuns >= Options.MaxNumberOfRuns) |
| 915 | break; |
| 916 | if (TimedOut()) |
| 917 | break; |
| 918 | |
| 919 | // Update TmpMaxMutationLen |
| 920 | if (Options.LenControl) { |
| 921 | if (TmpMaxMutationLen < MaxMutationLen && |
| 922 | TotalNumberOfRuns - LastCorpusUpdateRun > |
| 923 | Options.LenControl * Log(TmpMaxMutationLen)) { |
| 924 | TmpMaxMutationLen = |
| 925 | Min(MaxMutationLen, TmpMaxMutationLen + Log(TmpMaxMutationLen)); |
| 926 | LastCorpusUpdateRun = TotalNumberOfRuns; |
| 927 | } |
| 928 | } else { |
| 929 | TmpMaxMutationLen = MaxMutationLen; |
| 930 | } |
| 931 | |
| 932 | // Perform several mutations and runs. |
| 933 | MutateAndTestOne(); |
| 934 | |
| 935 | PurgeAllocator(); |
| 936 | } |
| 937 | |
| 938 | PrintStats("DONE ", "\n"); |
| 939 | MD.PrintRecommendedDictionary(); |
| 940 | } |
| 941 | |
| 942 | void Fuzzer::MinimizeCrashLoop(const Unit &U) { |
| 943 | if (U.size() <= 1) |
no test coverage detected