[compiler-rt] r194479 - [Sanitizer] Specify a default value for each common runtime flag

Alexey Samsonov samsonov at google.com
Tue Nov 12 05:59:09 PST 2013


Author: samsonov
Date: Tue Nov 12 07:59:08 2013
New Revision: 194479

URL: http://llvm.org/viewvc/llvm-project?rev=194479&view=rev
Log:
[Sanitizer] Specify a default value for each common runtime flag

Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/lsan/lsan.cc
    compiler-rt/trunk/lib/msan/msan.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h
    compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=194479&r1=194478&r2=194479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Nov 12 07:59:08 2013
@@ -132,16 +132,9 @@ static void ParseFlagsFromString(Flags *
 
 void InitializeFlags(Flags *f, const char *env) {
   CommonFlags *cf = common_flags();
+  SetCommonFlagDefaults();
   cf->external_symbolizer_path = GetEnv("ASAN_SYMBOLIZER_PATH");
-  cf->symbolize = true;
   cf->malloc_context_size = kDefaultMallocContextSize;
-  cf->fast_unwind_on_fatal = false;
-  cf->fast_unwind_on_malloc = true;
-  cf->strip_path_prefix = "";
-  cf->handle_ioctl = false;
-  cf->log_path = 0;
-  cf->detect_leaks = false;
-  cf->leak_check_at_exit = true;
 
   internal_memset(f, 0, sizeof(*f));
   f->quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 26 : 1UL << 28;

Modified: compiler-rt/trunk/lib/lsan/lsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.cc?rev=194479&r1=194478&r2=194479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan.cc Tue Nov 12 07:59:08 2013
@@ -24,13 +24,10 @@ namespace __lsan {
 
 static void InitializeCommonFlags() {
   CommonFlags *cf = common_flags();
+  SetCommonFlagDefaults();
   cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
-  cf->symbolize = true;
-  cf->strip_path_prefix = "";
-  cf->fast_unwind_on_malloc = true;
   cf->malloc_context_size = 30;
   cf->detect_leaks = true;
-  cf->leak_check_at_exit = true;
 
   ParseCommonFlagsFromString(GetEnv("LSAN_OPTIONS"));
 }

Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=194479&r1=194478&r2=194479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Tue Nov 12 07:59:08 2013
@@ -141,14 +141,10 @@ static void ParseFlagsFromString(Flags *
 
 static void InitializeFlags(Flags *f, const char *options) {
   CommonFlags *cf = common_flags();
+  SetCommonFlagDefaults();
   cf->external_symbolizer_path = GetEnv("MSAN_SYMBOLIZER_PATH");
-  cf->symbolize = true;
-  cf->strip_path_prefix = "";
-  cf->fast_unwind_on_fatal = false;
-  cf->fast_unwind_on_malloc = true;
   cf->malloc_context_size = 20;
   cf->handle_ioctl = true;
-  cf->log_path = 0;
 
   internal_memset(f, 0, sizeof(*f));
   f->poison_heap_with_zeroes = false;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc?rev=194479&r1=194478&r2=194479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc Tue Nov 12 07:59:08 2013
@@ -18,16 +18,31 @@
 
 namespace __sanitizer {
 
+void SetCommonFlagDefaults() {
+  CommonFlags *f = common_flags();
+  f->symbolize = true;
+  f->external_symbolizer_path = "";
+  f->strip_path_prefix = "";
+  f->fast_unwind_on_fatal = false;
+  f->fast_unwind_on_malloc = true;
+  f->handle_ioctl = false;
+  f->malloc_context_size = 1;
+  f->log_path = "stderr";
+  f->verbosity = 0;
+  f->detect_leaks = false;
+  f->leak_check_at_exit = true;
+  f->allocator_may_return_null = false;
+}
+
 void ParseCommonFlagsFromString(const char *str) {
   CommonFlags *f = common_flags();
   ParseFlag(str, &f->symbolize, "symbolize");
   ParseFlag(str, &f->external_symbolizer_path, "external_symbolizer_path");
-  ParseFlag(str, &f->malloc_context_size, "malloc_context_size");
   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->symbolize, "symbolize");
   ParseFlag(str, &f->handle_ioctl, "handle_ioctl");
+  ParseFlag(str, &f->malloc_context_size, "malloc_context_size");
   ParseFlag(str, &f->log_path, "log_path");
   ParseFlag(str, &f->verbosity, "verbosity");
   ParseFlag(str, &f->detect_leaks, "detect_leaks");

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h?rev=194479&r1=194478&r2=194479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h Tue Nov 12 07:59:08 2013
@@ -58,6 +58,7 @@ inline CommonFlags *common_flags() {
   return &f;
 }
 
+void SetCommonFlagDefaults();
 void ParseCommonFlagsFromString(const char *str);
 
 }  // namespace __sanitizer

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=194479&r1=194478&r2=194479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc Tue Nov 12 07:59:08 2013
@@ -91,21 +91,20 @@ void InitializeFlags(Flags *f, const cha
   f->history_size = kGoMode ? 1 : 2;  // There are a lot of goroutines in Go.
   f->io_sync = 1;
 
-  ParseCommonFlagsFromString("strip_path_prefix=");
-  ParseCommonFlagsFromString("log_path=stderr");
-  ParseCommonFlagsFromString("external_symbolizer_path=");
-  ParseCommonFlagsFromString("allocator_may_return_null=0");
-  ParseCommonFlagsFromString("verbosity=0");
-  *static_cast<CommonFlags*>(f) = *common_flags();
+  CommonFlags *cf = common_flags();
+  SetCommonFlagDefaults();
+  *static_cast<CommonFlags*>(f) = *cf;
 
   // Let a frontend override.
   OverrideFlags(f);
   ParseFlags(f, __tsan_default_options());
   ParseCommonFlagsFromString(__tsan_default_options());
-
   // Override from command line.
   ParseFlags(f, env);
+  ParseCommonFlagsFromString(env);
+  *static_cast<CommonFlags*>(f) = *cf;
 
+  // Sanity check.
   if (!f->report_bugs) {
     f->report_thread_leaks = false;
     f->report_destroy_locked = false;
@@ -123,10 +122,6 @@ void InitializeFlags(Flags *f, const cha
            " (must be [0..2])\n");
     Die();
   }
-
-  *common_flags() = *f;
-  ParseCommonFlagsFromString(env);
-  *static_cast<CommonFlags*>(f) = *common_flags();
 }
 
 }  // namespace __tsan





More information about the llvm-commits mailing list