1 //=-- lsan.cc -------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of LeakSanitizer.
11 // Standalone LSan RTL.
13 //===----------------------------------------------------------------------===//
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"
24 bool lsan_init_is_running;
28 ///// Interface to the common LSan module. /////
29 bool WordIsPoisoned(uptr addr) {
35 using namespace __lsan; // NOLINT
37 extern "C" void __lsan_init() {
38 CHECK(!lsan_init_is_running);
41 lsan_init_is_running = true;
42 SanitizerToolName = "LeakSanitizer";
44 InitializeAllocator();
46 InitializeInterceptors();
47 InitializeThreadRegistry();
48 u32 tid = ThreadCreate(0, 0, true);
50 ThreadStart(tid, GetTid());
51 SetCurrentThread(tid);
53 if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
56 lsan_init_is_running = false;
59 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
60 void __sanitizer_print_stack_trace() {
61 GET_STACK_TRACE_FATAL;