diff options
| author | Marcos Pividori <mpividori@google.com> | 2017-01-22 01:27:47 +0000 |
|---|---|---|
| committer | Marcos Pividori <mpividori@google.com> | 2017-01-22 01:27:47 +0000 |
| commit | 60cc2fbba11aa2f856049cd81bc4c7275ba94da5 (patch) | |
| tree | 9b666070b7145ca80f77cf6af9b80695909f8948 /llvm/lib/Fuzzer | |
| parent | 403007e3c11f482e4465e8d67b87dd11f886e868 (diff) | |
| download | bcm5719-llvm-60cc2fbba11aa2f856049cd81bc4c7275ba94da5.tar.gz bcm5719-llvm-60cc2fbba11aa2f856049cd81bc4c7275ba94da5.zip | |
[libFuzzer] Portable implementation of `IsInterestingCoverageFile()`.
For Posix systems and Windows, we need to consider different cases.
Differential Revision: https://reviews.llvm.org/D28633
llvm-svn: 292738
Diffstat (limited to 'llvm/lib/Fuzzer')
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerIO.h | 2 | ||||
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerIOPosix.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerIOWindows.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerTracePC.cpp | 12 |
4 files changed, 24 insertions, 12 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerIO.h b/llvm/lib/Fuzzer/FuzzerIO.h index 15bfd3d3472..17cf2ab6ac1 100644 --- a/llvm/lib/Fuzzer/FuzzerIO.h +++ b/llvm/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/llvm/lib/Fuzzer/FuzzerIOPosix.cpp b/llvm/lib/Fuzzer/FuzzerIOPosix.cpp index 6d8edf6ff53..494ec9e6c83 100644 --- a/llvm/lib/Fuzzer/FuzzerIOPosix.cpp +++ b/llvm/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 == "<null>") + return false; + return true; +} + } // namespace fuzzer #endif // LIBFUZZER_POSIX diff --git a/llvm/lib/Fuzzer/FuzzerIOWindows.cpp b/llvm/lib/Fuzzer/FuzzerIOWindows.cpp index 056f0721a33..e2a67973386 100644 --- a/llvm/lib/Fuzzer/FuzzerIOWindows.cpp +++ b/llvm/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 == "<null>") + return false; + return true; +} + } // namespace fuzzer #endif // LIBFUZZER_WINDOWS diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.cpp b/llvm/lib/Fuzzer/FuzzerTracePC.cpp index 2e386af8404..71f4b66f8bb 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.cpp +++ b/llvm/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 == "<null>") - return false; - return true; -} - void TracePC::InitializePrintNewPCs() { if (!DoPrintNewPCs) return; assert(!PrintedPCs); |

