[cfe-commits] [libcxxabi] r149409 - /libcxxabi/trunk/src/cxa_handlers.cpp
Howard Hinnant
hhinnant at apple.com
Tue Jan 31 11:48:06 PST 2012
Author: hhinnant
Date: Tue Jan 31 13:48:06 2012
New Revision: 149409
URL: http://llvm.org/viewvc/llvm-project?rev=149409&view=rev
Log:
Have the default unexpected/terminate handler output *demangled* names for the type of exception instead of the mangled name.
Modified:
libcxxabi/trunk/src/cxa_handlers.cpp
Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=149409&r1=149408&r2=149409&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Tue Jan 31 13:48:06 2012
@@ -47,20 +47,27 @@
exception_header + 1;
const __shim_type_info* thrown_type =
static_cast<const __shim_type_info*>(exception_header->exceptionType);
+ // Try to get demangled name of thrown_type
+ int status;
+ char buf[1024];
+ size_t len = sizeof(buf);
+ const char* name = __cxa_demangle(thrown_type->name(), buf, &len, &status);
+ if (status != 0)
+ name = thrown_type->name();
+ // If the uncaught exception can be caught with std::exception&
const __shim_type_info* catch_type =
static_cast<const __shim_type_info*>(&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<const exception*>(thrown_object);
abort_message("terminating with %s exception of type %s: %s",
- cause, thrown_type->name(), e->what());
+ cause, 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());
+ cause, name);
}
else
// Else we're terminating with a foreign exception
More information about the cfe-commits
mailing list