From d05b021ced29ae0ce32a5801db33b5343790b5c9 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Tue, 20 Sep 2011 14:09:36 +0100 Subject: Add get_terminate() / get_unexpected() functions required by libc++. Fixed the default unexpected handler to std::terminate(). --- src/exception.cc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/exception.cc b/src/exception.cc index ec9d4f0..97e014d 100644 --- a/src/exception.cc +++ b/src/exception.cc @@ -183,7 +183,7 @@ using namespace ABI_NAMESPACE; /** The global termination handler. */ static terminate_handler terminateHandler = abort; /** The global unexpected exception handler. */ -static unexpected_handler unexpectedHandler = abort; +static unexpected_handler unexpectedHandler = std::terminate; /** Key used for thread-local data. */ static pthread_key_t eh_key; @@ -1223,6 +1223,7 @@ namespace std */ void terminate() { + fprintf(stderr, "Terminate called\n"); static __cxa_thread_info *info = thread_info_fast(); if (0 != info && 0 != info->terminateHandler) { @@ -1259,5 +1260,28 @@ namespace std __cxa_thread_info *info = thread_info(); return info->globals.uncaughtExceptions != 0; } - + /** + * Returns the current unexpected handler. + */ + unexpected_handler get_unexpected() throw() + { + __cxa_thread_info *info = thread_info(); + if (info->unexpectedHandler) + { + return info->unexpectedHandler; + } + return unexpectedHandler; + } + /** + * Returns the current terminate handler. + */ + terminate_handler get_terminate() throw() + { + __cxa_thread_info *info = thread_info(); + if (info->terminateHandler) + { + return info->terminateHandler; + } + return terminateHandler; + } } -- cgit v1.2.3