[compiler-rt] r304318 - [sanitizer-coverage] remove stale code (old coverage); compiler-rt part

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 11:26:32 PDT 2017


Author: kcc
Date: Wed May 31 13:26:32 2017
New Revision: 304318

URL: http://llvm.org/viewvc/llvm-project?rev=304318&view=rev
Log:
[sanitizer-coverage] remove stale code (old coverage); compiler-rt part 

Removed:
    compiler-rt/trunk/test/asan/TestCases/Posix/coverage-sandboxing.cc
    compiler-rt/trunk/test/asan/TestCases/coverage-order-pcs.cc
Modified:
    compiler-rt/trunk/include/sanitizer/coverage_interface.h
    compiler-rt/trunk/lib/dfsan/done_abilist.txt
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
    compiler-rt/trunk/lib/sanitizer_common/scripts/sancov.py
    compiler-rt/trunk/test/asan/TestCases/Linux/coverage-missing.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/coverage-fork.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/coverage-module-unloaded.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/coverage.cc
    compiler-rt/trunk/test/asan/TestCases/coverage-and-lsan.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc

Modified: compiler-rt/trunk/include/sanitizer/coverage_interface.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/include/sanitizer/coverage_interface.h?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/include/sanitizer/coverage_interface.h (original)
+++ compiler-rt/trunk/include/sanitizer/coverage_interface.h Wed May 31 13:26:32 2017
@@ -32,9 +32,6 @@ extern "C" {
   // descriptor. Returns -1 on failure, or if coverage dumping is disabled.
   // This is intended for use by sandboxing code.
   intptr_t __sanitizer_maybe_open_cov_file(const char *name);
-  // Get the number of unique covered blocks (or edges).
-  // This can be useful for coverage-directed in-process fuzzers.
-  uintptr_t __sanitizer_get_total_unique_coverage();
 #ifdef __cplusplus
 }  // extern "C"
 #endif

Modified: compiler-rt/trunk/lib/dfsan/done_abilist.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/done_abilist.txt?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/done_abilist.txt (original)
+++ compiler-rt/trunk/lib/dfsan/done_abilist.txt Wed May 31 13:26:32 2017
@@ -287,8 +287,6 @@ fun:__sanitizer_cov_with_check=uninstrum
 fun:__sanitizer_cov_with_check=discard
 fun:__sanitizer_set_death_callback=uninstrumented
 fun:__sanitizer_set_death_callback=discard
-fun:__sanitizer_get_total_unique_coverage=uninstrumented
-fun:__sanitizer_get_total_unique_coverage=discard
 fun:__sanitizer_update_counter_bitset_and_clear_counters=uninstrumented
 fun:__sanitizer_update_counter_bitset_and_clear_counters=discard
 

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_interface.inc Wed May 31 13:26:32 2017
@@ -8,14 +8,9 @@
 //===----------------------------------------------------------------------===//
 // Sanitizer Coverage interface list.
 //===----------------------------------------------------------------------===//
-INTERFACE_FUNCTION(__sanitizer_cov)
 INTERFACE_FUNCTION(__sanitizer_cov_dump)
-INTERFACE_FUNCTION(__sanitizer_cov_init)
-INTERFACE_FUNCTION(__sanitizer_cov_module_init)
-INTERFACE_FUNCTION(__sanitizer_cov_with_check)
 INTERFACE_FUNCTION(__sanitizer_dump_coverage)
 INTERFACE_FUNCTION(__sanitizer_dump_trace_pc_guard_coverage)
