summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2019-05-10 00:59:32 +0000
committerKostya Serebryany <kcc@google.com>2019-05-10 00:59:32 +0000
commitda96d92175f716ba2dd219f937bb26bdea126cbc (patch)
treeb81c5be9c2b30e9015f293f87b7c4f6462b470a0 /compiler-rt/lib/fuzzer/FuzzerDriver.cpp
parent2f67cbb62c988d50a3552f4b11cc5b8b4031d093 (diff)
downloadbcm5719-llvm-da96d92175f716ba2dd219f937bb26bdea126cbc.tar.gz
bcm5719-llvm-da96d92175f716ba2dd219f937bb26bdea126cbc.zip
[libFuzzer] small refactoring in the driver; dummy implementation of collect_data_flow; attempt to fix the windows bot
llvm-svn: 360399
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerDriver.cpp')
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerDriver.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerDriver.cpp b/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
index b9c89274703..7a963ad6668 100644
--- a/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
@@ -561,6 +561,29 @@ int AnalyzeDictionary(Fuzzer *F, const Vector<Unit>& Dict,
return 0;
}
+Vector<std::string> ParseSeedInuts(const char *seed_inputs) {
+ // Parse -seed_inputs=file1,file2,... or -seed_inputs=@seed_inputs_file
+ Vector<std::string> Files;
+ if (!seed_inputs) return Files;
+ std::string SeedInputs;
+ if (Flags.seed_inputs[0] == '@')
+ SeedInputs = FileToString(Flags.seed_inputs + 1); // File contains list.
+ else
+ SeedInputs = Flags.seed_inputs; // seed_inputs contains the list.
+ if (SeedInputs.empty()) {
+ Printf("seed_inputs is empty or @file does not exist.\n");
+ exit(1);
+ }
+ // Parse SeedInputs.
+ size_t comma_pos = 0;
+ while ((comma_pos = SeedInputs.find_last_of(',')) != std::string::npos) {
+ Files.push_back(SeedInputs.substr(comma_pos + 1));
+ SeedInputs = SeedInputs.substr(0, comma_pos);
+ }
+ Files.push_back(SeedInputs);
+ return Files;
+}
+
int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
using namespace fuzzer;
assert(argc && argv && "Argument pointers cannot be nullptr");
@@ -663,6 +686,8 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
Options.FeaturesDir = Flags.features_dir;
Options.LazyCounters = Flags.lazy_counters;
+ auto ExtraSeedFiles = ParseSeedInuts(Flags.seed_inputs);
+
unsigned Seed = Flags.seed;
// Initialize Seed.
if (Seed == 0)
@@ -671,6 +696,10 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
if (Flags.verbosity)
Printf("INFO: Seed: %u\n", Seed);
+ if (Flags.collect_data_flow)
+ return CollectDataFlow(Flags.collect_data_flow, Flags.data_flow_trace,
+ *Inputs, ExtraSeedFiles);
+
Random Rand(Seed);
auto *MD = new MutationDispatcher(Rand, Options);
auto *Corpus = new InputCorpus(Options.OutputCorpus);
@@ -763,27 +792,6 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
exit(0);
}
- // Parse -seed_inputs=file1,file2,... or -seed_inputs=@seed_inputs_file
- Vector<std::string> ExtraSeedFiles;
- if (Flags.seed_inputs) {
- std::string SeedInputs;
- if (Flags.seed_inputs[0] == '@')
- SeedInputs = FileToString(Flags.seed_inputs + 1); // File contains list.
- else
- SeedInputs = Flags.seed_inputs; // seed_inputs contains the list.
- if (SeedInputs.empty()) {
- Printf("seed_inputs is empty or @file does not exist.\n");
- exit(1);
- }
- // Parse SeedInputs.
- size_t comma_pos = 0;
- while ((comma_pos = SeedInputs.find_last_of(',')) != std::string::npos) {
- ExtraSeedFiles.push_back(SeedInputs.substr(comma_pos + 1));
- SeedInputs = SeedInputs.substr(0, comma_pos);
- }
- ExtraSeedFiles.push_back(SeedInputs);
- }
-
F->Loop(*Inputs, ExtraSeedFiles);
if (Flags.verbosity)
OpenPOWER on IntegriCloud