From 8b351cd95a38b158bb7fc20fbdaddafef7bafc8f Mon Sep 17 00:00:00 2001 From: Marcos Pividori Date: Sun, 22 Jan 2017 01:27:47 +0000 Subject: [PATCH] [libFuzzer] Portable implementation of `IsInterestingCoverageFile()`. For Posix systems and Windows, we need to consider different cases. Differential Revision: https://reviews.llvm.org/D28633 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292738 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Fuzzer/FuzzerIO.h | 2 ++ lib/Fuzzer/FuzzerIOPosix.cpp | 12 ++++++++++++ lib/Fuzzer/FuzzerIOWindows.cpp | 10 ++++++++++ lib/Fuzzer/FuzzerTracePC.cpp | 12 ------------ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/Fuzzer/FuzzerIO.h b/lib/Fuzzer/FuzzerIO.h index 15bfd3d3472..17cf2ab6ac1 100644 --- a/lib/Fuzzer/FuzzerIO.h +++ b/lib/Fuzzer/FuzzerIO.h @@ -40,6 +40,8 @@ std::string DirName(const std::string &FileName); // Returns path to a TmpDir. std::string TmpDir(); +bool IsInterestingCoverageFile(const std::string &FileName); + void DupAndCloseStderr(); void CloseStdout(); diff --git a/lib/Fuzzer/FuzzerIOPosix.cpp b/lib/Fuzzer/FuzzerIOPosix.cpp index 6d8edf6ff53..494ec9e6c83 100644 --- a/lib/Fuzzer/FuzzerIOPosix.cpp +++ b/lib/Fuzzer/FuzzerIOPosix.cpp @@ -89,6 +89,18 @@ std::string TmpDir() { return "/tmp"; } +bool IsInterestingCoverageFile(const std::string &FileName) { + if (FileName.find("compiler-rt/lib/") != std::string::npos) + return false; // sanitizer internal. + if (FileName.find("/usr/lib/") != std::string::npos) + return false; + if (FileName.find("/usr/include/") != std::string::npos) + return false; + if (FileName == "") + return false; + return true; +} + } // namespace fuzzer #endif // LIBFUZZER_POSIX diff --git a/lib/Fuzzer/FuzzerIOWindows.cpp b/lib/Fuzzer/FuzzerIOWindows.cpp index 056f0721a33..e2a67973386 100644 --- a/lib/Fuzzer/FuzzerIOWindows.cpp +++ b/lib/Fuzzer/FuzzerIOWindows.cpp @@ -279,6 +279,16 @@ std::string DirName(const std::string &FileName) { std::string TmpDir() { return "TODO: implement TmpDir"; } +bool IsInterestingCoverageFile(const std::string &FileName) { + if (FileName.find("Program Files") != std::string::npos) + return false; + if (FileName.find("compiler-rt\\lib\\") != std::string::npos) + return false; // sanitizer internal. + if (FileName == "") + return false; + return true; +} + } // namespace fuzzer #endif // LIBFUZZER_WINDOWS diff --git a/lib/Fuzzer/FuzzerTracePC.cpp b/lib/Fuzzer/FuzzerTracePC.cpp index 2e386af8404..71f4b66f8bb 100644 --- a/lib/Fuzzer/FuzzerTracePC.cpp +++ b/lib/Fuzzer/FuzzerTracePC.cpp @@ -66,18 +66,6 @@ void TracePC::HandleCallerCallee(uintptr_t Caller, uintptr_t Callee) { HandleValueProfile(Idx); } -static bool IsInterestingCoverageFile(std::string &File) { - if (File.find("compiler-rt/lib/") != std::string::npos) - return false; // sanitizer internal. - if (File.find("/usr/lib/") != std::string::npos) - return false; - if (File.find("/usr/include/") != std::string::npos) - return false; - if (File == "") - return false; - return true; -} - void TracePC::InitializePrintNewPCs() { if (!DoPrintNewPCs) return; assert(!PrintedPCs); -- 2.50.1