[llvm] r267078 - [sancov] using normalized filenames for blacklist checks.

Mike Aizatsky via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 16:38:46 PDT 2016


Author: aizatsky
Date: Thu Apr 21 18:38:45 2016
New Revision: 267078

URL: http://llvm.org/viewvc/llvm-project?rev=267078&view=rev
Log:
[sancov] using normalized filenames for blacklist checks.

Differential Revision: http://reviews.llvm.org/D19395

Added:
    llvm/trunk/test/tools/sancov/Inputs/fun_blacklist.txt
      - copied, changed from r267077, llvm/trunk/test/tools/sancov/Inputs/blacklist.txt
    llvm/trunk/test/tools/sancov/Inputs/src_blacklist.txt
Removed:
    llvm/trunk/test/tools/sancov/Inputs/blacklist.txt
Modified:
    llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64
    llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.0.sancov
    llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.1.sancov
    llvm/trunk/test/tools/sancov/Inputs/test.cpp
    llvm/trunk/test/tools/sancov/blacklist.test
    llvm/trunk/test/tools/sancov/print.test
    llvm/trunk/test/tools/sancov/print_coverage_pcs.test
    llvm/trunk/test/tools/sancov/stats.test
    llvm/trunk/tools/sancov/sancov.cc

Removed: llvm/trunk/test/tools/sancov/Inputs/blacklist.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/blacklist.txt?rev=267077&view=auto
==============================================================================
--- llvm/trunk/test/tools/sancov/Inputs/blacklist.txt (original)
+++ llvm/trunk/test/tools/sancov/Inputs/blacklist.txt (removed)
@@ -1 +0,0 @@
-fun:bar*

Copied: llvm/trunk/test/tools/sancov/Inputs/fun_blacklist.txt (from r267077, llvm/trunk/test/tools/sancov/Inputs/blacklist.txt)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/fun_blacklist.txt?p2=llvm/trunk/test/tools/sancov/Inputs/fun_blacklist.txt&p1=llvm/trunk/test/tools/sancov/Inputs/blacklist.txt&r1=267077&r2=267078&rev=267078&view=diff
==============================================================================
    (empty)

Added: llvm/trunk/test/tools/sancov/Inputs/src_blacklist.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/src_blacklist.txt?rev=267078&view=auto
==============================================================================
--- llvm/trunk/test/tools/sancov/Inputs/src_blacklist.txt (added)
+++ llvm/trunk/test/tools/sancov/Inputs/src_blacklist.txt Thu Apr 21 18:38:45 2016
@@ -0,0 +1,3 @@
+# this path looks like sancov/Inputs/../Inputs/ in the binary. 
+# Make sure it is filtered out correctly.
+src:*/sancov/Inputs/foo.cpp

Modified: llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64 (original) and llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64 Thu Apr 21 18:38:45 2016 differ

Modified: llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.0.sancov
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.0.sancov?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.0.sancov (original) and llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.0.sancov Thu Apr 21 18:38:45 2016 differ

Modified: llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.1.sancov
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.1.sancov?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.1.sancov (original) and llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.1.sancov Thu Apr 21 18:38:45 2016 differ

Modified: llvm/trunk/test/tools/sancov/Inputs/test.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/test.cpp?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
--- llvm/trunk/test/tools/sancov/Inputs/test.cpp (original)
+++ llvm/trunk/test/tools/sancov/Inputs/test.cpp Thu Apr 21 18:38:45 2016
@@ -1,7 +1,7 @@
 // compile & generate coverage data using:
-// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=bb test.cpp foo.cpp
-// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 && mv test-linux_x86_64.*.sancov test-linux_x86_64.sancov
-// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 1 && mv test-linux_x86_64.*.sancov test-linux_x86_64-1.sancov
+// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=bb test.cpp ../Inputs/foo.cpp
+// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 && mv test-linux_x86_64.??*.sancov test-linux_x86_64.0.sancov
+// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 1 && mv test-linux_x86_64.??*.sancov test-linux_x86_64.1.sancov
 
 #include <stdio.h>
 #include <string>

Modified: llvm/trunk/test/tools/sancov/blacklist.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/blacklist.test?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
--- llvm/trunk/test/tools/sancov/blacklist.test (original)
+++ llvm/trunk/test/tools/sancov/blacklist.test Thu Apr 21 18:38:45 2016
@@ -1,5 +1,10 @@
 REQUIRES: x86_64-linux
-RUN: sancov -covered-functions -blacklist %p/Inputs/blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
+RUN: sancov -covered-functions -blacklist %p/Inputs/fun_blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
+RUN: sancov -covered-functions -blacklist %p/Inputs/src_blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.1.sancov | FileCheck --check-prefix=CHECK1 %s
 
 CHECK-NOT: Inputs{{[/\\]}}test.cpp:12 bar(std::string)
 CHECK: Inputs{{[/\\]}}test.cpp:14 main
+
+CHECK1-NOT: foo
+CHECK1: Inputs{{[/\\]}}test.cpp:12 bar(std::string)
+CHECK1: Inputs{{[/\\]}}test.cpp:14 main

Modified: llvm/trunk/test/tools/sancov/print.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/print.test?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
--- llvm/trunk/test/tools/sancov/print.test (original)
+++ llvm/trunk/test/tools/sancov/print.test Thu Apr 21 18:38:45 2016
@@ -1,11 +1,9 @@
 REQUIRES: x86_64-linux
 RUN: sancov -print %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
