1 | //===--- rtsan_flags.cpp - Realtime Sanitizer -------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file is a part of RealtimeSanitizer. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "rtsan/rtsan_flags.h" |
14 | #include "sanitizer_common/sanitizer_flag_parser.h" |
15 | #include "sanitizer_common/sanitizer_flags.h" |
16 | |
17 | using namespace __sanitizer; |
18 | using namespace __rtsan; |
19 | |
20 | Flags __rtsan::flags_data; |
21 | |
22 | SANITIZER_INTERFACE_WEAK_DEF(const char *, __rtsan_default_options, void) { |
23 | return "" ; |
24 | } |
25 | |
26 | static void RegisterRtsanFlags(FlagParser *parser, Flags *f) { |
27 | #define RTSAN_FLAG(Type, Name, DefaultValue, Description) \ |
28 | RegisterFlag(parser, #Name, Description, &f->Name); |
29 | #include "rtsan_flags.inc" |
30 | #undef RTSAN_FLAG |
31 | } |
32 | |
33 | void __rtsan::InitializeFlags() { |
34 | SetCommonFlagsDefaults(); |
35 | { |
36 | CommonFlags cf; |
37 | cf.CopyFrom(other: *common_flags()); |
38 | cf.exitcode = 43; |
39 | cf.external_symbolizer_path = GetEnv(name: "RTSAN_SYMBOLIZER_PATH" ); |
40 | OverrideCommonFlags(cf); |
41 | } |
42 | |
43 | FlagParser parser; |
44 | RegisterRtsanFlags(parser: &parser, f: &flags()); |
45 | RegisterCommonFlags(parser: &parser); |
46 | |
47 | // Override from user-specified string. |
48 | parser.ParseString(s: __rtsan_default_options()); |
49 | |
50 | parser.ParseStringFromEnv(env_name: "RTSAN_OPTIONS" ); |
51 | |
52 | InitializeCommonFlags(); |
53 | |
54 | if (Verbosity()) |
55 | ReportUnrecognizedFlags(); |
56 | |
57 | if (common_flags()->help) |
58 | parser.PrintFlagDescriptions(); |
59 | } |
60 | |