1//===-- sanitizer_symbolizer_libcdep.cc -----------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file is shared between AddressSanitizer and ThreadSanitizer
11// run-time libraries.
12//===----------------------------------------------------------------------===//
13
14#include "sanitizer_internal_defs.h"
15#include "sanitizer_symbolizer.h"
16
17namespace __sanitizer {
18
19Symbolizer *Symbolizer::CreateAndStore(const char *path_to_external) {
20  Symbolizer *platform_symbolizer = PlatformInit(path_to_external);
21  if (!platform_symbolizer)
22    return Disable();
23  symbolizer_ = platform_symbolizer;
24  return platform_symbolizer;
25}
26
27Symbolizer *Symbolizer::Init(const char *path_to_external) {
28  CHECK_EQ(0, symbolizer_);
29  return CreateAndStore(path_to_external);
30}
31
32Symbolizer *Symbolizer::GetOrInit() {
33  SpinMutexLock l(&init_mu_);
34  if (symbolizer_ == 0)
35    return CreateAndStore(0);
36  return symbolizer_;
37}
38
39}  // namespace __sanitizer
40