[ASan/Win tests] Bring back -GS- as SEH tests fail otherwise
[blocksruntime.git] / lib / lsan / lsan.cc
blob1b30b4f74c7082b7c4a29c7042f0be3ef15df415
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.
13 //===----------------------------------------------------------------------===//
15 #include "lsan.h"
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"
23 bool lsan_inited;
24 bool lsan_init_is_running;
26 namespace __lsan {
28 static void InitializeCommonFlags() {
29 CommonFlags *cf = common_flags();
30 SetCommonFlagsDefaults(cf);
31 cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
32 cf->malloc_context_size = 30;
33 cf->detect_leaks = true;
35 ParseCommonFlagsFromString(cf, GetEnv("LSAN_OPTIONS"));
38 ///// Interface to the common LSan module. /////
39 bool WordIsPoisoned(uptr addr) {
40 return false;
43 } // namespace __lsan
45 using namespace __lsan; // NOLINT
47 extern "C" void __lsan_init() {
48 CHECK(!lsan_init_is_running);
49 if (lsan_inited)
50 return;
51 lsan_init_is_running = true;
52 SanitizerToolName = "LeakSanitizer";
53 InitializeCommonFlags();
54 InitializeAllocator();
55 InitTlsSize();
56 InitializeInterceptors();
57 InitializeThreadRegistry();
58 u32 tid = ThreadCreate(0, 0, true);
59 CHECK_EQ(tid, 0);
60 ThreadStart(tid, GetTid());
61 SetCurrentThread(tid);
63 Symbolizer::Init(common_flags()->external_symbolizer_path);
65 InitCommonLsan();
66 if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
67 Atexit(DoLeakCheck);
68 lsan_inited = true;
69 lsan_init_is_running = false;