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