* config/nvptx/nvptx.c (nvptx_reorg): Remove unused vars. Fix
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_symbolizer.cc
blob6821e5a326272a170340c79d178c8b092c2b9897
1 //===-- sanitizer_symbolizer.cc -------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is shared between AddressSanitizer and ThreadSanitizer
9 // run-time libraries.
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::Disable() {
24 CHECK_EQ(0, symbolizer_);
25 // Initialize a dummy symbolizer.
26 symbolizer_ = new(symbolizer_allocator_) Symbolizer;
27 return symbolizer_;
30 void Symbolizer::AddHooks(Symbolizer::StartSymbolizationHook start_hook,
31 Symbolizer::EndSymbolizationHook end_hook) {
32 CHECK(start_hook_ == 0 && end_hook_ == 0);
33 start_hook_ = start_hook;
34 end_hook_ = end_hook;
37 Symbolizer::Symbolizer() : start_hook_(0), end_hook_(0) {}
39 Symbolizer::SymbolizerScope::SymbolizerScope(const Symbolizer *sym)
40 : sym_(sym) {
41 if (sym_->start_hook_)
42 sym_->start_hook_();
45 Symbolizer::SymbolizerScope::~SymbolizerScope() {
46 if (sym_->end_hook_)
47 sym_->end_hook_();
50 } // namespace __sanitizer