sanitizer_flags.h 2.2 KB

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