summaryrefslogtreecommitdiff
path: root/libsanitizer/sanitizer_common/sanitizer_symbolizer.cc
diff options
context:
space:
mode:
authorkcc <kcc@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-05 09:18:38 +0000
committerkcc <kcc@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-05 09:18:38 +0000
commit4fc7b5acfc1d42a0701c8fff726a3ebe7f563dd9 (patch)
tree20d85354103063e38b162a6a90b7ae51fb4b6104 /libsanitizer/sanitizer_common/sanitizer_symbolizer.cc
parent50e6c257ee5ad435e3a736a1375ccc7639fd9244 (diff)
downloadgcc-4fc7b5acfc1d42a0701c8fff726a3ebe7f563dd9.tar.gz
libsanitizer merge from upstream r196090
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205695 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libsanitizer/sanitizer_common/sanitizer_symbolizer.cc')
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_symbolizer.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/libsanitizer/sanitizer_common/sanitizer_symbolizer.cc b/libsanitizer/sanitizer_common/sanitizer_symbolizer.cc
new file mode 100644
index 00000000000..f417b087ae2
--- /dev/null
+++ b/libsanitizer/sanitizer_common/sanitizer_symbolizer.cc
@@ -0,0 +1,61 @@
+//===-- sanitizer_symbolizer.cc -------------------------------------------===//
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is shared between AddressSanitizer and ThreadSanitizer
+// run-time libraries.
+//===----------------------------------------------------------------------===//
+
+#include "sanitizer_platform.h"
+#include "sanitizer_internal_defs.h"
+#include "sanitizer_placement_new.h"
+#include "sanitizer_symbolizer.h"
+
+namespace __sanitizer {
+
+Symbolizer *Symbolizer::symbolizer_;
+StaticSpinMutex Symbolizer::init_mu_;
+LowLevelAllocator Symbolizer::symbolizer_allocator_;
+
+Symbolizer *Symbolizer::GetOrNull() {
+ SpinMutexLock l(&init_mu_);
+ return symbolizer_;
+}
+
+Symbolizer *Symbolizer::Get() {
+ SpinMutexLock l(&init_mu_);
+ RAW_CHECK_MSG(symbolizer_ != 0, "Using uninitialized symbolizer!");
+ return symbolizer_;
+}
+
+Symbolizer *Symbolizer::Disable() {
+ CHECK_EQ(0, symbolizer_);
+ // Initialize a dummy symbolizer.
+ symbolizer_ = new(symbolizer_allocator_) Symbolizer;
+ return symbolizer_;
+}
+
+void Symbolizer::AddHooks(Symbolizer::StartSymbolizationHook start_hook,
+ Symbolizer::EndSymbolizationHook end_hook) {
+ CHECK(start_hook_ == 0 && end_hook_ == 0);
+ start_hook_ = start_hook;
+ end_hook_ = end_hook;
+}
+
+Symbolizer::Symbolizer() : start_hook_(0), end_hook_(0) {}
+
+Symbolizer::SymbolizerScope::SymbolizerScope(const Symbolizer *sym)
+ : sym_(sym) {
+ if (sym_->start_hook_)
+ sym_->start_hook_();
+}
+
+Symbolizer::SymbolizerScope::~SymbolizerScope() {
+ if (sym_->end_hook_)
+ sym_->end_hook_();
+}
+
+} // namespace __sanitizer