1 //===-- xray_basic_flags.cpp ------------------------------------*- 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 XRay, a dynamic runtime instrumentation system.
10 //
11 // XRay Basic flag parsing logic.
12 //===----------------------------------------------------------------------===//
13
14 #include "xray_basic_flags.h"
15 #include "sanitizer_common/sanitizer_common.h"
16 #include "sanitizer_common/sanitizer_flag_parser.h"
17 #include "sanitizer_common/sanitizer_libc.h"
18 #include "xray_defs.h"
19
20 using namespace __sanitizer;
21
22 namespace __xray {
23
24 /// Use via basicFlags().
25 BasicFlags xray_basic_flags_dont_use_directly;
26
setDefaults()27 void BasicFlags::setDefaults() XRAY_NEVER_INSTRUMENT {
28 #define XRAY_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
29 #include "xray_basic_flags.inc"
30 #undef XRAY_FLAG
31 }
32
registerXRayBasicFlags(FlagParser * P,BasicFlags * F)33 void registerXRayBasicFlags(FlagParser *P,
34 BasicFlags *F) XRAY_NEVER_INSTRUMENT {
35 #define XRAY_FLAG(Type, Name, DefaultValue, Description) \
36 RegisterFlag(P, #Name, Description, &F->Name);
37 #include "xray_basic_flags.inc"
38 #undef XRAY_FLAG
39 }
40
useCompilerDefinedBasicFlags()41 const char *useCompilerDefinedBasicFlags() XRAY_NEVER_INSTRUMENT {
42 #ifdef XRAY_BASIC_OPTIONS
43 return SANITIZER_STRINGIFY(XRAY_BASIC_OPTIONS);
44 #else
45 return "";
46 #endif
47 }
48
49 } // namespace __xray
50