1 //===-- sanitizer_flags.h ---------------------------------------*- 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 ThreadSanitizer/AddressSanitizer runtime. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef SANITIZER_FLAGS_H 14 #define SANITIZER_FLAGS_H 15 16 #include "sanitizer_internal_defs.h" 17 18 namespace __sanitizer { 19 20 enum HandleSignalMode { 21 kHandleSignalNo, 22 kHandleSignalYes, 23 kHandleSignalExclusive, 24 }; 25 26 struct CommonFlags { 27 #define COMMON_FLAG(Type, Name, DefaultValue, Description) Type Name; 28 #include "sanitizer_flags.inc" 29 #undef COMMON_FLAG 30 31 void SetDefaults(); 32 void CopyFrom(const CommonFlags &other); 33 }; 34 35 // Functions to get/set global CommonFlags shared by all sanitizer runtimes: 36 extern CommonFlags common_flags_dont_use; 37 inline const CommonFlags *common_flags() { 38 return &common_flags_dont_use; 39 } 40 41 inline void SetCommonFlagsDefaults() { 42 common_flags_dont_use.SetDefaults(); 43 } 44 45 // This function can only be used to setup tool-specific overrides for 46 // CommonFlags defaults. Generally, it should only be used right after 47 // SetCommonFlagsDefaults(), but before ParseCommonFlagsFromString(), and 48 // only during the flags initialization (i.e. before they are used for 49 // the first time). 50 inline void OverrideCommonFlags(const CommonFlags &cf) { 51 common_flags_dont_use.CopyFrom(cf); 52 } 53 54 void SubstituteForFlagValue(const char *s, char *out, uptr out_size); 55 56 class FlagParser; 57 void RegisterCommonFlags(FlagParser *parser, 58 CommonFlags *cf = &common_flags_dont_use); 59 void RegisterIncludeFlags(FlagParser *parser, CommonFlags *cf); 60 61 // Should be called after parsing all flags. Sets up common flag values 62 // and perform initializations common to all sanitizers (e.g. setting 63 // verbosity). 64 void InitializeCommonFlags(CommonFlags *cf = &common_flags_dont_use); 65 } // namespace __sanitizer 66 67 #endif // SANITIZER_FLAGS_H 68