From: Kostya Serebryany Date: Tue, 5 May 2015 21:59:51 +0000 (+0000) Subject: [lib/Fuzzer] on crash print the contents of the crashy input as base64 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=605f3162583598e166c89724da86bdce8137e2ce;p=oota-llvm.git [lib/Fuzzer] on crash print the contents of the crashy input as base64 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236548 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Fuzzer/FuzzerIO.cpp b/lib/Fuzzer/FuzzerIO.cpp index ef23d42ea53..81f37aa3c01 100644 --- a/lib/Fuzzer/FuzzerIO.cpp +++ b/lib/Fuzzer/FuzzerIO.cpp @@ -60,4 +60,9 @@ std::string DirPlusFile(const std::string &DirPath, return DirPath + "/" + FileName; } +void PrintFileAsBase64(const std::string &Path) { + std::string Cmd = "base64 -w 0 < " + Path + "; echo"; + system(Cmd.c_str()); +} + } // namespace fuzzer diff --git a/lib/Fuzzer/FuzzerInternal.h b/lib/Fuzzer/FuzzerInternal.h index 77871097bd7..8948e3478c5 100644 --- a/lib/Fuzzer/FuzzerInternal.h +++ b/lib/Fuzzer/FuzzerInternal.h @@ -40,6 +40,7 @@ void Print(const Unit &U, const char *PrintAfter = ""); void PrintASCII(const Unit &U, const char *PrintAfter = ""); std::string Hash(const Unit &U); void SetTimer(int Seconds); +void PrintFileAsBase64(const std::string &Path); class Fuzzer { public: diff --git a/lib/Fuzzer/FuzzerLoop.cpp b/lib/Fuzzer/FuzzerLoop.cpp index 9dfe30b6d79..3a19b22653d 100644 --- a/lib/Fuzzer/FuzzerLoop.cpp +++ b/lib/Fuzzer/FuzzerLoop.cpp @@ -246,6 +246,8 @@ void Fuzzer::WriteToCrash(const Unit &U, const char *Prefix) { std::string Path = Prefix + Hash(U); WriteToFile(U, Path); std::cerr << "CRASHED; file written to " << Path << std::endl; + std::cerr << "Base64: "; + PrintFileAsBase64(Path); } void Fuzzer::SaveCorpus() {