diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/asan/asan_rtl.cc | 2 | ||||
-rw-r--r-- | lib/lsan/lsan.cc | 2 | ||||
-rw-r--r-- | lib/msan/msan.cc | 3 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer.h | 14 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc | 21 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc | 3 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer_win.cc | 2 | ||||
-rw-r--r-- | lib/tsan/rtl/tsan_rtl.cc | 3 |
8 files changed, 15 insertions, 35 deletions
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index b58a79708..ce799fc43 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -656,7 +656,7 @@ static void AsanInitInternal() { // fork() on Mac locks the allocator. InitializeAllocator(); - Symbolizer::Init(common_flags()->external_symbolizer_path); + Symbolizer::GetOrInit(); // On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited // should be set to 1 prior to initializing the threads. diff --git a/lib/lsan/lsan.cc b/lib/lsan/lsan.cc index 1b30b4f74..25389f62a 100644 --- a/lib/lsan/lsan.cc +++ b/lib/lsan/lsan.cc @@ -60,7 +60,7 @@ extern "C" void __lsan_init() { ThreadStart(tid, GetTid()); SetCurrentThread(tid); - Symbolizer::Init(common_flags()->external_symbolizer_path); + Symbolizer::GetOrInit(); InitCommonLsan(); if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) diff --git a/lib/msan/msan.cc b/lib/msan/msan.cc index fd7fdbba5..ba1bf8c7d 100644 --- a/lib/msan/msan.cc +++ b/lib/msan/msan.cc @@ -401,8 +401,7 @@ void __msan_init() { Die(); } - Symbolizer::Init(common_flags()->external_symbolizer_path); - Symbolizer::Get()->AddHooks(EnterSymbolizer, ExitSymbolizer); + Symbolizer::GetOrInit()->AddHooks(EnterSymbolizer, ExitSymbolizer); MsanTSDInit(MsanTSDDtor); diff --git a/lib/sanitizer_common/sanitizer_symbolizer.h b/lib/sanitizer_common/sanitizer_symbolizer.h index 7057a89e2..801afbf9c 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer.h +++ b/lib/sanitizer_common/sanitizer_symbolizer.h @@ -78,14 +78,9 @@ class Symbolizer { /// Returns platform-specific implementation of Symbolizer, or null if not /// initialized. static Symbolizer *GetOrNull(); - /// Returns platform-specific implementation of Symbolizer. Will - /// automatically initialize symbolizer as if by calling Init(0) if needed. + /// Initialize and return platform-specific implementation of symbolizer + /// (if it wasn't already initialized). static Symbolizer *GetOrInit(); - /// Initialize and return the symbolizer, given an optional path to an - /// external symbolizer. The path argument is only required for legacy - /// reasons as this function will check $PATH for an external symbolizer. Not - /// thread safe. - static Symbolizer *Init(const char* path_to_external = 0); // Fills at most "max_frames" elements of "frames" with descriptions // for a given address (in all inlined functions). Returns the number // of descriptions actually filled. @@ -122,10 +117,7 @@ class Symbolizer { private: /// Platform-specific function for creating a Symbolizer object. - static Symbolizer *PlatformInit(const char *path_to_external); - /// Create a symbolizer and store it to symbolizer_ without checking if one - /// already exists. Not thread safe. - static Symbolizer *CreateAndStore(const char *path_to_external); + static Symbolizer *PlatformInit(); /// Initialize the symbolizer in a disabled state. Not thread safe. static Symbolizer *Disable(); diff --git a/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc b/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc index b431e51e2..7ac7da7b2 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc +++ b/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc @@ -16,24 +16,13 @@ namespace __sanitizer { -Symbolizer *Symbolizer::CreateAndStore(const char *path_to_external) { - Symbolizer *platform_symbolizer = PlatformInit(path_to_external); - if (!platform_symbolizer) - return Disable(); - symbolizer_ = platform_symbolizer; - return platform_symbolizer; -} - -Symbolizer *Symbolizer::Init(const char *path_to_external) { - CHECK_EQ(0, symbolizer_); - return CreateAndStore(path_to_external); -} - Symbolizer *Symbolizer::GetOrInit() { SpinMutexLock l(&init_mu_); - if (symbolizer_ == 0) - return CreateAndStore(0); - return symbolizer_; + if (symbolizer_) + return symbolizer_; + if (symbolizer_ = PlatformInit()) + return symbolizer_; + return Disable(); } } // namespace __sanitizer diff --git a/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc b/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc index ddb9e1734..ec687b04f 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc +++ b/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc @@ -716,7 +716,7 @@ class POSIXSymbolizer : public Symbolizer { LibbacktraceSymbolizer *libbacktrace_symbolizer_; // Leaked. }; -Symbolizer *Symbolizer::PlatformInit(const char *path_to_external) { +Symbolizer *Symbolizer::PlatformInit() { if (!common_flags()->symbolize) { return new(symbolizer_allocator_) POSIXSymbolizer(0, 0, 0); } @@ -729,6 +729,7 @@ Symbolizer *Symbolizer::PlatformInit(const char *path_to_external) { libbacktrace_symbolizer = LibbacktraceSymbolizer::get(&symbolizer_allocator_); if (!libbacktrace_symbolizer) { + const char *path_to_external = common_flags()->external_symbolizer_path; if (path_to_external && path_to_external[0] == '\0') { // External symbolizer is explicitly disabled. Do nothing. } else { diff --git a/lib/sanitizer_common/sanitizer_symbolizer_win.cc b/lib/sanitizer_common/sanitizer_symbolizer_win.cc index a7acdb69b..4f203a437 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer_win.cc +++ b/lib/sanitizer_common/sanitizer_symbolizer_win.cc @@ -110,7 +110,7 @@ class WinSymbolizer : public Symbolizer { bool initialized_; }; -Symbolizer *Symbolizer::PlatformInit(const char *path_to_external) { +Symbolizer *Symbolizer::PlatformInit() { static bool called_once = false; CHECK(!called_once && "Shouldn't create more than one symbolizer"); called_once = true; diff --git a/lib/tsan/rtl/tsan_rtl.cc b/lib/tsan/rtl/tsan_rtl.cc index 1ebd7ecb5..1a25a5c18 100644 --- a/lib/tsan/rtl/tsan_rtl.cc +++ b/lib/tsan/rtl/tsan_rtl.cc @@ -306,8 +306,7 @@ void Initialize(ThreadState *thr) { InitializeSuppressions(); #ifndef TSAN_GO InitializeLibIgnore(); - Symbolizer::Init(common_flags()->external_symbolizer_path); - Symbolizer::Get()->AddHooks(EnterSymbolizer, ExitSymbolizer); + Symbolizer::GetOrInit()->AddHooks(EnterSymbolizer, ExitSymbolizer); #endif StartBackgroundThread(); #ifndef TSAN_GO |