summaryrefslogtreecommitdiffstats
path: root/libcxx/src
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-03-18 21:50:12 +0000
committerEric Fiselier <eric@efcs.ca>2019-03-18 21:50:12 +0000
commit61b302f94fd9983651bf210c8a1c0b116612022a (patch)
tree2df88e9d5398a3fcd1e7606c2c53feac4cc52170 /libcxx/src
parent2d5e7adf26f482280c62c5a759ac052bc4cd5023 (diff)
downloadbcm5719-llvm-61b302f94fd9983651bf210c8a1c0b116612022a.tar.gz
bcm5719-llvm-61b302f94fd9983651bf210c8a1c0b116612022a.zip
Remove exception throwing debug mode handler support.
Summary: The reason libc++ implemented a throwing debug mode handler was for ease of testing. Specifically, I thought that if a debug violation aborted, we could only test one violation per file. This made it impossible to test debug mode. Which throwing behavior we could test more! However, the throwing approach didn't work either, since there are debug violations underneath noexcept functions. This lead to the introduction of `_NOEXCEPT_DEBUG`, which was only noexcept when debug mode was off. Having thought more and having grown wiser, `_NOEXCEPT_DEBUG` was a horrible decision. It was viral, it didn't cover all the cases it needed to, and it was observable to the user -- at worst changing the behavior of their program. This patch removes the throwing debug handler, and rewrites the debug tests using 'fork-ing' style death tests. Reviewers: mclow.lists, ldionne, thomasanderson Reviewed By: ldionne Subscribers: christof, arphaman, libcxx-commits, #libc Differential Revision: https://reviews.llvm.org/D59166 llvm-svn: 356417
Diffstat (limited to 'libcxx/src')
-rw-r--r--libcxx/src/debug.cpp59
1 files changed, 9 insertions, 50 deletions
diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp
index 28a1f70a59b..0f75d8ce9b6 100644
--- a/libcxx/src/debug.cpp
+++ b/libcxx/src/debug.cpp
@@ -17,14 +17,18 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-static std::string make_what_str(__libcpp_debug_info const& info) {
- string msg = info.__file_;
- msg += ":" + to_string(info.__line_) + ": _LIBCPP_ASSERT '";
- msg += info.__pred_;
+std::string __libcpp_debug_info::what() const {
+ string msg = __file_;
+ msg += ":" + to_string(__line_) + ": _LIBCPP_ASSERT '";
+ msg += __pred_;
msg += "' failed. ";
- msg += info.__msg_;
+ msg += __msg_;
return msg;
}
+_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
+ std::fprintf(stderr, "%s\n", info.what().c_str());
+ std::abort();
+}
_LIBCPP_SAFE_STATIC __libcpp_debug_function_type
__libcpp_debug_function = __libcpp_abort_debug_function;
@@ -34,51 +38,6 @@ bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
return true;
}
-_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
- std::fprintf(stderr, "%s\n", make_what_str(info).c_str());
- std::abort();
-}
-
-_LIBCPP_NORETURN void __libcpp_throw_debug_function(__libcpp_debug_info const& info) {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw __libcpp_debug_exception(info);
-#else
- __libcpp_abort_debug_function(info);
-#endif
-}
-
-struct __libcpp_debug_exception::__libcpp_debug_exception_imp {
- __libcpp_debug_info __info_;
- std::string __what_str_;
-};
-
-__libcpp_debug_exception::__libcpp_debug_exception() _NOEXCEPT
- : __imp_(nullptr) {
-}
-
-__libcpp_debug_exception::__libcpp_debug_exception(
- __libcpp_debug_info const& info) : __imp_(new __libcpp_debug_exception_imp)
-{
- __imp_->__info_ = info;
- __imp_->__what_str_ = make_what_str(info);
-}
-__libcpp_debug_exception::__libcpp_debug_exception(
- __libcpp_debug_exception const& other) : __imp_(nullptr) {
- if (other.__imp_)
- __imp_ = new __libcpp_debug_exception_imp(*other.__imp_);
-}
-
-__libcpp_debug_exception::~__libcpp_debug_exception() _NOEXCEPT {
- if (__imp_)
- delete __imp_;
-}
-
-const char* __libcpp_debug_exception::what() const _NOEXCEPT {
- if (__imp_)
- return __imp_->__what_str_.c_str();
- return "__libcpp_debug_exception";
-}
-
_LIBCPP_FUNC_VIS
__libcpp_db*
__get_db()
OpenPOWER on IntegriCloud