diff options
author | Sergey Matveev <earthdok@google.com> | 2013-05-06 11:27:58 +0000 |
---|---|---|
committer | Sergey Matveev <earthdok@google.com> | 2013-05-06 11:27:58 +0000 |
commit | 0c8ed9ce4446eddfc33977f92cd415f5cabdc5cf (patch) | |
tree | 66602358f607bb2232799b0010ea2fc03325191c /compiler-rt/lib/asan/asan_rtl.cc | |
parent | 509c240ce5ef67d1bc9727841e1c827cb5d6b569 (diff) | |
download | bcm5719-llvm-0c8ed9ce4446eddfc33977f92cd415f5cabdc5cf.tar.gz bcm5719-llvm-0c8ed9ce4446eddfc33977f92cd415f5cabdc5cf.zip |
[asan] Common flags in ASan.
Some flags that are common to ASan/MSan/TSan/LSan have been moved to
sanitizer_common.
llvm-svn: 181193
Diffstat (limited to 'compiler-rt/lib/asan/asan_rtl.cc')
-rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 03158f31b5b..e05f15382bd 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -84,8 +84,10 @@ static const char *MaybeUseAsanDefaultOptionsCompileDefiniton() { } static void ParseFlagsFromString(Flags *f, const char *str) { + ParseCommonFlagsFromString(str); + CHECK((uptr)common_flags()->malloc_context_size <= kStackTraceMax); + ParseFlag(str, &f->quarantine_size, "quarantine_size"); - ParseFlag(str, &f->symbolize, "symbolize"); ParseFlag(str, &f->verbosity, "verbosity"); ParseFlag(str, &f->redzone, "redzone"); CHECK_GE(f->redzone, 16); @@ -94,8 +96,6 @@ static void ParseFlagsFromString(Flags *f, const char *str) { ParseFlag(str, &f->debug, "debug"); ParseFlag(str, &f->report_globals, "report_globals"); ParseFlag(str, &f->check_initialization_order, "check_initialization_order"); - ParseFlag(str, &f->malloc_context_size, "malloc_context_size"); - CHECK((uptr)f->malloc_context_size <= kStackTraceMax); ParseFlag(str, &f->replace_str, "replace_str"); ParseFlag(str, &f->replace_intrin, "replace_intrin"); @@ -116,12 +116,9 @@ static void ParseFlagsFromString(Flags *f, const char *str) { ParseFlag(str, &f->print_legend, "print_legend"); ParseFlag(str, &f->atexit, "atexit"); ParseFlag(str, &f->disable_core, "disable_core"); - ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix"); ParseFlag(str, &f->allow_reexec, "allow_reexec"); ParseFlag(str, &f->print_full_thread_history, "print_full_thread_history"); ParseFlag(str, &f->log_path, "log_path"); - 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->poison_heap, "poison_heap"); ParseFlag(str, &f->alloc_dealloc_mismatch, "alloc_dealloc_mismatch"); ParseFlag(str, &f->use_stack_depot, "use_stack_depot"); @@ -129,19 +126,22 @@ static void ParseFlagsFromString(Flags *f, const char *str) { ParseFlag(str, &f->strict_init_order, "strict_init_order"); } -static const char *asan_external_symbolizer; - void InitializeFlags(Flags *f, const char *env) { - internal_memset(f, 0, sizeof(*f)); + CommonFlags *cf = common_flags(); + cf->external_symbolizer_path = GetEnv("ASAN_SYMBOLIZER_PATH"); + cf->symbolize = (cf->external_symbolizer_path != 0); + cf->malloc_context_size = kDefaultMallocContextSize; + cf->fast_unwind_on_fatal = false; + cf->fast_unwind_on_malloc = true; + cf->strip_path_prefix = ""; + internal_memset(f, 0, sizeof(*f)); f->quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 26 : 1UL << 28; - f->symbolize = (asan_external_symbolizer != 0); f->verbosity = 0; f->redzone = 16; f->debug = false; f->report_globals = 1; f->check_initialization_order = false; - f->malloc_context_size = kDefaultMallocContextSize; f->replace_str = true; f->replace_intrin = true; f->mac_ignore_invalid_free = false; @@ -161,17 +161,14 @@ void InitializeFlags(Flags *f, const char *env) { f->print_legend = true; f->atexit = false; f->disable_core = (SANITIZER_WORDSIZE == 64); - f->strip_path_prefix = ""; f->allow_reexec = true; f->print_full_thread_history = true; f->log_path = 0; - f->fast_unwind_on_fatal = false; - f->fast_unwind_on_malloc = true; f->poison_heap = true; // Turn off alloc/dealloc mismatch checker on Mac for now. // TODO(glider): Fix known issues and enable this back. f->alloc_dealloc_mismatch = (SANITIZER_MAC == 0);; - f->use_stack_depot = true; // Only affects allocator2. + f->use_stack_depot = true; f->strict_memcmp = true; f->strict_init_order = false; @@ -371,7 +368,8 @@ static void PrintAddressSpaceLayout() { } Printf("\n"); Printf("red_zone=%zu\n", (uptr)flags()->redzone); - Printf("malloc_context_size=%zu\n", (uptr)flags()->malloc_context_size); + Printf("malloc_context_size=%zu\n", + (uptr)common_flags()->malloc_context_size); Printf("SHADOW_SCALE: %zx\n", (uptr)SHADOW_SCALE); Printf("SHADOW_GRANULARITY: %zx\n", (uptr)SHADOW_GRANULARITY); @@ -430,8 +428,6 @@ void __asan_init() { SetCheckFailedCallback(AsanCheckFailed); SetPrintfAndReportCallback(AppendToErrorMessageBuffer); - // Check if external symbolizer is defined before parsing the flags. - asan_external_symbolizer = GetEnv("ASAN_SYMBOLIZER_PATH"); // Initialize flags. This must be done early, because most of the // initialization steps look at flags(). const char *options = GetEnv("ASAN_OPTIONS"); @@ -509,9 +505,10 @@ void __asan_init() { InstallSignalHandlers(); // Start symbolizer process if necessary. - if (flags()->symbolize && asan_external_symbolizer && - asan_external_symbolizer[0]) { - InitializeExternalSymbolizer(asan_external_symbolizer); + const char* external_symbolizer = common_flags()->external_symbolizer_path; + if (common_flags()->symbolize && external_symbolizer && + external_symbolizer[0]) { + InitializeExternalSymbolizer(external_symbolizer); } // On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited |