[compiler-rt] r360399 - [libFuzzer] small refactoring in the driver; dummy implementation of collect_data_flow; attempt to fix the windows bot
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Thu May 9 17:59:32 PDT 2019
Author: kcc
Date: Thu May 9 17:59:32 2019
New Revision: 360399
URL: http://llvm.org/viewvc/llvm-project?rev=360399&view=rev
Log:
[libFuzzer] small refactoring in the driver; dummy implementation of collect_data_flow; attempt to fix the windows bot
Modified:
compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.cpp
compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.h
compiler-rt/trunk/lib/fuzzer/FuzzerDriver.cpp
compiler-rt/trunk/lib/fuzzer/FuzzerFlags.def
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.cpp?rev=360399&r1=360398&r2=360399&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.cpp Thu May 9 17:59:32 2019
@@ -14,6 +14,7 @@
#include <cstdlib>
#include <fstream>
+#include <numeric>
#include <sstream>
#include <string>
#include <vector>
@@ -195,5 +196,13 @@ void DataFlowTrace::Init(const std::stri
NumTraceFiles, NumFunctions, NumTracesWithFocusFunction);
}
+int CollectDataFlow(const std::string &DFTBinary, const std::string &DirPath,
+ const Vector<std::string> &CorpusDirs,
+ const Vector<std::string> &ExtraSeeds) {
+ Printf("INFO: collecting data flow. DFTBinary: %s DirPath: %s\n",
+ DFTBinary.c_str(), DirPath.c_str());
+ return 0;
+}
+
} // namespace fuzzer
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.h?rev=360399&r1=360398&r2=360399&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.h (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerDataFlowTrace.h Thu May 9 17:59:32 2019
@@ -36,6 +36,10 @@
namespace fuzzer {
+int CollectDataFlow(const std::string &DFTBinary, const std::string &DirPath,
+ const Vector<std::string> &CorpusDirs,
+ const Vector<std::string> &ExtraSeeds);
+
class BlockCoverage {
public:
bool AppendCoverage(std::istream &IN);
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerDriver.cpp?rev=360399&r1=360398&r2=360399&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerDriver.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerDriver.cpp Thu May 9 17:59:32 2019
@@ -561,6 +561,29 @@ int AnalyzeDictionary(Fuzzer *F, const V
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
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
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
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)
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerFlags.def
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerFlags.def?rev=360399&r1=360398&r2=360399&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerFlags.def (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerFlags.def Thu May 9 17:59:32 2019
@@ -158,3 +158,5 @@ FUZZER_FLAG_STRING(focus_function, "Expe
FUZZER_FLAG_INT(analyze_dict, 0, "Experimental")
FUZZER_DEPRECATED_FLAG(use_clang_coverage)
FUZZER_FLAG_STRING(data_flow_trace, "Experimental: use the data flow trace")
+FUZZER_FLAG_STRING(collect_data_flow,
+ "Experimental: collect the data flow trace")
More information about the llvm-commits
mailing list