1 //===-- sanitizer_symbolizer.cc -------------------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is shared between AddressSanitizer and ThreadSanitizer
10 //===----------------------------------------------------------------------===//
12 #include "sanitizer_platform.h"
13 #include "sanitizer_internal_defs.h"
14 #include "sanitizer_placement_new.h"
15 #include "sanitizer_symbolizer.h"
17 namespace __sanitizer
{
19 Symbolizer
*Symbolizer::symbolizer_
;
20 StaticSpinMutex
Symbolizer::init_mu_
;
21 LowLevelAllocator
Symbolizer::symbolizer_allocator_
;
23 Symbolizer
*Symbolizer::GetOrNull() {
24 SpinMutexLock
l(&init_mu_
);
28 Symbolizer
*Symbolizer::Get() {
29 SpinMutexLock
l(&init_mu_
);
30 RAW_CHECK_MSG(symbolizer_
!= 0, "Using uninitialized symbolizer!");
34 Symbolizer
*Symbolizer::Disable() {
35 CHECK_EQ(0, symbolizer_
);
36 // Initialize a dummy symbolizer.
37 symbolizer_
= new(symbolizer_allocator_
) Symbolizer
;
41 void Symbolizer::AddHooks(Symbolizer::StartSymbolizationHook start_hook
,
42 Symbolizer::EndSymbolizationHook end_hook
) {
43 CHECK(start_hook_
== 0 && end_hook_
== 0);
44 start_hook_
= start_hook
;
48 Symbolizer::Symbolizer() : start_hook_(0), end_hook_(0) {}
50 Symbolizer::SymbolizerScope::SymbolizerScope(const Symbolizer
*sym
)
52 if (sym_
->start_hook_
)
56 Symbolizer::SymbolizerScope::~SymbolizerScope() {
61 } // namespace __sanitizer