696d846a56
libsanitizer/ 2015-10-20 Maxim Ostapenko <m.ostapenko@partner.samsung.com> * All source files: Merge from upstream r250806. * configure.ac (link_sanitizer_common): Add -lrt flag. * configure.tgt: Enable TSAN and LSAN for aarch64-linux targets. Set CXX_ABI_NEEDED=true for darwin. * asan/Makefile.am (asan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0 and remove unused and legacy DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0. * asan/Makefile.in: Regenerate. * ubsan/Makefile.am (ubsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=1. (libubsan_la_LIBADD): Add -lc++abi if CXX_ABI_NEEDED is true. * ubsan/Makefile.in: Regenerate. * tsan/Makefile.am (tsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0. * tsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.am (sanitizer_common_files): Add new files. * sanitizer_common/Makefile.in: Regenerate. * asan/libtool-version: Bump the libasan SONAME. From-SVN: r229111
125 lines
3.2 KiB
C++
125 lines
3.2 KiB
C++
//===-- tsan_flags.cc -----------------------------------------------------===//
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file is a part of ThreadSanitizer (TSan), a race detector.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "sanitizer_common/sanitizer_flags.h"
|
|
#include "sanitizer_common/sanitizer_flag_parser.h"
|
|
#include "sanitizer_common/sanitizer_libc.h"
|
|
#include "tsan_flags.h"
|
|
#include "tsan_rtl.h"
|
|
#include "tsan_mman.h"
|
|
#include "ubsan/ubsan_flags.h"
|
|
|
|
namespace __tsan {
|
|
|
|
Flags *flags() {
|
|
return &ctx->flags;
|
|
}
|
|
|
|
// Can be overriden in frontend.
|
|
#ifdef TSAN_EXTERNAL_HOOKS
|
|
extern "C" const char* __tsan_default_options();
|
|
#else
|
|
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
|
|
const char *WEAK __tsan_default_options() {
|
|
return "";
|
|
}
|
|
#endif
|
|
|
|
void Flags::SetDefaults() {
|
|
#define TSAN_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
|
|
#include "tsan_flags.inc"
|
|
#undef TSAN_FLAG
|
|
// DDFlags
|
|
second_deadlock_stack = false;
|
|
}
|
|
|
|
void RegisterTsanFlags(FlagParser *parser, Flags *f) {
|
|
#define TSAN_FLAG(Type, Name, DefaultValue, Description) \
|
|
RegisterFlag(parser, #Name, Description, &f->Name);
|
|
#include "tsan_flags.inc"
|
|
#undef TSAN_FLAG
|
|
// DDFlags
|
|
RegisterFlag(parser, "second_deadlock_stack",
|
|
"Report where each mutex is locked in deadlock reports",
|
|
&f->second_deadlock_stack);
|
|
}
|
|
|
|
void InitializeFlags(Flags *f, const char *env) {
|
|
SetCommonFlagsDefaults();
|
|
{
|
|
// Override some common flags defaults.
|
|
CommonFlags cf;
|
|
cf.CopyFrom(*common_flags());
|
|
cf.allow_addr2line = true;
|
|
#ifndef SANITIZER_GO
|
|
cf.detect_deadlocks = true;
|
|
#endif
|
|
cf.print_suppressions = false;
|
|
cf.stack_trace_format = " #%n %f %S %M";
|
|
cf.exitcode = 66;
|
|
OverrideCommonFlags(cf);
|
|
}
|
|
|
|
f->SetDefaults();
|
|
|
|
FlagParser parser;
|
|
RegisterTsanFlags(&parser, f);
|
|
RegisterCommonFlags(&parser);
|
|
|
|
#if TSAN_CONTAINS_UBSAN
|
|
__ubsan::Flags *uf = __ubsan::flags();
|
|
uf->SetDefaults();
|
|
|
|
FlagParser ubsan_parser;
|
|
__ubsan::RegisterUbsanFlags(&ubsan_parser, uf);
|
|
RegisterCommonFlags(&ubsan_parser);
|
|
#endif
|
|
|
|
// Let a frontend override.
|
|
parser.ParseString(__tsan_default_options());
|
|
#if TSAN_CONTAINS_UBSAN
|
|
const char *ubsan_default_options = __ubsan::MaybeCallUbsanDefaultOptions();
|
|
ubsan_parser.ParseString(ubsan_default_options);
|
|
#endif
|
|
// Override from command line.
|
|
parser.ParseString(env);
|
|
#if TSAN_CONTAINS_UBSAN
|
|
ubsan_parser.ParseString(GetEnv("UBSAN_OPTIONS"));
|
|
#endif
|
|
|
|
// Sanity check.
|
|
if (!f->report_bugs) {
|
|
f->report_thread_leaks = false;
|
|
f->report_destroy_locked = false;
|
|
f->report_signal_unsafe = false;
|
|
}
|
|
|
|
SetVerbosity(common_flags()->verbosity);
|
|
|
|
if (Verbosity()) ReportUnrecognizedFlags();
|
|
|
|
if (common_flags()->help) parser.PrintFlagDescriptions();
|
|
|
|
if (f->history_size < 0 || f->history_size > 7) {
|
|
Printf("ThreadSanitizer: incorrect value for history_size"
|
|
" (must be [0..7])\n");
|
|
Die();
|
|
}
|
|
|
|
if (f->io_sync < 0 || f->io_sync > 2) {
|
|
Printf("ThreadSanitizer: incorrect value for io_sync"
|
|
" (must be [0..2])\n");
|
|
Die();
|
|
}
|
|
}
|
|
|
|
} // namespace __tsan
|