xref: /freebsd/contrib/llvm-project/compiler-rt/lib/xray/xray_fdr_flags.cpp (revision 3078531de10dcae44b253a35125c949ff4235284)
1 //===-- xray_fdr_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 FDR flag parsing logic.
12 //===----------------------------------------------------------------------===//
13 
14 #include "xray_fdr_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 FDRFlags xray_fdr_flags_dont_use_directly; // use via fdrFlags().
25 
26 void FDRFlags::setDefaults() XRAY_NEVER_INSTRUMENT {
27 #define XRAY_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
28 #include "xray_fdr_flags.inc"
29 #undef XRAY_FLAG
30 }
31 
32 void registerXRayFDRFlags(FlagParser *P, FDRFlags *F) XRAY_NEVER_INSTRUMENT {
33 #define XRAY_FLAG(Type, Name, DefaultValue, Description)                       \
34   RegisterFlag(P, #Name, Description, &F->Name);
35 #include "xray_fdr_flags.inc"
36 #undef XRAY_FLAG
37 }
38 
39 const char *useCompilerDefinedFDRFlags() XRAY_NEVER_INSTRUMENT {
40 #ifdef XRAY_FDR_OPTIONS
41   return SANITIZER_STRINGIFY(XRAY_FDR_OPTIONS);
42 #else
43   return "";
44 #endif
45 }
46 
47 } // namespace __xray
48