| 54 | using namespace __lsan; |
| 55 | |
| 56 | static void InitializeFlags() { |
| 57 | // Set all the default values. |
| 58 | SetCommonFlagsDefaults(); |
| 59 | { |
| 60 | CommonFlags cf; |
| 61 | cf.CopyFrom(*common_flags()); |
| 62 | #if !SANITIZER_EMSCRIPTEN |
| 63 | // getenv on emscripten uses malloc, which we can't when using LSan. |
| 64 | // You can't run external symbolizers anyway. |
| 65 | cf.external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH"); |
| 66 | #endif |
| 67 | cf.malloc_context_size = 30; |
| 68 | cf.intercept_tls_get_addr = true; |
| 69 | cf.detect_leaks = true; |
| 70 | cf.exitcode = 23; |
| 71 | OverrideCommonFlags(cf); |
| 72 | } |
| 73 | |
| 74 | Flags *f = flags(); |
| 75 | f->SetDefaults(); |
| 76 | |
| 77 | FlagParser parser; |
| 78 | RegisterLsanFlags(&parser, f); |
| 79 | RegisterCommonFlags(&parser); |
| 80 | |
| 81 | // Override from user-specified string. |
| 82 | const char *lsan_default_options = __lsan_default_options(); |
| 83 | parser.ParseString(lsan_default_options); |
| 84 | #if SANITIZER_EMSCRIPTEN |
| 85 | char *options = _emscripten_sanitizer_get_option("LSAN_OPTIONS"); |
| 86 | parser.ParseString(options); |
| 87 | free(options); |
| 88 | #else |
| 89 | parser.ParseString(GetEnv("LSAN_OPTIONS")); |
| 90 | #endif // SANITIZER_EMSCRIPTEN |
| 91 | |
| 92 | #if SANITIZER_EMSCRIPTEN |
| 93 | if (common_flags()->malloc_context_size <= 1) |
| 94 | StackTrace::snapshot_stack = false; |
| 95 | #endif // SANITIZER_EMSCRIPTEN |
| 96 | |
| 97 | InitializeCommonFlags(); |
| 98 | |
| 99 | if (Verbosity()) ReportUnrecognizedFlags(); |
| 100 | |
| 101 | if (common_flags()->help) parser.PrintFlagDescriptions(); |
| 102 | |
| 103 | __sanitizer_set_report_path(common_flags()->log_path); |
| 104 | } |
| 105 | |
| 106 | extern "C" void __lsan_init() { |
| 107 | CHECK(!lsan_init_is_running); |
no test coverage detected