* gcc.dg/c11-complex-1.c: Use dg-add-options ieee.
[official-gcc.git] / libsanitizer / lsan / lsan.cc
blob500da50622c85706de41a3afb704d7564c084f32
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 namespace __lsan {
23 static void InitializeCommonFlags() {
24 CommonFlags *cf = common_flags();
25 cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
26 cf->symbolize = true;
27 cf->strip_path_prefix = "";
28 cf->fast_unwind_on_malloc = true;
29 cf->malloc_context_size = 30;
30 cf->detect_leaks = true;
31 cf->leak_check_at_exit = true;
33 ParseCommonFlagsFromString(GetEnv("LSAN_OPTIONS"));
36 void Init() {
37 static bool inited;
38 if (inited)
39 return;
40 inited = true;
41 SanitizerToolName = "LeakSanitizer";
42 InitializeCommonFlags();
43 InitializeAllocator();
44 InitTlsSize();
45 InitializeInterceptors();
46 InitializeThreadRegistry();
47 u32 tid = ThreadCreate(0, 0, true);
48 CHECK_EQ(tid, 0);
49 ThreadStart(tid, GetTid());
50 SetCurrentThread(tid);
52 // Start symbolizer process if necessary.
53 if (common_flags()->symbolize) {
54 getSymbolizer()
55 ->InitializeExternal(common_flags()->external_symbolizer_path);
58 InitCommonLsan();
59 if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
60 Atexit(DoLeakCheck);
63 } // namespace __lsan