60 lines · cpp
1//===--- rtsan_flags.cpp - Realtime Sanitizer -------------------*- 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 RealtimeSanitizer.10//11//===----------------------------------------------------------------------===//12 13#include "rtsan/rtsan_flags.h"14#include "sanitizer_common/sanitizer_flag_parser.h"15#include "sanitizer_common/sanitizer_flags.h"16 17using namespace __sanitizer;18using namespace __rtsan;19 20Flags __rtsan::flags_data;21 22SANITIZER_INTERFACE_WEAK_DEF(const char *, __rtsan_default_options, void) {23 return "";24}25 26static void RegisterRtsanFlags(FlagParser *parser, Flags *f) {27#define RTSAN_FLAG(Type, Name, DefaultValue, Description) \28 RegisterFlag(parser, #Name, Description, &f->Name);29#include "rtsan_flags.inc"30#undef RTSAN_FLAG31}32 33void __rtsan::InitializeFlags() {34 SetCommonFlagsDefaults();35 {36 CommonFlags cf;37 cf.CopyFrom(*common_flags());38 cf.exitcode = 43;39 cf.external_symbolizer_path = GetEnv("RTSAN_SYMBOLIZER_PATH");40 OverrideCommonFlags(cf);41 }42 43 FlagParser parser;44 RegisterRtsanFlags(&parser, &flags());45 RegisterCommonFlags(&parser);46 47 // Override from user-specified string.48 parser.ParseString(__rtsan_default_options());49 50 parser.ParseStringFromEnv("RTSAN_OPTIONS");51 52 InitializeCommonFlags();53 54 if (Verbosity())55 ReportUnrecognizedFlags();56 57 if (common_flags()->help)58 parser.PrintFlagDescriptions();59}60