summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2015-08-21 20:49:37 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2015-08-21 20:49:37 +0000
commitbb79b06f4e40d85d6c1b0ff2098e9aa5d6afce5d (patch)
tree69de2072c26b79701e96b368a1f564ec44488214 /compiler-rt/lib/tsan
parentdddad102418960e8dc187233fff849c1ce9badf4 (diff)
downloadbcm5719-llvm-bb79b06f4e40d85d6c1b0ff2098e9aa5d6afce5d.tar.gz
bcm5719-llvm-bb79b06f4e40d85d6c1b0ff2098e9aa5d6afce5d.zip
[Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across all sanitizers.
Summary: Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan into one entity. Additionally, make sure sanitizer_common now uses the value of common_flags()->exitcode when dying on error, so that this flag will automatically work for other sanitizers (UBSan and DFSan) as well. User-visible changes: * "exit_code" MSan runtime flag is now deprecated. If explicitly specified, this flag will take precedence over "exitcode". The users are encouraged to migrate to the new version. * __asan_set_error_exit_code() and __msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead. * Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks. Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12120 llvm-svn: 245734
Diffstat (limited to 'compiler-rt/lib/tsan')
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_flags.cc1
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_flags.inc1
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc2
-rw-r--r--compiler-rt/lib/tsan/tests/unit/tsan_flags_test.cc6
5 files changed, 3 insertions, 9 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_flags.cc b/compiler-rt/lib/tsan/rtl/tsan_flags.cc
index 5de227a42de..b8bee70b7f0 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_flags.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_flags.cc
@@ -66,6 +66,7 @@ void InitializeFlags(Flags *f, const char *env) {
#endif
cf.print_suppressions = false;
cf.stack_trace_format = " #%n %f %S %M";
+ cf.exitcode = 66;
OverrideCommonFlags(cf);
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_flags.inc b/compiler-rt/lib/tsan/rtl/tsan_flags.inc
index e4994685fa0..ab9ca992493 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_flags.inc
+++ b/compiler-rt/lib/tsan/rtl/tsan_flags.inc
@@ -45,7 +45,6 @@ TSAN_FLAG(
"If set, all atomics are effectively sequentially consistent (seq_cst), "
"regardless of what user actually specified.")
TSAN_FLAG(bool, print_benign, false, "Print matched \"benign\" races at exit.")
-TSAN_FLAG(int, exitcode, 66, "Override exit status if something was reported.")
TSAN_FLAG(bool, halt_on_error, false, "Exit after first reported error.")
TSAN_FLAG(int, atexit_sleep_ms, 1000,
"Sleep in main thread before exiting for that many ms "
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index 9ec84b8811d..264fdf90221 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -417,7 +417,7 @@ int Finalize(ThreadState *thr) {
StatOutput(ctx->stat);
#endif
- return failed ? flags()->exitcode : 0;
+ return failed ? common_flags()->exitcode : 0;
}
#ifndef SANITIZER_GO
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
index 6d4ab28e47e..12e7ad68c41 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
@@ -514,7 +514,7 @@ bool OutputReport(ThreadState *thr, const ScopedReport &srep) {
PrintReport(rep);
ctx->nreported++;
if (flags()->halt_on_error)
- internal__exit(flags()->exitcode);
+ internal__exit(common_flags()->exitcode);
return true;
}
diff --git a/compiler-rt/lib/tsan/tests/unit/tsan_flags_test.cc b/compiler-rt/lib/tsan/tests/unit/tsan_flags_test.cc
index 22610c0dc42..aa8a024f9dc 100644
--- a/compiler-rt/lib/tsan/tests/unit/tsan_flags_test.cc
+++ b/compiler-rt/lib/tsan/tests/unit/tsan_flags_test.cc
@@ -28,9 +28,7 @@ TEST(Flags, DefaultValues) {
Flags f;
f.enable_annotations = false;
- f.exitcode = -11;
InitializeFlags(&f, "");
- EXPECT_EQ(66, f.exitcode);
EXPECT_EQ(true, f.enable_annotations);
}
@@ -46,7 +44,6 @@ static const char *options1 =
" report_atomic_races=0"
" force_seq_cst_atomics=0"
" print_benign=0"
- " exitcode=111"
" halt_on_error=0"
" atexit_sleep_ms=222"
" profile_memory=qqq"
@@ -72,7 +69,6 @@ static const char *options2 =
" report_atomic_races=true"
" force_seq_cst_atomics=true"
" print_benign=true"
- " exitcode=222"
" halt_on_error=true"
" atexit_sleep_ms=123"
" profile_memory=bbbbb"
@@ -98,7 +94,6 @@ void VerifyOptions1(Flags *f) {
EXPECT_EQ(f->report_atomic_races, 0);
EXPECT_EQ(f->force_seq_cst_atomics, 0);
EXPECT_EQ(f->print_benign, 0);
- EXPECT_EQ(f->exitcode, 111);
EXPECT_EQ(f->halt_on_error, 0);
EXPECT_EQ(f->atexit_sleep_ms, 222);
EXPECT_EQ(f->profile_memory, std::string("qqq"));
@@ -124,7 +119,6 @@ void VerifyOptions2(Flags *f) {
EXPECT_EQ(f->report_atomic_races, true);
EXPECT_EQ(f->force_seq_cst_atomics, true);
EXPECT_EQ(f->print_benign, true);
- EXPECT_EQ(f->exitcode, 222);
EXPECT_EQ(f->halt_on_error, true);
EXPECT_EQ(f->atexit_sleep_ms, 123);
EXPECT_EQ(f->profile_memory, std::string("bbbbb"));
OpenPOWER on IntegriCloud