diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-02-22 22:43:40 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-02-22 22:43:40 +0000 |
commit | cd2dd3df15523e2be8d2bbace27641d6ac9fa40d (patch) | |
tree | fbdacaec253cc5ceee88cb44de5545fa32c8bd67 /lib/asan/asan_flags.cc | |
parent | 476c4db3dc56bee43df384704c75ccc71cfa7a1d (diff) | |
download | src-cd2dd3df15523e2be8d2bbace27641d6ac9fa40d.tar.gz src-cd2dd3df15523e2be8d2bbace27641d6ac9fa40d.zip |
Import compiler-rt trunk r230183.vendor/compiler-rt/compiler-rt-r230183
Notes
Notes:
svn path=/vendor/compiler-rt/dist/; revision=279192
svn path=/vendor/compiler-rt/compiler-rt-r230183/; revision=279193; tag=vendor/compiler-rt/compiler-rt-r230183
Diffstat (limited to 'lib/asan/asan_flags.cc')
-rw-r--r-- | lib/asan/asan_flags.cc | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/lib/asan/asan_flags.cc b/lib/asan/asan_flags.cc index 1d82ab0e725f..efb7767d5d91 100644 --- a/lib/asan/asan_flags.cc +++ b/lib/asan/asan_flags.cc @@ -46,18 +46,15 @@ void Flags::SetDefaults() { #undef ASAN_FLAG } -void RegisterAsanFlags(FlagParser *parser, Flags *f) { +static void RegisterAsanFlags(FlagParser *parser, Flags *f) { #define ASAN_FLAG(Type, Name, DefaultValue, Description) \ RegisterFlag(parser, #Name, Description, &f->Name); #include "asan_flags.inc" #undef ASAN_FLAG } -void InitializeFlags(Flags *f) { - FlagParser parser; - RegisterAsanFlags(&parser, f); - RegisterCommonFlags(&parser); - +void InitializeFlags() { + // Set the default values and prepare for parsing ASan and common flags. SetCommonFlagsDefaults(); { CommonFlags cf; @@ -68,28 +65,44 @@ void InitializeFlags(Flags *f) { cf.intercept_tls_get_addr = true; OverrideCommonFlags(cf); } - - const int kDefaultQuarantineSizeMb = (ASAN_LOW_MEMORY) ? 1UL << 6 : 1UL << 8; + Flags *f = flags(); f->SetDefaults(); - // Override from compile definition. - const char *compile_def = MaybeUseAsanDefaultOptionsCompileDefinition(); - parser.ParseString(compile_def); + FlagParser asan_parser; + RegisterAsanFlags(&asan_parser, f); + RegisterCommonFlags(&asan_parser); + + // Set the default values and prepare for parsing LSan flags (which can also + // overwrite common flags). +#if CAN_SANITIZE_LEAKS + __lsan::Flags *lf = __lsan::flags(); + lf->SetDefaults(); + + FlagParser lsan_parser; + __lsan::RegisterLsanFlags(&lsan_parser, lf); + RegisterCommonFlags(&lsan_parser); +#endif + + // Override from ASan compile definition. + const char *asan_compile_def = MaybeUseAsanDefaultOptionsCompileDefinition(); + asan_parser.ParseString(asan_compile_def); // Override from user-specified string. - const char *default_options = MaybeCallAsanDefaultOptions(); - parser.ParseString(default_options); + const char *asan_default_options = MaybeCallAsanDefaultOptions(); + asan_parser.ParseString(asan_default_options); // Override from command line. - const char *env = GetEnv("ASAN_OPTIONS"); - if (env) parser.ParseString(env); + asan_parser.ParseString(GetEnv("ASAN_OPTIONS")); +#if CAN_SANITIZE_LEAKS + lsan_parser.ParseString(GetEnv("LSAN_OPTIONS")); +#endif // Let activation flags override current settings. On Android they come // from a system property. On other platforms this is no-op. if (!flags()->start_deactivated) { char buf[100]; GetExtraActivationFlags(buf, sizeof(buf)); - parser.ParseString(buf); + asan_parser.ParseString(buf); } SetVerbosity(common_flags()->verbosity); @@ -97,7 +110,10 @@ void InitializeFlags(Flags *f) { // TODO(eugenis): dump all flags at verbosity>=2? if (Verbosity()) ReportUnrecognizedFlags(); - if (common_flags()->help) parser.PrintFlagDescriptions(); + if (common_flags()->help) { + // TODO(samsonov): print all of the flags (ASan, LSan, common). + asan_parser.PrintFlagDescriptions(); + } // Flag validation: if (!CAN_SANITIZE_LEAKS && common_flags()->detect_leaks) { @@ -127,8 +143,11 @@ void InitializeFlags(Flags *f) { } if (f->quarantine_size >= 0) f->quarantine_size_mb = f->quarantine_size >> 20; - if (f->quarantine_size_mb < 0) + if (f->quarantine_size_mb < 0) { + const int kDefaultQuarantineSizeMb = + (ASAN_LOW_MEMORY) ? 1UL << 6 : 1UL << 8; f->quarantine_size_mb = kDefaultQuarantineSizeMb; + } } } // namespace __asan |