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"
23 static void InitializeCommonFlags() {
24 CommonFlags
*cf
= common_flags();
25 cf
->external_symbolizer_path
= GetEnv("LSAN_SYMBOLIZER_PATH");
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"));
41 SanitizerToolName
= "LeakSanitizer";
42 InitializeCommonFlags();
43 InitializeAllocator();
45 InitializeInterceptors();
46 InitializeThreadRegistry();
47 u32 tid
= ThreadCreate(0, 0, true);
49 ThreadStart(tid
, GetTid());
50 SetCurrentThread(tid
);
52 // Start symbolizer process if necessary.
53 if (common_flags()->symbolize
) {
55 ->InitializeExternal(common_flags()->external_symbolizer_path
);
59 if (common_flags()->detect_leaks
&& common_flags()->leak_check_at_exit
)