]> granicus.if.org Git - llvm/commitdiff
[libFuzzer] more refactoring; NFC
authorKostya Serebryany <kcc@google.com>
Wed, 21 Sep 2016 02:05:39 +0000 (02:05 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 21 Sep 2016 02:05:39 +0000 (02:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282047 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerCrossOver.cpp
lib/Fuzzer/FuzzerDefs.h
lib/Fuzzer/FuzzerDictionary.h
lib/Fuzzer/FuzzerIO.cpp
lib/Fuzzer/FuzzerInternal.h
lib/Fuzzer/FuzzerMutate.cpp
lib/Fuzzer/FuzzerMutate.h
lib/Fuzzer/FuzzerOptions.h [new file with mode: 0644]

index 8f2b8f409be048735efd481e984c0f891b506d62..e86e23f81f04c391345761a409c1860ebad3a5bb 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <cstring>
 
-#include "FuzzerInternal.h"
+#include "FuzzerDefs.h"
 #include "FuzzerMutate.h"
 #include "FuzzerRandom.h"
 
index 9f47ecec60978bd2ba8ff5dc27493c4644b8bd1b..fa8ef57d70a68b7ed55bda76db9f919ee60c4c34 100644 (file)
@@ -11,6 +11,7 @@
 #ifndef LLVM_FUZZER_DEFS_H
 #define LLVM_FUZZER_DEFS_H
 
+#include <cassert>
 #include <cstddef>
 #include <cstdint>
 #include <string>
@@ -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<uint8_t> Unit;
 typedef std::vector<Unit> UnitVector;
index 3b5457bb8fe69547139f73da49c8ed75494f275e..821cf9bd0016db7fadb911ff4f3219776a059cf4 100644 (file)
@@ -12,6 +12,9 @@
 #ifndef LLVM_FUZZER_DICTIONARY_H
 #define LLVM_FUZZER_DICTIONARY_H
 
+#include <algorithm>
+#include <limits>
+
 #include "FuzzerDefs.h"
 
 namespace fuzzer {
index 5b394b641a3acac4e078a99e81ec19ee92351f4f..e956b3eb91e8284fe06cb44121ae72feda16ed37 100644 (file)
@@ -9,7 +9,7 @@
 // IO functions.
 //===----------------------------------------------------------------------===//
 #include "FuzzerExtFunctions.h"
-#include "FuzzerInternal.h"
+#include "FuzzerDefs.h"
 #include <iterator>
 #include <fstream>
 #include <dirent.h>
index 7b774d303ab739152a137bc99946c989412e4b5f..aab01692f09b6957c826a0af09f57724375d1f98 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <algorithm>
 #include <atomic>
-#include <cassert>
 #include <chrono>
 #include <climits>
 #include <cstdlib>
@@ -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
index 2a356df1c8b4ed58f6b483a9fb7ab2169f12d3b2..b243aa653c34a8f4cddd34418290b8d997f12444 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include <cstring>
+#include <unordered_set>
 
-#include "FuzzerInternal.h"
+#include "FuzzerCorpus.h"
+#include "FuzzerDefs.h"
+#include "FuzzerExtFunctions.h"
 #include "FuzzerMutate.h"
+#include "FuzzerOptions.h"
 
 namespace fuzzer {
 
index dcb2b19ba535d90b0a95c5ccf6c694e6b11cae5b..f8611a77124e915a5c424a5b049a21fdf164b358 100644 (file)
@@ -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 (file)
index 0000000..fc8141c
--- /dev/null
@@ -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