[compiler-rt] r210655 - [asan] Fix mmap-ed coverage with coverage=0.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Wed Jun 11 08:11:26 PDT 2014


Author: eugenis
Date: Wed Jun 11 10:11:26 2014
New Revision: 210655

URL: http://llvm.org/viewvc/llvm-project?rev=210655&view=rev
Log:
[asan] Fix mmap-ed coverage with coverage=0.

Added:
    compiler-rt/trunk/test/asan/TestCases/Linux/coverage-disabled.cc   (with props)
Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc

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=210655&r1=210654&r2=210655&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc Wed Jun 11 10:11:26 2014
@@ -365,8 +365,8 @@ SANITIZER_INTERFACE_ATTRIBUTE void __san
   coverage_data.Init();
 }
 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_module_init(uptr npcs) {
-  if (SANITIZER_ANDROID && common_flags()->coverage &&
-      common_flags()->coverage_direct) {
+  if (!common_flags()->coverage || !common_flags()->coverage_direct) return;
+  if (SANITIZER_ANDROID) {
     // dlopen/dlclose interceptors do not work on Android, so we rely on
     // Extend() calls to update .sancov.map.
     CovUpdateMapping(GET_CALLER_PC());

Added: compiler-rt/trunk/test/asan/TestCases/Linux/coverage-disabled.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/coverage-disabled.cc?rev=210655&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/coverage-disabled.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/coverage-disabled.cc Wed Jun 11 10:11:26 2014
@@ -0,0 +1,18 @@
+// Test that no data is collected without a runtime flag.
+//
+// RUN: %clangxx_asan -mllvm -asan-coverage=1 %s -o %t
+//
+// RUN: rm -rf %T/coverage-disabled
+//
+// RUN: mkdir -p %T/coverage-disabled/normal
+// RUN: ASAN_OPTIONS=coverage_direct=0:coverage_dir=%T/coverage-disabled/normal:verbosity=1 %run %t
+// RUN: not %sancov print %T/coverage-disabled/normal/*.sancov 2>&1
+//
+// RUN: mkdir -p %T/coverage-disabled/direct
+// RUN: ASAN_OPTIONS=coverage_direct=1:coverage_dir=%T/coverage-disabled/direct:verbosity=1 %run %t
+// RUN: cd %T/coverage-disabled/direct
+// RUN: not %sancov rawunpack *.sancov
+
+int main(int argc, char **argv) {
+  return 0;
+}

Propchange: compiler-rt/trunk/test/asan/TestCases/Linux/coverage-disabled.cc
------------------------------------------------------------------------------
    svn:eol-style = LF





More information about the llvm-commits mailing list