From 7da9b96afc66c4496eb8809897c1b707b574a5c4 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Mon, 30 Jan 2012 16:07:00 +0000 Subject: Add a descriptive name for a constant. Also I'm at least temporarily waging war on throw specs, both old and new style. Except where we have already publicly exposed the throw spec, I'm getting rid of them. They may come back later. But they seem somewhat prone to cyclic dependencies here. The throw spec implies compiler generated code that this library has to jump to during stack unwinding. I'd like to minimize the possiblity that the code used to properly make that jump is itself creating such jumps. git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@149251 91177308-0d34-0410-b5e6-96231b3b80d8 --- src/cxa_handlers.cpp | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'src/cxa_handlers.cpp') diff --git a/src/cxa_handlers.cpp b/src/cxa_handlers.cpp index 15fde24..98f7c25 100644 --- a/src/cxa_handlers.cpp +++ b/src/cxa_handlers.cpp @@ -37,24 +37,34 @@ static void default_terminate_handler() { _Unwind_Exception* unwind_exception = reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1; - void* thrown_object = - unwind_exception->exception_class == kOurDependentExceptionClass ? - ((__cxa_dependent_exception*)exception_header)->primaryException : - exception_header + 1; - const __shim_type_info* thrown_type = - static_cast(exception_header->exceptionType); - const __shim_type_info* catch_type = - static_cast(&typeid(exception)); - // If the uncaught exception can be caught with std::exception& - if (catch_type->can_catch(thrown_type, thrown_object)) + bool native_exception = (unwind_exception->exception_class & get_language) == + (kOurExceptionClass & get_language); + if (native_exception) { - // Include the what() message from the exception - const exception* e = static_cast(thrown_object); - abort_message("terminating with %s exception: %s", cause, e->what()); + void* thrown_object = + unwind_exception->exception_class == kOurDependentExceptionClass ? + ((__cxa_dependent_exception*)exception_header)->primaryException : + exception_header + 1; + const __shim_type_info* thrown_type = + static_cast(exception_header->exceptionType); + const __shim_type_info* catch_type = + static_cast(&typeid(exception)); + // If the uncaught exception can be caught with std::exception& + if (catch_type->can_catch(thrown_type, thrown_object)) + { + // Include the what() message from the exception + const exception* e = static_cast(thrown_object); + abort_message("terminating with %s exception of type %s: %s", + cause, thrown_type->name(), e->what()); + } + else + // Else just note that we're terminating with an exception + abort_message("terminating with %s exception of type %s", + cause, thrown_type->name()); } else - // Else just note that we're terminating with an exception - abort_message("terminating with %s exception", cause); + // Else we're terminating with a foreign exception + abort_message("terminating with %s foreign exception", cause); } } // Else just note that we're terminating -- cgit v1.2.3