]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/lsan/lsan.cc
Update LLDB snapshot to upstream r225923 (git 2b588ecd)
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / lsan / lsan.cc
1 //=-- lsan.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 a part of LeakSanitizer.
11 // Standalone LSan RTL.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "lsan.h"
16
17 #include "sanitizer_common/sanitizer_flags.h"
18 #include "sanitizer_common/sanitizer_stacktrace.h"
19 #include "lsan_allocator.h"
20 #include "lsan_common.h"
21 #include "lsan_thread.h"
22
23 bool lsan_inited;
24 bool lsan_init_is_running;
25
26 namespace __lsan {
27
28 ///// Interface to the common LSan module. /////
29 bool WordIsPoisoned(uptr addr) {
30   return false;
31 }
32
33 }  // namespace __lsan
34
35 using namespace __lsan;  // NOLINT
36
37 extern "C" void __lsan_init() {
38   CHECK(!lsan_init_is_running);
39   if (lsan_inited)
40     return;
41   lsan_init_is_running = true;
42   SanitizerToolName = "LeakSanitizer";
43   InitCommonLsan(true);
44   InitializeAllocator();
45   InitTlsSize();
46   InitializeInterceptors();
47   InitializeThreadRegistry();
48   u32 tid = ThreadCreate(0, 0, true);
49   CHECK_EQ(tid, 0);
50   ThreadStart(tid, GetTid());
51   SetCurrentThread(tid);
52
53   if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
54     Atexit(DoLeakCheck);
55   lsan_inited = true;
56   lsan_init_is_running = false;
57 }
58
59 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
60 void __sanitizer_print_stack_trace() {
61   GET_STACK_TRACE_FATAL;
62   stack.Print();
63 }