[compiler-rt] r211896 - [msan] Add store_context_size= flag.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Jun 27 05:48:01 PDT 2014


Author: eugenis
Date: Fri Jun 27 07:48:01 2014
New Revision: 211896

URL: http://llvm.org/viewvc/llvm-project?rev=211896&view=rev
Log:
[msan] Add store_context_size= flag.

A new flag to control stack trace size for store event (in
track-origins=2 mode) independently of malloc_context_size.

Modified:
    compiler-rt/trunk/lib/msan/msan.cc
    compiler-rt/trunk/lib/msan/msan.h
    compiler-rt/trunk/lib/msan/msan_flags.h
    compiler-rt/trunk/test/msan/chained_origin_empty_stack.cc

Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=211896&r1=211895&r2=211896&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Fri Jun 27 07:48:01 2014
@@ -145,6 +145,8 @@ static void ParseFlagsFromString(Flags *
   ParseFlag(str, &f->wrap_signals, "wrap_signals", "");
   ParseFlag(str, &f->print_stats, "print_stats", "");
   ParseFlag(str, &f->atexit, "atexit", "");
+  ParseFlag(str, &f->store_context_size, "store_context_size", "");
+  if (f->store_context_size < 1) f->store_context_size = 1;
 
   // keep_going is an old name for halt_on_error,
   // and it has inverse meaning.
@@ -177,6 +179,7 @@ static void InitializeFlags(Flags *f, co
   f->print_stats = false;
   f->atexit = false;
   f->halt_on_error = !&__msan_keep_going;
+  f->store_context_size = 20;
 
   // Override from user-specified string.
   if (__msan_default_options)

Modified: compiler-rt/trunk/lib/msan/msan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.h?rev=211896&r1=211895&r2=211896&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.h (original)
+++ compiler-rt/trunk/lib/msan/msan.h Fri Jun 27 07:48:01 2014
@@ -104,12 +104,12 @@ u32 ChainOrigin(u32 id, StackTrace *stac
         StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(),           \
         common_flags()->fast_unwind_on_malloc)
 
-#define GET_STORE_STACK_TRACE_PC_BP(pc, bp)                            \
-  StackTrace stack;                                                    \
-  stack.size = 0;                                                      \
-  if (__msan_get_track_origins() > 1 && msan_inited)                   \
-    GetStackTrace(&stack, common_flags()->malloc_context_size, pc, bp, \
-                  common_flags()->fast_unwind_on_malloc)
+#define GET_STORE_STACK_TRACE_PC_BP(pc, bp)                  \
+  StackTrace stack;                                          \
+  stack.size = 0;                                            \
+  if (__msan_get_track_origins() > 1 && msan_inited)         \
+  GetStackTrace(&stack, flags()->store_context_size, pc, bp, \
+                common_flags()->fast_unwind_on_malloc)
 
 #define GET_FATAL_STACK_TRACE_PC_BP(pc, bp)       \
   StackTrace stack;                               \

Modified: compiler-rt/trunk/lib/msan/msan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_flags.h?rev=211896&r1=211895&r2=211896&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_flags.h (original)
+++ compiler-rt/trunk/lib/msan/msan_flags.h Fri Jun 27 07:48:01 2014
@@ -30,6 +30,7 @@ struct Flags {
   bool print_stats;
   bool halt_on_error;
   bool atexit;
+  int store_context_size; // like malloc_context_size, but for uninit stores
 };
 
 Flags *flags();

Modified: compiler-rt/trunk/test/msan/chained_origin_empty_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/chained_origin_empty_stack.cc?rev=211896&r1=211895&r2=211896&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/chained_origin_empty_stack.cc (original)
+++ compiler-rt/trunk/test/msan/chained_origin_empty_stack.cc Fri Jun 27 07:48:01 2014
@@ -1,5 +1,5 @@
 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t && \
-// RUN:     MSAN_OPTIONS=malloc_context_size=1 not %run %t 2>&1 | FileCheck %s
+// RUN:     MSAN_OPTIONS=store_context_size=1 not %run %t 2>&1 | FileCheck %s
 
 // Test that stack trace for the intermediate store is not empty.
 
@@ -8,6 +8,7 @@
 
 // CHECK: Uninitialized value was stored to memory at
 // CHECK:   #0 {{.*}} in fn_g
+// CHECK-NOT: #1
 
 // CHECK: Uninitialized value was created by an allocation of 'z' in the stack frame of function 'main'
 // CHECK:   #0 {{.*}} in main





More information about the llvm-commits mailing list