[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
This commit is contained in:
Marcos Pividori 2017-01-22 01:27:47 +00:00
parent 403007e3c1
commit 60cc2fbba1
4 changed files with 24 additions and 12 deletions

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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);