1 //=-- lsan.cc -------------------------------------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of LeakSanitizer.
9 // Standalone LSan RTL.
11 //===----------------------------------------------------------------------===//
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"
22 bool lsan_init_is_running
;
26 ///// Interface to the common LSan module. /////
27 bool WordIsPoisoned(uptr addr
) {
33 using namespace __lsan
; // NOLINT
35 extern "C" void __lsan_init() {
36 CHECK(!lsan_init_is_running
);
39 lsan_init_is_running
= true;
40 SanitizerToolName
= "LeakSanitizer";
42 InitializeAllocator();
44 InitializeInterceptors();
45 InitializeThreadRegistry();
46 u32 tid
= ThreadCreate(0, 0, true);
48 ThreadStart(tid
, GetTid());
49 SetCurrentThread(tid
);
51 if (common_flags()->detect_leaks
&& common_flags()->leak_check_at_exit
)
54 lsan_init_is_running
= false;
57 extern "C" SANITIZER_INTERFACE_ATTRIBUTE
58 void __sanitizer_print_stack_trace() {
59 GET_STACK_TRACE_FATAL
;