5d3805fca3
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins, store max (log2 (align), 0) into uchar field instead of align into uptr field. (ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins, store uchar 0 field instead of uptr 0 field. (instrument_nonnull_return): Use _v1 suffixed nonnull return builtin, instead of passing one address of struct with 2 locations pass two addresses of structs with 1 location each. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH, BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT, BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN, BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed. (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1, BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT, BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1, BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins. * c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword from expected output regexps. * c-c++-common/ubsan/float-cast-overflow-2.c: Likewise. * c-c++-common/ubsan/float-cast-overflow-3.c: Likewise. * c-c++-common/ubsan/float-cast-overflow-4.c: Likewise. * c-c++-common/ubsan/float-cast-overflow-5.c: Likewise. * c-c++-common/ubsan/float-cast-overflow-6.c: Likewise. * c-c++-common/ubsan/float-cast-overflow-8.c: Likewise. * c-c++-common/ubsan/float-cast-overflow-9.c: Likewise. * c-c++-common/ubsan/float-cast-overflow-10.c: Likewise. * g++.dg/ubsan/float-cast-overflow-bf.C: Likewise. * gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise. * g++.dg/asan/default-options-1.C (__asan_default_options): Add used attribute. * g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2 in the environment. * All source files: Merge from upstream 315899. * asan/Makefile.am (nodist_saninclude_HEADERS): Add include/sanitizer/tsan_interface.h. * asan/libtool-version: Bump the libasan SONAME. * lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc. (lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc. * sanitizer_common/Makefile.am (sanitizer_common_files): Add sancov_flags.cc, sanitizer_allocator_checks.cc, sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc, sanitizer_file.cc, sanitizer_mac_libcdep.cc and sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc and sanitizer_coverage_mapping_libcdep.cc. * tsan/Makefile.am (tsan_files): Add tsan_external.cc. * ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1. (ubsan_files): Add ubsan_init_standalone.cc and ubsan_signals_standalone.cc. * ubsan/libtool-version: Bump the libubsan SONAME. * asan/Makefile.in: Regenerate. * lsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.in: Regenerate. * tsan/Makefile.in: Regenerate. * ubsan/Makefile.in: Regenerate. From-SVN: r253887
126 lines
3.3 KiB
C++
126 lines
3.3 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 {
|
|
|
|
// Can be overriden in frontend.
|
|
#ifdef TSAN_EXTERNAL_HOOKS
|
|
extern "C" const char* __tsan_default_options();
|
|
#else
|
|
SANITIZER_WEAK_DEFAULT_IMPL
|
|
const char *__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;
|
|
if (SANITIZER_GO) {
|
|
// Does not work as expected for Go: runtime handles SIGABRT and crashes.
|
|
cf.abort_on_error = false;
|
|
// Go does not have mutexes.
|
|
} else {
|
|
cf.detect_deadlocks = true;
|
|
}
|
|
cf.print_suppressions = false;
|
|
cf.stack_trace_format = " #%n %f %S %M";
|
|
cf.exitcode = 66;
|
|
cf.intercept_tls_get_addr = true;
|
|
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;
|
|
}
|
|
|
|
InitializeCommonFlags();
|
|
|
|
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
|