diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2014-06-24 09:04:06 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2014-06-24 09:04:06 +0000 |
commit | 26729fe0a77f1f7137bf88fef94ecc52ab56961a (patch) | |
tree | 7c70a08d0cf076b5d806f730db213b12a0b23e56 | |
parent | 84074d61a1931e7b68ac2571ef3a184497bbc011 (diff) |
[msan] Print stats even on successful run with atexit=1.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211574 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/msan/msan.cc | 2 | ||||
-rw-r--r-- | lib/msan/msan_flags.h | 1 | ||||
-rw-r--r-- | lib/msan/msan_linux.cc | 7 | ||||
-rw-r--r-- | test/msan/print_stats.cc | 6 |
4 files changed, 10 insertions, 6 deletions
diff --git a/lib/msan/msan.cc b/lib/msan/msan.cc index 4c58200f1..bd5545fb4 100644 --- a/lib/msan/msan.cc +++ b/lib/msan/msan.cc @@ -144,6 +144,7 @@ static void ParseFlagsFromString(Flags *f, const char *str) { ParseFlag(str, &f->report_umrs, "report_umrs", ""); ParseFlag(str, &f->wrap_signals, "wrap_signals", ""); ParseFlag(str, &f->print_stats, "print_stats", ""); + ParseFlag(str, &f->atexit, "atexit", ""); // keep_going is an old name for halt_on_error, // and it has inverse meaning. @@ -173,6 +174,7 @@ static void InitializeFlags(Flags *f, const char *options) { f->report_umrs = true; f->wrap_signals = true; f->print_stats = false; + f->atexit = false; f->halt_on_error = !&__msan_keep_going; // Override from user-specified string. diff --git a/lib/msan/msan_flags.h b/lib/msan/msan_flags.h index 47ac7e435..e9ea32bda 100644 --- a/lib/msan/msan_flags.h +++ b/lib/msan/msan_flags.h @@ -29,6 +29,7 @@ struct Flags { bool wrap_signals; bool print_stats; bool halt_on_error; + bool atexit; }; Flags *flags(); diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc index 72f7c594b..a8fbabb01 100644 --- a/lib/msan/msan_linux.cc +++ b/lib/msan/msan_linux.cc @@ -90,12 +90,11 @@ void MsanDie() { } static void MsanAtExit(void) { + if (flags()->print_stats && (flags()->atexit || msan_report_count > 0)) + ReportStats(); if (msan_report_count > 0) { ReportAtExitStatistics(); - if (flags()->print_stats) - ReportStats(); - if (flags()->exit_code) - _exit(flags()->exit_code); + if (flags()->exit_code) _exit(flags()->exit_code); } } diff --git a/test/msan/print_stats.cc b/test/msan/print_stats.cc index bee364ba0..74943835b 100644 --- a/test/msan/print_stats.cc +++ b/test/msan/print_stats.cc @@ -3,6 +3,8 @@ // RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NOSTATS %s // RUN: MSAN_OPTIONS=print_stats=1 %run %t 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NOSTATS %s +// RUN: MSAN_OPTIONS=print_stats=1,atexit=1 %run %t 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-STATS %s // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -m64 -g -DPOSITIVE=1 %s -o %t // RUN: not %run %t 2>&1 | \ @@ -30,8 +32,6 @@ int main(int argc, char **argv) { // CHECK: TEST -// CHECK-KEEPGOING: MemorySanitizer: 1 warnings reported. - // CHECK-STATS: Unique heap origins: // CHECK-STATS: Stack depot allocated bytes: // CHECK-STATS: Unique origin histories: @@ -41,3 +41,5 @@ int main(int argc, char **argv) { // CHECK-NOSTATS-NOT: Stack depot allocated bytes: // CHECK-NOSTATS-NOT: Unique origin histories: // CHECK-NOSTATS-NOT: History depot allocated bytes: + +// CHECK-KEEPGOING: MemorySanitizer: 1 warnings reported. |