summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerLoop.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-01-28 23:48:39 +0000
committerKostya Serebryany <kcc@google.com>2015-01-28 23:48:39 +0000
commit265cf04f9c738f3be7a941d87eaee80d928be39e (patch)
treeb75dca4aea21f52a9af650086b596194f120dfab /llvm/lib/Fuzzer/FuzzerLoop.cpp
parent1689d3f732a410dd6a09961f0e8a9fbe0d62c4ac (diff)
downloadbcm5719-llvm-265cf04f9c738f3be7a941d87eaee80d928be39e.tar.gz
bcm5719-llvm-265cf04f9c738f3be7a941d87eaee80d928be39e.zip
[fuzzer] add option -save_minimized_corpus
llvm-svn: 227395
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerLoop.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp
index b0bfce73ffd..1f2193a45b3 100644
--- a/llvm/lib/Fuzzer/FuzzerLoop.cpp
+++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp
@@ -96,7 +96,7 @@ size_t Fuzzer::RunOne(const Unit &U) {
void Fuzzer::WriteToOutputCorpus(const Unit &U) {
if (Options.OutputCorpus.empty()) return;
- std::string Path = Options.OutputCorpus + "/" + Hash(U);
+ std::string Path = DirPlusFile(Options.OutputCorpus, Hash(U));
WriteToFile(U, Path);
if (Options.Verbosity >= 2)
std::cerr << "Written to " << Path << std::endl;
@@ -108,6 +108,15 @@ void Fuzzer::WriteToCrash(const Unit &U, const char *Prefix) {
std::cerr << "CRASHED; file written to " << Path << std::endl;
}
+void Fuzzer::SaveCorpus() {
+ if (Options.OutputCorpus.empty()) return;
+ for (const auto &U : Corpus)
+ WriteToFile(U, DirPlusFile(Options.OutputCorpus, Hash(U)));
+ if (Options.Verbosity)
+ std::cerr << "Written corpus of " << Corpus.size() << " files to "
+ << Options.OutputCorpus << "\n";
+}
+
size_t Fuzzer::MutateAndTestOne(Unit *U) {
size_t NewUnits = 0;
for (size_t i = 0; i < Options.MutateDepth; i++) {
OpenPOWER on IntegriCloud