-INTERFACE_FUNCTION(__sanitizer_get_total_unique_coverage)
 INTERFACE_FUNCTION(__sanitizer_maybe_open_cov_file)
 INTERFACE_WEAK_FUNCTION(__sancov_default_options)
 INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_cmp)

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc Wed May 31 13:26:32 2017
@@ -155,13 +155,6 @@ void CoverageData::DirectOpen() {
 
 void CoverageData::Init() {
   pc_fd = kInvalidFd;
-
-  if (!common_flags()->coverage) return;
-  Printf("**\n***\n***\n");
-  Printf("**WARNING: this implementation of SanitizerCoverage is deprecated\n");
-  Printf("**WARNING: and will be removed in future versions\n");
-  Printf("**WARNING: See https://clang.llvm.org/docs/SanitizerCoverage.html\n");
-  Printf("**\n***\n***\n");
 }
 
 void CoverageData::Enable() {
@@ -495,6 +488,12 @@ static void GenerateHtmlReport(const Int
 void CoverageData::DumpOffsets() {
   auto sym = Symbolizer::GetOrInit();
   if (!common_flags()->coverage_pcs) return;
+  Printf("**\n***\n***\n");
+  Printf("**WARNING: this implementation of SanitizerCoverage is deprecated\n");
+  Printf("**WARNING: and will be removed in future versions\n");
+  Printf("**WARNING: See https://clang.llvm.org/docs/SanitizerCoverage.html\n");
+  Printf("**\n***\n***\n");
+
   CHECK_NE(sym, nullptr);
   InternalMmapVector<uptr> offsets(0);
   InternalScopedString path(kMaxPathLength);
@@ -607,47 +606,13 @@ void CoverageUpdateMapping() {
 } // namespace __sanitizer
 
 extern "C" {
-SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov(u32 *guard) {
-  coverage_data.Add(StackTrace::GetPreviousInstructionPc(GET_CALLER_PC()),
-                    guard);
-}
-SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_with_check(u32 *guard) {
-  atomic_uint32_t *atomic_guard = reinterpret_cast<atomic_uint32_t*>(guard);
-  if (static_cast<s32>(
-          __sanitizer::atomic_load(atomic_guard, memory_order_relaxed)) < 0)
-  coverage_data.Add(StackTrace::GetPreviousInstructionPc(GET_CALLER_PC()),
-                    guard);
-}
-SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_init() {
-  coverage_enabled = true;
-  coverage_dir = common_flags()->coverage_dir;
-  coverage_data.Init();
-}
 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump() {
-  coverage_data.DumpAll();
   __sanitizer_dump_trace_pc_guard_coverage();
 }
-SANITIZER_INTERFACE_ATTRIBUTE void
-__sanitizer_cov_module_init(s32 *guards, uptr npcs, u8 *counters,
-                            const char *comp_unit_name) {
-  coverage_data.InitializeGuards(guards, npcs, comp_unit_name, GET_CALLER_PC());
-  if (!common_flags()->coverage_direct) return;
-  if (SANITIZER_ANDROID && coverage_enabled) {
-    // dlopen/dlclose interceptors do not work on Android, so we rely on
-    // Extend() calls to update .sancov.map.
-    CovUpdateMapping(coverage_dir, GET_CALLER_PC());
-  }
-  coverage_data.Extend(npcs);
-}
 SANITIZER_INTERFACE_ATTRIBUTE
 sptr __sanitizer_maybe_open_cov_file(const char *name) {
   return (sptr)MaybeOpenCovFile(name);
 }
-SANITIZER_INTERFACE_ATTRIBUTE
-uptr __sanitizer_get_total_unique_coverage() {
-  return atomic_load(&coverage_counter, memory_order_relaxed);
-}
-
 // Default empty implementations (weak). Users should redefine them.
 SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_cmp, void) {}
 SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_cmp1, void) {}

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc Wed May 31 13:26:32 2017
@@ -49,7 +49,7 @@ static void WriteModuleCoverage(char* fi
   WriteToFile(fd, &Magic, sizeof(Magic));
   WriteToFile(fd, pcs, len * sizeof(*pcs));
   CloseFile(fd);
-  Printf("SanitizerCoverage: %s %zd PCs written\n", file_path, len);
+  Printf("SanitizerCoverage: %s: %zd PCs written\n", file_path, len);
 }
 
 static void SanitizerDumpCoverage(const uptr* unsorted_pcs, uptr len) {
@@ -71,7 +71,7 @@ static void SanitizerDumpCoverage(const
     if (!pc) continue;
 
     if (!__sanitizer_get_module_and_offset_for_pc(pc, nullptr, 0, &pcs[i])) {
-      Printf("ERROR: bad pc %x\n", pc);
+      Printf("ERROR: unknown pc 0x%x (may happen if dlclose is used)\n", pc);
       continue;
     }
     uptr module_base = pc - pcs[i];

Modified: compiler-rt/trunk/lib/sanitizer_common/scripts/sancov.py
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/scripts/sancov.py?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/scripts/sancov.py (original)
+++ compiler-rt/trunk/lib/sanitizer_common/scripts/sancov.py Wed May 31 13:26:32 2017
@@ -194,7 +194,7 @@ def GetInstrumentedPCs(binary):
   # - with call or callq,
   # - directly or via PLT.
   cmd = "objdump -d %s | " \
-        "grep '^\s\+[0-9a-f]\+:.*\scall\(q\|\)\s\+[0-9a-f]\+ <__sanitizer_cov\(_with_check\|\)\(@plt\|\)>' | " \
+        "grep '^\s\+[0-9a-f]\+:.*\scall\(q\|\)\s\+[0-9a-f]\+ <__sanitizer_cov\(_with_check\|\|_trace_pc_guard\)\(@plt\|\)>' | " \
         "grep '^\s\+[0-9a-f]\+' -o" % binary
   proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                           shell=True)

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/coverage-missing.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/coverage-missing.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/coverage-missing.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/coverage-missing.cc Wed May 31 13:26:32 2017
@@ -1,7 +1,7 @@
 // Test for "sancov.py missing ...".
 
 // First case: coverage from executable. main() is called on every code path.
-// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t -DFOOBAR -DMAIN
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %t -DFOOBAR -DMAIN
 // RUN: rm -rf %T/coverage-missing
 // RUN: mkdir -p %T/coverage-missing
 // RUN: cd %T/coverage-missing
@@ -27,8 +27,8 @@
 
 // Second case: coverage from DSO.
 // cd %T
-// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %dynamiclib -DFOOBAR -shared -fPIC
-// RUN: %clangxx_asan -fsanitize-coverage=func %s %dynamiclib -o %t -DMAIN
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %dynamiclib -DFOOBAR -shared -fPIC
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %dynamiclib -o %t -DMAIN
 // RUN: cd ..
 // RUN: rm -rf %T/coverage-missing
 // RUN: mkdir -p %T/coverage-missing

Modified: compiler-rt/trunk/test/asan/TestCases/Posix/coverage-fork.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/coverage-fork.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/coverage-fork.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/coverage-fork.cc Wed May 31 13:26:32 2017
@@ -1,9 +1,13 @@
-// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %t
 // RUN: rm -rf %T/coverage-fork
 // RUN: mkdir -p %T/coverage-fork && cd %T/coverage-fork
-// RUN: %env_asan_opts=coverage=1:coverage_direct=0:verbosity=1 %run %t 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t 2>&1 | FileCheck %s
 //
 // UNSUPPORTED: android
+//
+// Ideally a forked-subprocess should only report it's own coverage,
+// not parent's one. But trace-pc-guard currently does nothing special for fork,
+// and thus this test is relaxed.
 
 #include <stdio.h>
 #include <string.h>
@@ -32,6 +36,6 @@ int main(int argc, char **argv) {
 }
 
 // CHECK-DAG: Child PID: [[ChildPID:[0-9]+]]
-// CHECK-DAG: [[ChildPID]].sancov: 1 PCs written
+// CHECK-DAG: [[ChildPID]].sancov: {{.*}} PCs written
 // CHECK-DAG: Parent PID: [[ParentPID:[0-9]+]]
 // CHECK-DAG: [[ParentPID]].sancov: 3 PCs written

Modified: compiler-rt/trunk/test/asan/TestCases/Posix/coverage-module-unloaded.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/coverage-module-unloaded.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/coverage-module-unloaded.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/coverage-module-unloaded.cc Wed May 31 13:26:32 2017
@@ -1,12 +1,11 @@
 // Check that unloading a module doesn't break coverage dumping for remaining
 // modules.
-// RUN: %clangxx_asan -fsanitize-coverage=func -DSHARED %s -shared -o %dynamiclib1 -fPIC
-// RUN: %clangxx_asan -fsanitize-coverage=func -DSHARED %s -shared -o %dynamiclib2 -fPIC
-// RUN: %clangxx_asan -fsanitize-coverage=func %s %libdl -o %t
-// RUN: mkdir -p %T/coverage-module-unloaded && cd %T/coverage-module-unloaded
-// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t %dynamiclib1 %dynamiclib2 2>&1        | FileCheck %s
-// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t %dynamiclib1 %dynamiclib2 foo 2>&1    | FileCheck %s
-// RUN: rm -r %T/coverage-module-unloaded
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard -DSHARED %s -shared -o %dynamiclib1 -fPIC
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard -DSHARED %s -shared -o %dynamiclib2 -fPIC
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %libdl -o %t.exe
+// RUN: mkdir -p %t.tmp/coverage-module-unloaded && cd %t.tmp/coverage-module-unloaded
+// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t.exe %dynamiclib1 %dynamiclib2 2>&1        | FileCheck %s
+// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t.exe %dynamiclib1 %dynamiclib2 foo 2>&1    | FileCheck %s
 //
 // https://code.google.com/p/address-sanitizer/issues/detail?id=263
 // XFAIL: android
@@ -48,8 +47,5 @@ int main(int argc, char **argv) {
 #endif
 
 // CHECK: PID: [[PID:[0-9]+]]
-// CHECK: [[PID]].sancov: 1 PCs written
-// CHECK: coverage-module-unloaded{{.*}}1.[[PID]]
-// CHECK: coverage-module-unloaded{{.*}}2.[[PID]]
-// Even though we've unloaded one of the libs we still dump the coverage file
-// for that lib (although the data will be inaccurate, if at all useful)
+// CHECK-DAG: exe{{.*}}[[PID]].sancov: {{.*}}PCs written
+// CHECK-DAG: dynamic{{.*}}[[PID]].sancov: {{.*}}PCs written

Removed: compiler-rt/trunk/test/asan/TestCases/Posix/coverage-sandboxing.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/coverage-sandboxing.cc?rev=304317&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/coverage-sandboxing.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/coverage-sandboxing.cc (removed)
@@ -1,87 +0,0 @@
-// RUN: %clangxx_asan -fsanitize-coverage=bb -DSHARED %s -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
-// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t %ld_flags_rpath_exe
-
-// RUN: rm -rf %T/coverage_sandboxing_test
-// RUN: mkdir %T/coverage_sandboxing_test && cd %T/coverage_sandboxing_test
-// RUN: mkdir vanilla && cd vanilla
-// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t 2>&1  | FileCheck %s --check-prefix=CHECK-vanilla
-// RUN: mkdir ../sandbox1 && cd ../sandbox1
-// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t a 2>&1 | FileCheck %s --check-prefix=CHECK-sandbox
-// RUN: %sancov unpack coverage_sandboxing_test.sancov.packed
-// RUN: mkdir ../sandbox2 && cd ../sandbox2
-// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t a b 2>&1 | FileCheck %s --check-prefix=CHECK-sandbox
-// RUN: %sancov unpack coverage_sandboxing_test.sancov.packed
-// RUN: cd ..
-// RUN: %sancov print vanilla/%xdynamiclib_filename*.sancov > vanilla.txt
-// RUN: %sancov print sandbox1/%xdynamiclib_filename*.sancov > sandbox1.txt
-// RUN: %sancov print sandbox2/%xdynamiclib_filename*.sancov > sandbox2.txt
-// RUN: diff vanilla.txt sandbox1.txt
-// RUN: diff vanilla.txt sandbox2.txt
-// RUN: rm -r %T/coverage_sandboxing_test
-
-// https://code.google.com/p/address-sanitizer/issues/detail?id=263
-// XFAIL: android
-// UNSUPPORTED: ios
-
-#include <assert.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <sanitizer/coverage_interface.h>
-
-#define bb0(n)                        \
-  case n:                             \
-    fprintf(stderr, "foo: %d\n", n);  \
-    break;
-
-#define bb1(n) bb0(n) bb0(n + 1)
-#define bb2(n) bb1(n) bb1(n + 2)
-#define bb3(n) bb2(n) bb2(n + 4)
-#define bb4(n) bb3(n) bb3(n + 8)
-#define bb5(n) bb4(n) bb4(n + 16)
-#define bb6(n) bb5(n) bb5(n + 32)
-#define bb7(n) bb6(n) bb6(n + 64)
-#define bb8(n) bb7(n) bb7(n + 128)
-
-#ifdef SHARED
-void foo(int i) {
-  switch(i) {
-    // 256 basic blocks
-    bb8(0)
-  }
-}
-#else
-extern void foo(int i);
-
-int main(int argc, char **argv) {
-  assert(argc <= 3);
-  for (int i = 0; i < 256; i++) foo(i);
-  fprintf(stderr, "PID: %d\n", getpid());
-  if (argc == 1) {
-    // Vanilla mode, dump to individual files.
-    return 0;
-  }
-  // Dump to packed file.
-  int fd = creat("coverage_sandboxing_test.sancov.packed", 0660);
-  __sanitizer_sandbox_arguments args = {0};
-  args.coverage_sandboxed = 1;
-  args.coverage_fd = fd;
-  if (argc == 2)
-    // Write to packed file, do not split into blocks.
-    args.coverage_max_block_size = 0;
-  else if (argc == 3)
-    // Write to packed file, split into blocks (as if writing to a socket).
-    args.coverage_max_block_size = 100;
-  __sanitizer_sandbox_on_notify(&args);
-  return 0;
-}
-#endif
-
-// CHECK-vanilla: PID: [[PID:[0-9]+]]
-// CHECK-vanilla: .so.[[PID]].sancov: 257 PCs written
-// CHECK-vanilla: [[PID]].sancov: 1 PCs written
-
-// CHECK-sandbox: PID: [[PID:[0-9]+]]
-// CHECK-sandbox: 257 PCs written to packed file

Modified: compiler-rt/trunk/test/asan/TestCases/Posix/coverage.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/coverage.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/coverage.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/coverage.cc Wed May 31 13:26:32 2017
@@ -1,5 +1,5 @@
-// RUN: %clangxx_asan -fsanitize-coverage=func -DSHARED %s -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
-// RUN: %clangxx_asan -fsanitize-coverage=func %s %ld_flags_rpath_exe -o %t
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard -DSHARED %s -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %ld_flags_rpath_exe -o %t
 // RUN: rm -rf %T/coverage && mkdir -p %T/coverage && cd %T/coverage
 // RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t 2>&1         | FileCheck %s --check-prefix=CHECK-main
 // RUN: %sancov print coverage.*sancov 2>&1 | FileCheck %s --check-prefix=CHECK-SANCOV1
@@ -20,7 +20,6 @@
 // XFAIL: android
 // UNSUPPORTED: ios
 
-#include <sanitizer/coverage_interface.h>
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
@@ -38,12 +37,8 @@ int G[4];
 int main(int argc, char **argv) {
   fprintf(stderr, "PID: %d\n", getpid());
   for (int i = 1; i < argc; i++) {
-    if (!strcmp(argv[i], "foo")) {
-      uintptr_t old_coverage = __sanitizer_get_total_unique_coverage();
+    if (!strcmp(argv[i], "foo"))
       foo();
-      uintptr_t new_coverage = __sanitizer_get_total_unique_coverage();
-      assert(new_coverage > old_coverage);
-    }
     if (!strcmp(argv[i], "bar"))
       bar();
   }
@@ -64,12 +59,12 @@ int main(int argc, char **argv) {
 // CHECK-foo-NOT: .so.[[PID]]
 //
 // CHECK-bar: PID: [[PID:[0-9]+]]
-// CHECK-bar: .so.[[PID]].sancov: 1 PCs written
-// CHECK-bar: [[PID]].sancov: 1 PCs written
+// CHECK-bar-DAG: .so.[[PID]].sancov: 1 PCs written
+// CHECK-bar-DAG: [[PID]].sancov: 1 PCs written
 //
 // CHECK-foo-bar: PID: [[PID:[0-9]+]]
-// CHECK-foo-bar: so.[[PID]].sancov: 1 PCs written
-// CHECK-foo-bar: [[PID]].sancov: 2 PCs written
+// CHECK-foo-bar-DAG: so.[[PID]].sancov: 1 PCs written
+// CHECK-foo-bar-DAG: [[PID]].sancov: 2 PCs written
 //
 // CHECK-report: AddressSanitizer: global-buffer-overflow
 // CHECK-report: PCs written

Modified: compiler-rt/trunk/test/asan/TestCases/coverage-and-lsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/coverage-and-lsan.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/coverage-and-lsan.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/coverage-and-lsan.cc Wed May 31 13:26:32 2017
@@ -1,6 +1,6 @@
 // Make sure coverage is dumped even if there are reported leaks.
 //
-// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t
+// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %t
 //
 // RUN: rm -rf %T/coverage-and-lsan
 //
@@ -17,4 +17,4 @@ int main(int argc, char **argv) {
 }
 
 // CHECK: LeakSanitizer: detected memory leaks
-// CHECK: CovDump:
+// CHECK: SanitizerCoverage: {{.*}}PCs written

Removed: compiler-rt/trunk/test/asan/TestCases/coverage-order-pcs.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/coverage-order-pcs.cc?rev=304317&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/coverage-order-pcs.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/coverage-order-pcs.cc (removed)
@@ -1,57 +0,0 @@
-// Test coverage_order_pcs=1 flag which orders the PCs by their appearance.
-// RUN: DIR=%T/coverage-order-pcs
-// RUN: rm -rf $DIR
-// RUN: mkdir $DIR
-// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t
-// RUN: %env_asan_opts=coverage_dir=$DIR:coverage=1:coverage_order_pcs=0 %run %t
-// RUN: mv $DIR/*sancov $DIR/A
-
-// RUN: %env_asan_opts=coverage_dir=$DIR:coverage=1:coverage_order_pcs=0 %run %t 1
-// RUN: mv $DIR/*sancov $DIR/B
-
-// RUN: %env_asan_opts=coverage_dir=$DIR:coverage=1:coverage_order_pcs=1 %run %t
-// RUN: mv $DIR/*sancov $DIR/C
-
-// RUN: %env_asan_opts=coverage_dir=$DIR:coverage=1:coverage_order_pcs=1 %run %t 1
-// RUN: mv $DIR/*sancov $DIR/D
-//
-// RUN: (%sancov print $DIR/A; %sancov print $DIR/B; %sancov print $DIR/C; %sancov print $DIR/D) | FileCheck %s
-//
-// RUN: rm -rf $DIR
-// Ordering works only in 64-bit mode for now.
-// REQUIRES: asan-64-bits, shell
-// UNSUPPORTED: android
-#include <stdio.h>
-
-void foo() { fprintf(stderr, "FOO\n"); }
-void bar() { fprintf(stderr, "BAR\n"); }
-
-int main(int argc, char **argv) {
-  if (argc == 2) {
-    foo();
-    bar();
-  } else {
-    bar();
-    foo();
-  }
-}
-
-// Run A: no ordering
-// CHECK: [[FOO:0x[0-9a-f]*]]
-// CHECK-NEXT: [[BAR:0x[0-9a-f]*]]
-// CHECK-NEXT: [[MAIN:0x[0-9a-f]*]]
-//
-// Run B: still no ordering
-// CHECK-NEXT: [[FOO]]
-// CHECK-NEXT: [[BAR]]
-// CHECK-NEXT: [[MAIN]]
-//
-// Run C: MAIN, BAR, FOO
-// CHECK-NEXT: [[MAIN]]
-// CHECK-NEXT: [[BAR]]
-// CHECK-NEXT: [[FOO]]
-//
-// Run D: MAIN, FOO, BAR
-// CHECK-NEXT: [[MAIN]]
-// CHECK-NEXT: [[FOO]]
-// CHECK-NEXT: [[BAR]]

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cc Wed May 31 13:26:32 2017
@@ -25,4 +25,4 @@ int main() {
 }
 
 // CHECK: main
-// CHECK: SanitizerCoverage: ./sanitizer_coverage_symbolize.{{.*}}.sancov 2 PCs written
+// CHECK: SanitizerCoverage: ./sanitizer_coverage_symbolize.{{.*}}.sancov: 2 PCs written

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cc Wed May 31 13:26:32 2017
@@ -62,9 +62,9 @@ int baz() {
 // CHECK-NEXT: foo
 // CHECK-NEXT: bar
 // CHECK-NEXT: baz
-// CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}.sancov 2 PCs written
-// CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_2.so.{{.*}}.sancov 1 PCs written
-// CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_1.so.{{.*}}.sancov 1 PCs written
+// CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}.sancov: 2 PCs written
+// CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_2.so.{{.*}}.sancov: 1 PCs written
+// CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_1.so.{{.*}}.sancov: 1 PCs written
 //
 // CHECK-SANCOV: Ignoring {{.*}}_1.so and its coverage because __sanitizer_cov* functions were not found.
 // CHECK-SANCOV: Ignoring {{.*}}_2.so and its coverage because __sanitizer_cov* functions were not found.

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc?rev=304318&r1=304317&r2=304318&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cc Wed May 31 13:26:32 2017
@@ -34,7 +34,7 @@ int main() {
 // CHECK: main
 // CHECK-NEXT: foo
 // CHECK-NEXT: foo
-// CHECK-NEXT: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard.{{.*}}.sancov 2 PCs written
+// CHECK-NEXT: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard.{{.*}}.sancov: 2 PCs written
 //
 // CHECK-SANCOV: sanitizer_coverage_trace_pc_guard.cc:23 foo
 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard.cc:28 main




More information about the llvm-commits mailing list