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
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 61b302f94fd9983651bf210c8a1c0b116612022a
diff --git a/src/debug.cpp b/src/debug.cpp
index 28a1f70..0f75d8c 100644
--- a/src/debug.cpp
+++ b/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 @@
   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()