[compiler-rt] r219946 - [asan] make sure coverage is dumped even if leaks are reported

Kostya Serebryany kcc at google.com
Thu Oct 16 11:59:08 PDT 2014


Author: kcc
Date: Thu Oct 16 13:59:07 2014
New Revision: 219946

URL: http://llvm.org/viewvc/llvm-project?rev=219946&view=rev
Log:
[asan] make sure coverage is dumped even if leaks are reported

Added:
    compiler-rt/trunk/test/asan/TestCases/Linux/coverage-and-lsan.cc
Modified:
    compiler-rt/trunk/lib/lsan/lsan_common.cc

Modified: compiler-rt/trunk/lib/lsan/lsan_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.cc?rev=219946&r1=219945&r2=219946&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common.cc Thu Oct 16 13:59:07 2014
@@ -451,8 +451,11 @@ void DoLeakCheck() {
     PrintMatchedSuppressions();
   if (unsuppressed_count > 0) {
     param.leak_report.PrintSummary();
-    if (flags()->exitcode)
+    if (flags()->exitcode) {
+      if (common_flags()->coverage)
+        __sanitizer_cov_dump();
       internal__exit(flags()->exitcode);
+    }
   }
 }
 

Added: compiler-rt/trunk/test/asan/TestCases/Linux/coverage-and-lsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/coverage-and-lsan.cc?rev=219946&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/coverage-and-lsan.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/coverage-and-lsan.cc Thu Oct 16 13:59:07 2014
@@ -0,0 +1,20 @@
+// Make sure coverage is dumped even if there are reported leaks.
+//
+// RUN: %clangxx_asan -mllvm -asan-coverage=1 %s -o %t
+//
+// RUN: rm -rf %T/coverage-and-lsan
+//
+// RUN: mkdir -p %T/coverage-and-lsan/normal
+// RUN: ASAN_OPTIONS=coverage=1:coverage_dir=%T/coverage-and-lsan:verbosity=1 not %run %t 2>&1 | FileCheck %s
+// RUN: %sancov print %T/coverage-and-lsan/*.sancov 2>&1
+//
+// REQUIRES: asan-64-bits
+
+int *g = new int;
+int main(int argc, char **argv) {
+  g = 0;
+  return 0;
+}
+
+// CHECK: LeakSanitizer: detected memory leaks
+// CHECK: CovDump:





More information about the llvm-commits mailing list