diff --git a/lib/Fuzzer/FuzzerCrossOver.cpp b/lib/Fuzzer/FuzzerCrossOver.cpp index 8f2b8f409be..e86e23f81f0 100644 --- a/lib/Fuzzer/FuzzerCrossOver.cpp +++ b/lib/Fuzzer/FuzzerCrossOver.cpp @@ -11,7 +11,7 @@ #include -#include "FuzzerInternal.h" +#include "FuzzerDefs.h" #include "FuzzerMutate.h" #include "FuzzerRandom.h" diff --git a/lib/Fuzzer/FuzzerDefs.h b/lib/Fuzzer/FuzzerDefs.h index 9f47ecec609..fa8ef57d70a 100644 --- a/lib/Fuzzer/FuzzerDefs.h +++ b/lib/Fuzzer/FuzzerDefs.h @@ -11,6 +11,7 @@ #ifndef LLVM_FUZZER_DEFS_H #define LLVM_FUZZER_DEFS_H +#include #include #include #include @@ -39,6 +40,12 @@ class Random; class Dictionary; class DictionaryEntry; class MutationDispatcher; +struct FuzzingOptions; +class InputCorpus; +struct ExternalFunctions; + +// Global interface to functions that may or may not be available. +extern ExternalFunctions *EF; typedef std::vector Unit; typedef std::vector UnitVector; diff --git a/lib/Fuzzer/FuzzerDictionary.h b/lib/Fuzzer/FuzzerDictionary.h index 3b5457bb8fe..821cf9bd001 100644 --- a/lib/Fuzzer/FuzzerDictionary.h +++ b/lib/Fuzzer/FuzzerDictionary.h @@ -12,6 +12,9 @@ #ifndef LLVM_FUZZER_DICTIONARY_H #define LLVM_FUZZER_DICTIONARY_H +#include +#include + #include "FuzzerDefs.h" namespace fuzzer { diff --git a/lib/Fuzzer/FuzzerIO.cpp b/lib/Fuzzer/FuzzerIO.cpp index 5b394b641a3..e956b3eb91e 100644 --- a/lib/Fuzzer/FuzzerIO.cpp +++ b/lib/Fuzzer/FuzzerIO.cpp @@ -9,7 +9,7 @@ // IO functions. //===----------------------------------------------------------------------===// #include "FuzzerExtFunctions.h" -#include "FuzzerInternal.h" +#include "FuzzerDefs.h" #include #include #include diff --git a/lib/Fuzzer/FuzzerInternal.h b/lib/Fuzzer/FuzzerInternal.h index 7b774d303ab..aab01692f09 100644 --- a/lib/Fuzzer/FuzzerInternal.h +++ b/lib/Fuzzer/FuzzerInternal.h @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -24,6 +23,7 @@ #include "FuzzerDefs.h" #include "FuzzerExtFunctions.h" #include "FuzzerInterface.h" +#include "FuzzerOptions.h" #include "FuzzerValueBitMap.h" #include "FuzzerCorpus.h" // TODO(kcc): remove this from here. @@ -35,40 +35,6 @@ using namespace std::chrono; void EnableValueProfile(); size_t VPMapMergeFromCurrent(ValueBitMap &M); -struct FuzzingOptions { - int Verbosity = 1; - size_t MaxLen = 0; - int UnitTimeoutSec = 300; - int TimeoutExitCode = 77; - int ErrorExitCode = 77; - int MaxTotalTimeSec = 0; - int RssLimitMb = 0; - bool DoCrossOver = true; - int MutateDepth = 5; - bool UseCounters = false; - bool UseIndirCalls = true; - bool UseMemcmp = true; - bool UseMemmem = true; - bool UseFullCoverageSet = false; - bool Reload = true; - bool ShuffleAtStartUp = true; - bool PreferSmall = true; - size_t MaxNumberOfRuns = ULONG_MAX; - int ReportSlowUnits = 10; - bool OnlyASCII = false; - std::string OutputCorpus; - std::string ArtifactPrefix = "./"; - std::string ExactArtifactPath; - bool SaveArtifacts = true; - bool PrintNEW = true; // Print a status line when new units are found; - bool OutputCSV = false; - bool PrintNewCovPcs = false; - bool PrintFinalStats = false; - bool PrintCoverage = false; - bool DetectLeaks = true; - bool PruneCorpus = true; -}; - class Fuzzer { public: @@ -226,9 +192,6 @@ private: bool InMergeMode = false; }; -// Global interface to functions that may or may not be available. -extern ExternalFunctions *EF; - }; // namespace fuzzer #endif // LLVM_FUZZER_INTERNAL_H diff --git a/lib/Fuzzer/FuzzerMutate.cpp b/lib/Fuzzer/FuzzerMutate.cpp index 2a356df1c8b..b243aa653c3 100644 --- a/lib/Fuzzer/FuzzerMutate.cpp +++ b/lib/Fuzzer/FuzzerMutate.cpp @@ -10,9 +10,13 @@ //===----------------------------------------------------------------------===// #include +#include -#include "FuzzerInternal.h" +#include "FuzzerCorpus.h" +#include "FuzzerDefs.h" +#include "FuzzerExtFunctions.h" #include "FuzzerMutate.h" +#include "FuzzerOptions.h" namespace fuzzer { diff --git a/lib/Fuzzer/FuzzerMutate.h b/lib/Fuzzer/FuzzerMutate.h index dcb2b19ba53..f8611a77124 100644 --- a/lib/Fuzzer/FuzzerMutate.h +++ b/lib/Fuzzer/FuzzerMutate.h @@ -106,7 +106,7 @@ private: size_t ToSize); Random &Rand; - const FuzzingOptions Options; + const FuzzingOptions &Options; // Dictionary provided by the user via -dict=DICT_FILE. Dictionary ManualDictionary; diff --git a/lib/Fuzzer/FuzzerOptions.h b/lib/Fuzzer/FuzzerOptions.h new file mode 100644 index 00000000000..fc8141caca9 --- /dev/null +++ b/lib/Fuzzer/FuzzerOptions.h @@ -0,0 +1,55 @@ +//===- FuzzerOptions.h - Internal header for the Fuzzer ---------*- C++ -* ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// fuzzer::FuzzingOptions +//===----------------------------------------------------------------------===// + +#ifndef LLVM_FUZZER_OPTIONS_H +#define LLVM_FUZZER_OPTIONS_H + +#include "FuzzerDefs.h" + +namespace fuzzer { + +struct FuzzingOptions { + int Verbosity = 1; + size_t MaxLen = 0; + int UnitTimeoutSec = 300; + int TimeoutExitCode = 77; + int ErrorExitCode = 77; + int MaxTotalTimeSec = 0; + int RssLimitMb = 0; + bool DoCrossOver = true; + int MutateDepth = 5; + bool UseCounters = false; + bool UseIndirCalls = true; + bool UseMemcmp = true; + bool UseMemmem = true; + bool UseFullCoverageSet = false; + bool Reload = true; + bool ShuffleAtStartUp = true; + bool PreferSmall = true; + size_t MaxNumberOfRuns = -1L; + int ReportSlowUnits = 10; + bool OnlyASCII = false; + std::string OutputCorpus; + std::string ArtifactPrefix = "./"; + std::string ExactArtifactPath; + bool SaveArtifacts = true; + bool PrintNEW = true; // Print a status line when new units are found; + bool OutputCSV = false; + bool PrintNewCovPcs = false; + bool PrintFinalStats = false; + bool PrintCoverage = false; + bool DetectLeaks = true; + bool PruneCorpus = true; +}; + +} // namespace fuzzer + +#endif // LLVM_FUZZER_OPTIONS_H