Add C++11 header <cuchar>.
[official-gcc.git] / libsanitizer / lsan / lsan.cc
blob61792d9c9ea08c0b678bb39631442fa78b8961f1
1 //=-- lsan.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 a part of LeakSanitizer.
9 // Standalone LSan RTL.
11 //===----------------------------------------------------------------------===//
13 #include "lsan.h"
15 #include "sanitizer_common/sanitizer_flags.h"
16 #include "sanitizer_common/sanitizer_stacktrace.h"
17 #include "lsan_allocator.h"
18 #include "lsan_common.h"
19 #include "lsan_thread.h"
21 bool lsan_inited;
22 bool lsan_init_is_running;
24 namespace __lsan {
26 ///// Interface to the common LSan module. /////
27 bool WordIsPoisoned(uptr addr) {
28 return false;
31 } // namespace __lsan
33 using namespace __lsan; // NOLINT
35 extern "C" void __lsan_init() {
36 CHECK(!lsan_init_is_running);
37 if (lsan_inited)
38 return;
39 lsan_init_is_running = true;
40 SanitizerToolName = "LeakSanitizer";
41 InitCommonLsan(true);
42 InitializeAllocator();
43 InitTlsSize();
44 InitializeInterceptors();
45 InitializeThreadRegistry();
46 u32 tid = ThreadCreate(0, 0, true);
47 CHECK_EQ(tid, 0);
48 ThreadStart(tid, GetTid());
49 SetCurrentThread(tid);
51 if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
52 Atexit(DoLeakCheck);
53 lsan_inited = true;
54 lsan_init_is_running = false;
57 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
58 void __sanitizer_print_stack_trace() {
59 GET_STACK_TRACE_FATAL;
60 stack.Print();