| 139 | } |
| 140 | |
| 141 | Fuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD, |
| 142 | const FuzzingOptions &Options) |
| 143 | : CB(CB), Corpus(Corpus), MD(MD), Options(Options) { |
| 144 | if (EF->__sanitizer_set_death_callback) |
| 145 | EF->__sanitizer_set_death_callback(StaticDeathCallback); |
| 146 | if (EF->__sanitizer_set_crash_callback) |
| 147 | EF->__sanitizer_set_crash_callback(StaticCrashSignalCallback); |
| 148 | if (EF->LLVMFuzzerPassStats) |
| 149 | EF->LLVMFuzzerPassStats(&TotalNumberOfRuns, &NumberOfNewUnitsAdded, &LastCorpusUpdateRun); |
| 150 | assert(!F); |
| 151 | F = this; |
| 152 | TPC.ResetMaps(); |
| 153 | IsMyThread = true; |
| 154 | if (Options.DetectLeaks && EF->__sanitizer_install_malloc_and_free_hooks) |
| 155 | EF->__sanitizer_install_malloc_and_free_hooks(MallocHook, FreeHook); |
| 156 | TPC.SetUseCounters(Options.UseCounters); |
| 157 | TPC.SetUseValueProfileMask(Options.UseValueProfile); |
| 158 | |
| 159 | if (Options.Verbosity) |
| 160 | TPC.PrintModuleInfo(); |
| 161 | if (!Options.OutputCorpus.empty() && Options.ReloadIntervalSec) |
| 162 | EpochOfLastReadOfOutputCorpus = GetEpoch(Options.OutputCorpus); |
| 163 | MaxInputLen = MaxMutationLen = Options.MaxLen; |
| 164 | TmpMaxMutationLen = 0; // Will be set once we load the corpus. |
| 165 | AllocateCurrentUnitData(); |
| 166 | CurrentUnitSize = 0; |
| 167 | memset(BaseSha1, 0, sizeof(BaseSha1)); |
| 168 | } |
| 169 | |
| 170 | void Fuzzer::AllocateCurrentUnitData() { |
| 171 | if (CurrentUnitData || MaxInputLen == 0) |
nothing calls this directly
no test coverage detected