[llvm-commits] [compiler-rt] r172057 - in /compiler-rt/trunk/lib/msan: msan.cc msan.h msan_linux.cc msan_report.cc

Evgeniy Stepanov eugeni.stepanov at gmail.com
Thu Jan 10 03:17:56 PST 2013


Author: eugenis
Date: Thu Jan 10 05:17:55 2013
New Revision: 172057

URL: http://llvm.org/viewvc/llvm-project?rev=172057&view=rev
Log:
[msan] Set program exit code in keep-going mode.

Modified:
    compiler-rt/trunk/lib/msan/msan.cc
    compiler-rt/trunk/lib/msan/msan.h
    compiler-rt/trunk/lib/msan/msan_linux.cc
    compiler-rt/trunk/lib/msan/msan_report.cc

Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=172057&r1=172056&r2=172057&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Thu Jan 10 05:17:55 2013
@@ -90,6 +90,8 @@
 int msan_inited = 0;
 bool msan_init_is_running;
 
+int msan_report_count = 0;
+
 // Array of stack origins.
 // FIXME: make it resizable.
 static const uptr kNumStackOriginDescrs = 1024 * 1024;
@@ -163,6 +165,8 @@
     return;
   }
 
+  ++msan_report_count;
+
   StackTrace stack;
   GetStackTrace(&stack, kStackTraceMax, pc, bp);
 
@@ -177,7 +181,6 @@
   }
 }
 
-
 }  // namespace __msan
 
 // Interface.
@@ -202,6 +205,7 @@
   if (msan_inited) return;
   msan_init_is_running = 1;
 
+  InstallAtExitHandler();
   SetDieCallback(MsanDie);
   InitializeInterceptors();
 

Modified: compiler-rt/trunk/lib/msan/msan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.h?rev=172057&r1=172056&r2=172057&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.h (original)
+++ compiler-rt/trunk/lib/msan/msan.h Thu Jan 10 05:17:55 2013
@@ -32,6 +32,7 @@
 namespace __msan {
 extern int msan_inited;
 extern bool msan_init_is_running;
+extern int msan_report_count;
 
 bool ProtectRange(uptr beg, uptr end);
 bool InitShadow(bool prot1, bool prot2, bool map_shadow, bool init_origins);
@@ -42,6 +43,7 @@
                      uptr alignment, bool zeroise);
 void MsanDeallocate(void *ptr);
 void InstallTrapHandler();
+void InstallAtExitHandler();
 void ReplaceOperatorsNewAndDelete();
 
 void MsanDie();
@@ -52,6 +54,7 @@
 
 void ReportUMR(StackTrace *stack, u32 origin);
 void ReportExpectedUMRNotFound(StackTrace *stack);
+void ReportAtExitStatistics();
 
 #define GET_MALLOC_STACK_TRACE                                     \
   StackTrace stack;                                                \

Modified: compiler-rt/trunk/lib/msan/msan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_linux.cc?rev=172057&r1=172056&r2=172057&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_linux.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_linux.cc Thu Jan 10 05:17:55 2013
@@ -91,6 +91,19 @@
 void MsanDie() {
   _exit(flags()->exit_code);
 }
+
+static void MsanAtExit(void) {
+  if (msan_report_count > 0) {
+    ReportAtExitStatistics();
+    if (flags()->exit_code)
+      _exit(flags()->exit_code);
+  }
+}
+
+void InstallAtExitHandler() {
+  atexit(MsanAtExit);
+}
+
 }
 
 #endif  // __linux__

Modified: compiler-rt/trunk/lib/msan/msan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_report.cc?rev=172057&r1=172056&r2=172057&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_report.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_report.cc Thu Jan 10 05:17:55 2013
@@ -89,4 +89,12 @@
   StackTrace::PrintStack(stack->trace, stack->size, true, "", 0);
 }
 
+void ReportAtExitStatistics() {
+  Decorator d;
+  Printf("%s", d.Warning());
+  Printf("MemorySanitizer: %d warnings reported.\n", msan_report_count);
+  Printf("%s", d.End());
+}
+
+
 }  // namespace msan





More information about the llvm-commits mailing list