-CHECK: 0x4dbe2b
-CHECK: 0x4dbf72
-CHECK: 0x4dbfec
-CHECK: 0x4dc033
-CHECK: 0x4dc06a
-CHECK: 0x4dc09d
-CHECK: 0x4dc0d0
+CHECK: 0x4e132b
+CHECK: 0x4e1472
+CHECK: 0x4e1520
+CHECK: 0x4e1553
+CHECK: 0x4e1586
 

Modified: llvm/trunk/test/tools/sancov/print_coverage_pcs.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/print_coverage_pcs.test?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
--- llvm/trunk/test/tools/sancov/print_coverage_pcs.test (original)
+++ llvm/trunk/test/tools/sancov/print_coverage_pcs.test Thu Apr 21 18:38:45 2016
@@ -1,20 +1,13 @@
 REQUIRES: x86_64-linux
 RUN: sancov -print-coverage-pcs %p/Inputs/test-linux_x86_64 | FileCheck %s
 
-CHECK: 0x4cced1
-CHECK: 0x4ccf01
-CHECK: 0x4dbe2b
-CHECK: 0x4dbf72
-CHECK: 0x4dbfc2
-CHECK: 0x4dbfec
-CHECK: 0x4dc033
-CHECK: 0x4dc06a
-CHECK: 0x4dc09d
-CHECK: 0x4dc0d0
-CHECK: 0x4dc17f
-CHECK: 0x4dc1c6
-CHECK: 0x4dc20d
-CHECK: 0x4dc237
-CHECK: 0x4dc265
-CHECK: 0x4dc34c
+CHECK: 0x4e132b
+CHECK: 0x4e1472
+CHECK: 0x4e14c2
+CHECK: 0x4e1520
+CHECK: 0x4e1553
+CHECK: 0x4e1586
+CHECK: 0x4e1635
+CHECK: 0x4e1690
+CHECK: 0x4e178c
 

Modified: llvm/trunk/test/tools/sancov/stats.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/stats.test?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
--- llvm/trunk/test/tools/sancov/stats.test (original)
+++ llvm/trunk/test/tools/sancov/stats.test Thu Apr 21 18:38:45 2016
@@ -1,8 +1,8 @@
 REQUIRES: x86_64-linux
 RUN: sancov -print-coverage-stats %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
-CHECK: all-edges: 16
-CHECK: cov-edges: 7
+CHECK: all-edges: 9
+CHECK: cov-edges: 5
 CHECK: all-functions: 3
 CHECK: cov-functions: 2
 

Modified: llvm/trunk/tools/sancov/sancov.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/sancov/sancov.cc?rev=267078&r1=267077&r2=267078&view=diff
==============================================================================
--- llvm/trunk/tools/sancov/sancov.cc (original)
+++ llvm/trunk/tools/sancov/sancov.cc Thu Apr 21 18:38:45 2016
@@ -241,14 +241,16 @@ public:
       : DefaultBlacklist(createDefaultBlacklist()),
         UserBlacklist(createUserBlacklist()) {}
 
-  bool isBlacklisted(const DILineInfo &DI) {
-    if (DefaultBlacklist && DefaultBlacklist->inSection("fun", DI.FunctionName))
+  // AddrInfo contains normalized filename. It is important to check it rather
+  // than DILineInfo.
+  bool isBlacklisted(const AddrInfo &AI) {
+    if (DefaultBlacklist && DefaultBlacklist->inSection("fun", AI.FunctionName))
       return true;
-    if (DefaultBlacklist && DefaultBlacklist->inSection("src", DI.FileName))
+    if (DefaultBlacklist && DefaultBlacklist->inSection("src", AI.FileName))
       return true;
-    if (UserBlacklist && UserBlacklist->inSection("fun", DI.FunctionName))
+    if (UserBlacklist && UserBlacklist->inSection("fun", AI.FunctionName))
       return true;
-    if (UserBlacklist && UserBlacklist->inSection("src", DI.FileName))
+    if (UserBlacklist && UserBlacklist->inSection("src", AI.FileName))
       return true;
     return false;
   }
@@ -286,17 +288,19 @@ static std::vector<AddrInfo> getAddrInfo
   for (auto Addr : Addrs) {
     auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, Addr);
     FailIfError(LineInfo);
-    if (B.isBlacklisted(*LineInfo))
+    auto LineAddrInfo = AddrInfo(*LineInfo, Addr);
+    if (B.isBlacklisted(LineAddrInfo))
       continue;
-    Result.push_back(AddrInfo(*LineInfo, Addr));
+    Result.push_back(LineAddrInfo);
     if (InlinedCode) {
       auto InliningInfo = Symbolizer->symbolizeInlinedCode(ObjectFile, Addr);
       FailIfError(InliningInfo);
       for (uint32_t I = 0; I < InliningInfo->getNumberOfFrames(); ++I) {
         auto FrameInfo = InliningInfo->getFrame(I);
-        if (B.isBlacklisted(FrameInfo))
+        auto FrameAddrInfo = AddrInfo(FrameInfo, Addr);
+        if (B.isBlacklisted(FrameAddrInfo))
           continue;
-        Result.push_back(AddrInfo(FrameInfo, Addr));
+        Result.push_back(FrameAddrInfo);
       }
     }
   }




More information about the llvm-commits mailing list