[PATCH] [msan] Common flags in MSan.

Sergey Matveev earthdok at google.com
Mon May 6 04:52:44 PDT 2013


Hi eugenis, kcc,

http://llvm-reviews.chandlerc.com/D748

Files:
  lib/msan/msan.cc
  lib/msan/msan.h
  lib/msan/msan_flags.h
  lib/msan/msan_report.cc

Index: lib/msan/msan.cc
===================================================================
--- lib/msan/msan.cc
+++ lib/msan/msan.cc
@@ -114,6 +114,7 @@
 static atomic_uint32_t NumStackOriginDescrs;
 
 static void ParseFlagsFromString(Flags *f, const char *str) {
+  ParseCommonFlagsFromString(str);
   ParseFlag(str, &f->poison_heap_with_zeroes, "poison_heap_with_zeroes");
   ParseFlag(str, &f->poison_stack_with_zeroes, "poison_stack_with_zeroes");
   ParseFlag(str, &f->poison_in_malloc, "poison_in_malloc");
@@ -123,28 +124,26 @@
     f->exit_code = 1;
     Die();
   }
-  ParseFlag(str, &f->num_callers, "num_callers");
   ParseFlag(str, &f->report_umrs, "report_umrs");
   ParseFlag(str, &f->verbosity, "verbosity");
-  ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix");
-  ParseFlag(str, &f->fast_unwind_on_fatal, "fast_unwind_on_fatal");
-  ParseFlag(str, &f->fast_unwind_on_malloc, "fast_unwind_on_malloc");
   ParseFlag(str, &f->wrap_signals, "wrap_signals");
 }
 
 static void InitializeFlags(Flags *f, const char *options) {
-  internal_memset(f, 0, sizeof(*f));
+  CommonFlags *cf = common_flags();
+  cf->external_symbolizer_path = GetEnv("MSAN_SYMBOLIZER_PATH");
+  cf->strip_path_prefix = "";
+  cf->fast_unwind_on_fatal = false;
+  cf->fast_unwind_on_malloc = true;
+  cf->malloc_context_size = 20;
 
+  internal_memset(f, 0, sizeof(*f));
   f->poison_heap_with_zeroes = false;
   f->poison_stack_with_zeroes = false;
   f->poison_in_malloc = true;
   f->exit_code = 77;
-  f->num_callers = 20;
   f->report_umrs = true;
   f->verbosity = 0;
-  f->strip_path_prefix = "";
-  f->fast_unwind_on_fatal = false;
-  f->fast_unwind_on_malloc = true;
   f->wrap_signals = true;
 
   // Override from user-specified string.
@@ -201,7 +200,8 @@
   ++msan_report_count;
 
   StackTrace stack;
-  GetStackTrace(&stack, kStackTraceMax, pc, bp, flags()->fast_unwind_on_fatal);
+  GetStackTrace(&stack, kStackTraceMax, pc, bp,
+                common_flags()->fast_unwind_on_fatal);
 
   u32 report_origin =
     (__msan_track_origins && OriginIsValid(origin)) ? origin : 0;
@@ -276,7 +276,7 @@
     Die();
   }
 
-  const char *external_symbolizer = GetEnv("MSAN_SYMBOLIZER_PATH");
+  const char *external_symbolizer = common_flags()->external_symbolizer_path;
   if (external_symbolizer && external_symbolizer[0]) {
     CHECK(InitializeExternalSymbolizer(external_symbolizer));
   }
@@ -302,7 +302,7 @@
     (void)sp;
     StackTrace stack;
     GetStackTrace(&stack, kStackTraceMax, pc, bp,
-                  flags()->fast_unwind_on_fatal);
+                  common_flags()->fast_unwind_on_fatal);
     ReportExpectedUMRNotFound(&stack);
     Die();
   }
Index: lib/msan/msan.h
===================================================================
--- lib/msan/msan.h
+++ lib/msan/msan.h
@@ -16,6 +16,7 @@
 #define MSAN_H
 
 #include "sanitizer_common/sanitizer_internal_defs.h"
+#include "sanitizer_common/sanitizer_flags.h"
 #include "sanitizer_common/sanitizer_stacktrace.h"
 #include "msan_interface_internal.h"
 #include "msan_flags.h"
@@ -81,9 +82,9 @@
   StackTrace stack;                                                \
   stack.size = 0;                                                  \
   if (__msan_get_track_origins() && msan_inited)                   \
-    GetStackTrace(&stack, flags()->num_callers,                    \
+    GetStackTrace(&stack, common_flags()->malloc_context_size,     \
         StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(),           \
-        flags()->fast_unwind_on_malloc)
+        common_flags()->fast_unwind_on_malloc)
 
 }  // namespace __msan
 
Index: lib/msan/msan_flags.h
===================================================================
--- lib/msan/msan_flags.h
+++ lib/msan/msan_flags.h
@@ -19,17 +19,11 @@
 // Flags.
 struct Flags {
   int exit_code;
-  int num_callers;
   int verbosity;
   bool poison_heap_with_zeroes;  // default: false
   bool poison_stack_with_zeroes;  // default: false
   bool poison_in_malloc;  // default: true
   bool report_umrs;
-  const char *strip_path_prefix;
-  // Use fast (frame-pointer-based) unwinder on fatal errors (if available).
-  bool fast_unwind_on_fatal;
-  // Use fast (frame-pointer-based) unwinder on malloc/free (if available).
-  bool fast_unwind_on_malloc;
   bool wrap_signals;
 };
 
Index: lib/msan/msan_report.cc
===================================================================
--- lib/msan/msan_report.cc
+++ lib/msan/msan_report.cc
@@ -14,6 +14,7 @@
 
 #include "msan.h"
 #include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_flags.h"
 #include "sanitizer_common/sanitizer_mutex.h"
 #include "sanitizer_common/sanitizer_report_decorator.h"
 #include "sanitizer_common/sanitizer_stackdepot.h"
@@ -44,7 +45,8 @@
 
 static void PrintStack(const uptr *trace, uptr size) {
   SymbolizerScope sym_scope;
-  StackTrace::PrintStack(trace, size, true, flags()->strip_path_prefix, 0);
+  StackTrace::PrintStack(trace, size, true,
+                         common_flags()->strip_path_prefix, 0);
 }
 
 static void DescribeOrigin(u32 origin) {
@@ -80,7 +82,8 @@
     SymbolizeCode(pc, &ai, 1);
   }
   ReportErrorSummary(error_type,
-                     StripPathPrefix(ai.file, flags()->strip_path_prefix),
+                     StripPathPrefix(ai.file,
+                                     common_flags()->strip_path_prefix),
                      ai.line, ai.function);
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D748.1.patch
Type: text/x-patch
Size: 5436 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130506/b718d069/attachment.bin>


More information about the llvm-commits mailing list