[lib/Fuzzer] on crash print the contents of the crashy input as base64
authorKostya Serebryany <kcc@google.com>
Tue, 5 May 2015 21:59:51 +0000 (21:59 +0000)
committerKostya Serebryany <kcc@google.com>
Tue, 5 May 2015 21:59:51 +0000 (21:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236548 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerIO.cpp
lib/Fuzzer/FuzzerInternal.h
lib/Fuzzer/FuzzerLoop.cpp

index ef23d42ea53a5110fa44de550e9e560feb60030c..81f37aa3c0137b2e73959f22d4b555b16384e785 100644 (file)
@@ -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
index 77871097bd72df20add3da785e335cb092ad3833..8948e3478c56388066a96d069f580815679694c0 100644 (file)
@@ -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:
index 9dfe30b6d798532fe10b23d39c12aad68f67e5b9..3a19b22653d11d08952d6ef856a5f80e753df322 100644 (file)
@@ -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() {