[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
This commit is contained in:
Kostya Serebryany 2015-05-05 21:59:51 +00:00
parent cc0615ad0a
commit 605f316258
3 changed files with 8 additions and 0 deletions

View 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

View 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:

View 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() {