diff options
-rw-r--r-- | lib/asan/asan_rtl.cc | 2 | ||||
-rw-r--r-- | lib/lsan/lsan.cc | 13 | ||||
-rw-r--r-- | lib/lsan/lsan_common.cc | 17 | ||||
-rw-r--r-- | lib/lsan/lsan_common.h | 2 | ||||
-rw-r--r-- | test/lsan/TestCases/ignore_object.cc | 2 | ||||
-rw-r--r-- | test/lsan/TestCases/ignore_object_errors.cc | 2 | ||||
-rw-r--r-- | test/lsan/TestCases/leak_check_at_exit.cc | 4 | ||||
-rw-r--r-- | test/lsan/TestCases/print_suppressions.cc | 4 | ||||
-rw-r--r-- | test/lsan/TestCases/suppressions_file.cc | 4 |
9 files changed, 25 insertions, 25 deletions
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index 2064a6101..c3cc1d3f3 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -680,7 +680,7 @@ static void AsanInitInternal() { SanitizerInitializeUnwinder(); #if CAN_SANITIZE_LEAKS - __lsan::InitCommonLsan(); + __lsan::InitCommonLsan(false); if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) { Atexit(__lsan::DoLeakCheck); } diff --git a/lib/lsan/lsan.cc b/lib/lsan/lsan.cc index 25389f62a..02b5ac1a9 100644 --- a/lib/lsan/lsan.cc +++ b/lib/lsan/lsan.cc @@ -25,16 +25,6 @@ bool lsan_init_is_running; namespace __lsan { -static void InitializeCommonFlags() { - CommonFlags *cf = common_flags(); - SetCommonFlagsDefaults(cf); - cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH"); - cf->malloc_context_size = 30; - cf->detect_leaks = true; - - ParseCommonFlagsFromString(cf, GetEnv("LSAN_OPTIONS")); -} - ///// Interface to the common LSan module. ///// bool WordIsPoisoned(uptr addr) { return false; @@ -50,7 +40,7 @@ extern "C" void __lsan_init() { return; lsan_init_is_running = true; SanitizerToolName = "LeakSanitizer"; - InitializeCommonFlags(); + InitCommonLsan(true); InitializeAllocator(); InitTlsSize(); InitializeInterceptors(); @@ -62,7 +52,6 @@ extern "C" void __lsan_init() { Symbolizer::GetOrInit(); - InitCommonLsan(); if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) Atexit(DoLeakCheck); lsan_inited = true; diff --git a/lib/lsan/lsan_common.cc b/lib/lsan/lsan_common.cc index 62fab033b..27cb52f69 100644 --- a/lib/lsan/lsan_common.cc +++ b/lib/lsan/lsan_common.cc @@ -36,7 +36,7 @@ bool DisabledInThisThread() { return disable_counter > 0; } Flags lsan_flags; -static void InitializeFlags() { +static void InitializeFlags(bool standalone) { Flags *f = flags(); // Default values. f->report_objects = false; @@ -71,6 +71,17 @@ static void InitializeFlags() { ParseFlag(options, &f->log_threads, "log_threads", ""); ParseFlag(options, &f->exitcode, "exitcode", ""); } + + // Set defaults for common flags (only in standalone mode) and parse + // them from LSAN_OPTIONS. + CommonFlags *cf = common_flags(); + if (standalone) { + SetCommonFlagsDefaults(cf); + cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH"); + cf->malloc_context_size = 30; + cf->detect_leaks = true; + } + ParseCommonFlagsFromString(cf, options); } #define LOG_POINTERS(...) \ @@ -106,8 +117,8 @@ void InitializeRootRegions() { root_regions = new(placeholder) InternalMmapVector<RootRegion>(1); } -void InitCommonLsan() { - InitializeFlags(); +void InitCommonLsan(bool standalone) { + InitializeFlags(standalone); InitializeRootRegions(); if (common_flags()->detect_leaks) { // Initialization which can fail or print warnings should only be done if diff --git a/lib/lsan/lsan_common.h b/lib/lsan/lsan_common.h index 6f9fea47b..86ff12da6 100644 --- a/lib/lsan/lsan_common.h +++ b/lib/lsan/lsan_common.h @@ -131,7 +131,7 @@ enum IgnoreObjectResult { }; // Functions called from the parent tool. -void InitCommonLsan(); +void InitCommonLsan(bool standalone); void DoLeakCheck(); bool DisabledInThisThread(); diff --git a/test/lsan/TestCases/ignore_object.cc b/test/lsan/TestCases/ignore_object.cc index 133ccc75f..38d76e679 100644 --- a/test/lsan/TestCases/ignore_object.cc +++ b/test/lsan/TestCases/ignore_object.cc @@ -1,7 +1,7 @@ // Test for __lsan_ignore_object(). // RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=0:verbosity=2" // RUN: %clangxx_lsan %s -o %t -// RUN: LSAN_OPTIONS=$LSAN_BASE ASAN_OPTIONS=$ASAN_OPTIONS:"verbosity=2" not %run %t 2>&1 | FileCheck %s +// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s #include <stdio.h> #include <stdlib.h> diff --git a/test/lsan/TestCases/ignore_object_errors.cc b/test/lsan/TestCases/ignore_object_errors.cc index 7ca2a4f82..39b9b0288 100644 --- a/test/lsan/TestCases/ignore_object_errors.cc +++ b/test/lsan/TestCases/ignore_object_errors.cc @@ -1,7 +1,7 @@ // Test for incorrect use of __lsan_ignore_object(). // RUN: LSAN_BASE="verbosity=2" // RUN: %clangxx_lsan %s -o %t -// RUN: LSAN_OPTIONS=$LSAN_BASE ASAN_OPTIONS=$ASAN_OPTIONS:verbosity=2 %run %t 2>&1 | FileCheck %s +// RUN: LSAN_OPTIONS=$LSAN_BASE %run %t 2>&1 | FileCheck %s #include <stdio.h> #include <stdlib.h> diff --git a/test/lsan/TestCases/leak_check_at_exit.cc b/test/lsan/TestCases/leak_check_at_exit.cc index 3e4ccd782..fe3f70e40 100644 --- a/test/lsan/TestCases/leak_check_at_exit.cc +++ b/test/lsan/TestCases/leak_check_at_exit.cc @@ -3,8 +3,8 @@ // RUN: %clangxx_lsan %s -o %t // RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do // RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-do -// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0" ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do -// RUN: LSAN_OPTIONS=%LSAN_BASE:"leak_check_at_exit=0" ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont +// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0" not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do +// RUN: LSAN_OPTIONS=%LSAN_BASE:"leak_check_at_exit=0" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont #include <stdio.h> #include <stdlib.h> diff --git a/test/lsan/TestCases/print_suppressions.cc b/test/lsan/TestCases/print_suppressions.cc index e0e8858f5..b292c0a7c 100644 --- a/test/lsan/TestCases/print_suppressions.cc +++ b/test/lsan/TestCases/print_suppressions.cc @@ -2,9 +2,9 @@ // matched. Default is print_suppressions=true. // RUN: LSAN_BASE="use_registers=0:use_stacks=0" // RUN: %clangxx_lsan %s -o %t -// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 ASAN_OPTIONS=$ASAN_OPTIONS:print_suppressions=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print +// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print // RUN: LSAN_OPTIONS=$LSAN_BASE %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print -// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 ASAN_OPTIONS=$ASAN_OPTIONS:print_suppressions=0 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print +// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print // RUN: LSAN_OPTIONS=$LSAN_BASE %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-print #include <stdio.h> diff --git a/test/lsan/TestCases/suppressions_file.cc b/test/lsan/TestCases/suppressions_file.cc index 4087d931e..16ad93234 100644 --- a/test/lsan/TestCases/suppressions_file.cc +++ b/test/lsan/TestCases/suppressions_file.cc @@ -2,10 +2,10 @@ // RUN: %clangxx_lsan %s -o %t // RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp1 -// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions=%t.supp1 ASAN_OPTIONS=$ASAN_OPTIONS:suppressions=%t.supp1 not %run %t 2>&1 | FileCheck %s +// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions=%t.supp1 not %run %t 2>&1 | FileCheck %s // RUN: echo "leak:%t" > %t.supp2 -// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions="%t.supp2":symbolize=false ASAN_OPTIONS=$ASAN_OPTIONS:suppressions="%t.supp2" %run %t +// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions="%t.supp2":symbolize=false %run %t #include <stdio.h> #include <stdlib.h> |