[msan] Print stats even on successful run with atexit=1.

llvm-svn: 211574
This commit is contained in:
Evgeniy Stepanov 2014-06-24 09:04:06 +00:00
parent cc91169fd7
commit ad8065f01a
4 changed files with 10 additions and 6 deletions

View File

@ -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.

View File

@ -29,6 +29,7 @@ struct Flags {
bool wrap_signals;
bool print_stats;
bool halt_on_error;
bool atexit;
};
Flags *flags();

View File

@ -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);
}
}

View File

@ -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.