Running sanitized code under gdb can be annoying because the program will
print out its error then exit, instead of the usual behaviour when we get
an abort() of stopping the program there and allowing the user to inspect
its stack trace.
Add a trap to the exit path in sanitizer_common. Please review!
Nick
Index: lib/sanitizer_common/sanitizer_internal_defs.h
===================================================================
--- lib/sanitizer_common/sanitizer_internal_defs.h (revision 193231)
+++ lib/sanitizer_common/sanitizer_internal_defs.h (working copy)
@@ -116,6 +116,7 @@
// FIXME(timurrrr): do we need this on Windows?
# define ALIAS(x)
# define ALIGNED(x) __declspec(align(x))
+# define ENTERDEBUGGER __debugbreak()
# define FORMAT(f, a)
# define NOINLINE __declspec(noinline)
# define NORETURN __declspec(noreturn)
@@ -132,6 +133,7 @@
// Please only use the ALIGNED macro before the type.
// Using ALIGNED after the variable declaration is not portable!
# define ALIGNED(x) __attribute__((aligned(x)))
+# define ENTERDEBUGGER __builtin_trap()
# define FORMAT(f, a) __attribute__((format(printf, f, a)))
# define NOINLINE __attribute__((noinline))
# define NORETURN __attribute__((noreturn))
Index: lib/sanitizer_common/sanitizer_common.cc
===================================================================
--- lib/sanitizer_common/sanitizer_common.cc (revision 193231)
+++ lib/sanitizer_common/sanitizer_common.cc (working copy)
@@ -53,6 +53,7 @@
if (DieCallback) {
DieCallback();
}
+ ENTERDEBUGGER;
internal__exit(1);
}
Index: lib/tsan/lit_tests/allocator_returns_null.cc
===================================================================
--- lib/tsan/lit_tests/allocator_returns_null.cc (revision 193231)
+++ lib/tsan/lit_tests/allocator_returns_null.cc (working copy)
@@ -3,12 +3,12 @@
// With allocator_may_return_null=1 the allocator should return 0.
//
// RUN: %clangxx_tsan -O0 %s -o %t
-// RUN: not %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %t calloc 2>&1 | FileCheck %s --check-prefix=CHECK-cCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %t calloc-overflow 2>&1 | FileCheck %s --check-prefix=CHECK-coCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %t realloc 2>&1 | FileCheck %s --check-prefix=CHECK-rCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %t realloc-after-malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mrCRASH
+// RUN: not --crash %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
+// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not --crash %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
+// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not --crash %t calloc 2>&1 | FileCheck %s --check-prefix=CHECK-cCRASH
+// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not --crash %t calloc-overflow 2>&1 | FileCheck %s --check-prefix=CHECK-coCRASH
+// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not --crash %t realloc 2>&1 | FileCheck %s --check-prefix=CHECK-rCRASH
+// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not --crash %t realloc-after-malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mrCRASH
#include <limits.h>
#include <stdlib.h>
Index: lib/tsan/lit_tests/ignore_lib2.cc
===================================================================
--- lib/tsan/lit_tests/ignore_lib2.cc (revision 193231)
+++ lib/tsan/lit_tests/ignore_lib2.cc (working copy)
@@ -1,7 +1,7 @@
// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib2_0.so
// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib2_1.so
// RUN: %clangxx_tsan -O1 %s -o %t
-// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions=%s.supp" not %t 2>&1 | FileCheck %s
+// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions=%s.supp" not --crash %t 2>&1 | FileCheck %s
// Tests that called_from_lib suppression matched against 2 libraries
// causes program crash (this is not supported).
Index: lib/tsan/lit_tests/ignore_lib3.cc
===================================================================
--- lib/tsan/lit_tests/ignore_lib3.cc (revision 193231)
+++ lib/tsan/lit_tests/ignore_lib3.cc (working copy)
@@ -1,6 +1,6 @@
// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib3.so
// RUN: %clangxx_tsan -O1 %s -o %t
-// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions=%s.supp" not %t 2>&1 | FileCheck %s
+// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions=%s.supp" not --crash %t 2>&1 | FileCheck %s
// Tests that unloading of a library matched against called_from_lib suppression
// causes program crash (this is not supported).
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits