summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2014-12-30 19:55:04 +0000
committerKostya Serebryany <kcc@google.com>2014-12-30 19:55:04 +0000
commitf04c72a1de7b99e2e239c6eeeb02943a8a3ab33d (patch)
tree66af3673e8e541defe799596d8a4575a2459baa7
parentf72f42958663a578dad99c2406285fac5c84986e (diff)
downloadcompiler-rt-f04c72a1de7b99e2e239c6eeeb02943a8a3ab33d.tar.gz
[asan] add flag coverage_pcs. When false, the coverage is not dumped as PCs. Useful e.g. if the user only needs coverage is bitset
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225002 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/sanitizer_common/sanitizer_coverage_libcdep.cc1
-rw-r--r--lib/sanitizer_common/sanitizer_flags.cc4
-rw-r--r--lib/sanitizer_common/sanitizer_flags.h1
-rw-r--r--test/asan/TestCases/Linux/coverage-levels.cc2
4 files changed, 8 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_coverage_libcdep.cc b/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
index e28a6aee3..eb69172c7 100644
--- a/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
+++ b/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
@@ -509,6 +509,7 @@ static void CovDump() {
if (atomic_fetch_add(&dump_once_guard, 1, memory_order_relaxed))
return;
CovDumpAsBitSet();
+ if (!common_flags()->coverage_pcs) return;
uptr size = coverage_data.size();
InternalMmapVector<u32> offsets(size);
uptr *vb = coverage_data.data();
diff --git a/lib/sanitizer_common/sanitizer_flags.cc b/lib/sanitizer_common/sanitizer_flags.cc
index 7cc5cfecc..3b1ec70fb 100644
--- a/lib/sanitizer_common/sanitizer_flags.cc
+++ b/lib/sanitizer_common/sanitizer_flags.cc
@@ -63,6 +63,7 @@ void CommonFlags::SetDefaults() {
legacy_pthread_cond = false;
intercept_tls_get_addr = false;
coverage = false;
+ coverage_pcs = true; // On by default, but works only if coverage==true.
coverage_bitset = false;
coverage_direct = SANITIZER_ANDROID;
coverage_dir = ".";
@@ -151,6 +152,9 @@ void CommonFlags::ParseFromString(const char *str) {
ParseFlag(str, &coverage, "coverage",
"If set, coverage information will be dumped at program shutdown (if the "
"coverage instrumentation was enabled at compile time).");
+ ParseFlag(str, &coverage_pcs, "coverage_pcs",
+ "If set (and if 'coverage' is set too), the coverage information "
+ "will be dumped as a set of PC offsets for every module.");
ParseFlag(str, &coverage_bitset, "coverage_bitset",
"If set (and if 'coverage' is set too), the coverage information "
"will also be dumped as a bitset to a separate file.");
diff --git a/lib/sanitizer_common/sanitizer_flags.h b/lib/sanitizer_common/sanitizer_flags.h
index 6d251b40e..8718089ae 100644
--- a/lib/sanitizer_common/sanitizer_flags.h
+++ b/lib/sanitizer_common/sanitizer_flags.h
@@ -56,6 +56,7 @@ struct CommonFlags {
uptr mmap_limit_mb;
uptr hard_rss_limit_mb;
bool coverage;
+ bool coverage_pcs;
bool coverage_bitset;
bool coverage_direct;
const char *coverage_dir;
diff --git a/test/asan/TestCases/Linux/coverage-levels.cc b/test/asan/TestCases/Linux/coverage-levels.cc
index d187d36dc..cc196c5a9 100644
--- a/test/asan/TestCases/Linux/coverage-levels.cc
+++ b/test/asan/TestCases/Linux/coverage-levels.cc
@@ -9,6 +9,7 @@
// RUN: ASAN_OPTIONS=coverage=1:coverage_bitset=0:verbosity=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3_NOBITSET
// RUN: ASAN_OPTIONS=coverage=1:verbosity=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3_NOBITSET
+// RUN: ASAN_OPTIONS=coverage=1:coverage_pcs=0:verbosity=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3_NOPCS
//
// REQUIRES: asan-64-bits
@@ -25,3 +26,4 @@ int main(int argc, char **argv) {
// CHECK3: CovDump: bitset of 4 bits written, 3 bits are set
// CHECK3: 3 PCs written
// CHECK3_NOBITSET-NOT: bitset of
+// CHECK3_NOPCS-NOT: PCs written