[llvm] r282047 - [libFuzzer] more refactoring; NFC
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 20 19:05:40 PDT 2016
Author: kcc
Date: Tue Sep 20 21:05:39 2016
New Revision: 282047
URL: http://llvm.org/viewvc/llvm-project?rev=282047&view=rev
Log:
[libFuzzer] more refactoring; NFC
Added:
llvm/trunk/lib/Fuzzer/FuzzerOptions.h
Modified:
llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp
llvm/trunk/lib/Fuzzer/FuzzerDefs.h
llvm/trunk/lib/Fuzzer/FuzzerDictionary.h
llvm/trunk/lib/Fuzzer/FuzzerIO.cpp
llvm/trunk/lib/Fuzzer/FuzzerInternal.h
llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp
llvm/trunk/lib/Fuzzer/FuzzerMutate.h
Modified: llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp?rev=282047&r1=282046&r2=282047&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerCrossOver.cpp Tue Sep 20 21:05:39 2016
@@ -11,7 +11,7 @@
#include <cstring>
-#include "FuzzerInternal.h"
+#include "FuzzerDefs.h"
#include "FuzzerMutate.h"
#include "FuzzerRandom.h"
Modified: llvm/trunk/lib/Fuzzer/FuzzerDefs.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerDefs.h?rev=282047&r1=282046&r2=282047&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerDefs.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerDefs.h Tue Sep 20 21:05:39 2016
@@ -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;
Modified: llvm/trunk/lib/Fuzzer/FuzzerDictionary.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerDictionary.h?rev=282047&r1=282046&r2=282047&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerDictionary.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerDictionary.h Tue Sep 20 21:05:39 2016
@@ -12,6 +12,9 @@
#ifndef LLVM_FUZZER_DICTIONARY_H
#define LLVM_FUZZER_DICTIONARY_H
+#include <algorithm>
+#include <limits>
+
#include "FuzzerDefs.h"
namespace fuzzer {
Modified: llvm/trunk/lib/Fuzzer/FuzzerIO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerIO.cpp?rev=282047&r1=282046&r2=282047&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerIO.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerIO.cpp Tue Sep 20 21:05:39 2016
@@ -9,7 +9,7 @@
// IO functions.
//===----------------------------------------------------------------------===//
#include "FuzzerExtFunctions.h"
-#include "FuzzerInternal.h"
+#include "FuzzerDefs.h"
#include <iterator>
#include <fstream>
#include <dirent.h>
Modified: llvm/trunk/lib/Fuzzer/FuzzerInternal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerInternal.h?rev=282047&r1=282046&r2=282047&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerInternal.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerInternal.h Tue Sep 20 21:05:39 2016
@@ -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
Modified: llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp?rev=282047&r1=282046&r2=282047&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerMutate.cpp Tue Sep 20 21:05:39 2016
@@ -10,9 +10,13 @@
//===----------------------------------------------------------------------===//
#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 {
Modified: llvm/trunk/lib/Fuzzer/FuzzerMutate.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerMutate.h?rev=282047&r1=282046&r2=282047&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerMutate.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerMutate.h Tue Sep 20 21:05:39 2016
@@ -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;
Added: llvm/trunk/lib/Fuzzer/FuzzerOptions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerOptions.h?rev=282047&view=auto
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerOptions.h (added)
+++ llvm/trunk/lib/Fuzzer/FuzzerOptions.h Tue Sep 20 21:05:39 2016
@@ -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
More information about the llvm-commits
mailing list