[PATCH] D28497: [libc++abi] Add a silent terminate handler to libcxxabi.

James Y Knight via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 13 11:33:29 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL291946: [libc++abi] Add a silent terminate handler to libcxxabi. (authored by jyknight).

Changed prior to commit:
  https://reviews.llvm.org/D28497?vs=83725&id=84339#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28497

Files:
  libcxxabi/trunk/CMakeLists.txt
  libcxxabi/trunk/src/config.h
  libcxxabi/trunk/src/cxa_default_handlers.cpp


Index: libcxxabi/trunk/src/cxa_default_handlers.cpp
===================================================================
--- libcxxabi/trunk/src/cxa_default_handlers.cpp
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp
@@ -12,6 +12,7 @@
 #include <stdexcept>
 #include <new>
 #include <exception>
+#include <cstdlib>
 #include "abort_message.h"
 #include "config.h" // For __sync_swap
 #include "cxxabi.h"
@@ -22,7 +23,7 @@
 static const char* cause = "uncaught";
 
 __attribute__((noreturn))
-static void default_terminate_handler()
+static void demangling_terminate_handler()
 {
     // If there might be an uncaught exception
     using namespace __cxxabiv1;
@@ -78,12 +79,19 @@
 }
 
 __attribute__((noreturn))
-static void default_unexpected_handler() 
+static void demangling_unexpected_handler()
 {
     cause = "unexpected";
     std::terminate();
 }
 
+#if !LIBCXXABI_SILENT_TERMINATE
+static std::terminate_handler default_terminate_handler = demangling_terminate_handler;
+static std::terminate_handler default_unexpected_handler = demangling_unexpected_handler;
+#else
+static std::terminate_handler default_terminate_handler = std::abort;
+static std::terminate_handler default_unexpected_handler = std::abort;
+#endif
 
 //
 // Global variables that hold the pointers to the current handler
Index: libcxxabi/trunk/src/config.h
===================================================================
--- libcxxabi/trunk/src/config.h
+++ libcxxabi/trunk/src/config.h
@@ -23,4 +23,11 @@
 #  define LIBCXXABI_BAREMETAL 0
 #endif
 
+// The default terminate handler attempts to demangle uncaught exceptions, which
+// causes extra I/O and demangling code to be pulled in.
+// Set this to make the terminate handler default to a silent alternative.
+#ifndef LIBCXXABI_SILENT_TERMINATE
+#  define LIBCXXABI_SILENT_TERMINATE 0
+#endif
+
 #endif // LIBCXXABI_CONFIG_H
Index: libcxxabi/trunk/CMakeLists.txt
===================================================================
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -433,6 +433,10 @@
   add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER=1)
 endif()
 
+if (LIBCXXABI_SILENT_TERMINATE)
+  add_definitions(-DLIBCXXABI_SILENT_TERMINATE=1)
+endif()
+
 string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28497.84339.patch
Type: text/x-patch
Size: 2418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170113/c8889443/attachment.bin>


More information about the llvm-commits mailing list