diff options
Diffstat (limited to 'libsanitizer/lsan/lsan.cc')
-rw-r--r-- | libsanitizer/lsan/lsan.cc | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/libsanitizer/lsan/lsan.cc b/libsanitizer/lsan/lsan.cc index 500da50622c..270979a78e7 100644 --- a/libsanitizer/lsan/lsan.cc +++ b/libsanitizer/lsan/lsan.cc @@ -18,26 +18,30 @@ #include "lsan_common.h" #include "lsan_thread.h" +bool lsan_inited; +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->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")); + ParseCommonFlagsFromString(cf, GetEnv("LSAN_OPTIONS")); } -void Init() { - static bool inited; - if (inited) +} // namespace __lsan + +using namespace __lsan; // NOLINT + +extern "C" void __lsan_init() { + CHECK(!lsan_init_is_running); + if (lsan_inited) return; - inited = true; + lsan_init_is_running = true; SanitizerToolName = "LeakSanitizer"; InitializeCommonFlags(); InitializeAllocator(); @@ -51,13 +55,14 @@ void Init() { // Start symbolizer process if necessary. if (common_flags()->symbolize) { - getSymbolizer() - ->InitializeExternal(common_flags()->external_symbolizer_path); + Symbolizer::Init(common_flags()->external_symbolizer_path); + } else { + Symbolizer::Disable(); } InitCommonLsan(); if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) Atexit(DoLeakCheck); + lsan_inited = true; + lsan_init_is_running = false; } - -} // namespace __lsan |