diff options
author | Howard Hinnant <hhinnant@apple.com> | 2012-01-31 19:48:06 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2012-01-31 19:48:06 +0000 |
commit | 06b1ea1bbdc163008d1e7714f5f41f43908b8def (patch) | |
tree | b16f0869b8c339f815a70b100093881309e67cda /src/cxa_handlers.cpp | |
parent | 2e774bf081cc1aeff076a250ade5c909f9ad79a8 (diff) |
Have the default unexpected/terminate handler output *demangled* names for the type of exception instead of the mangled name.
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@149409 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src/cxa_handlers.cpp')
-rw-r--r-- | src/cxa_handlers.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cxa_handlers.cpp b/src/cxa_handlers.cpp index 93cc269..015a06e 100644 --- a/src/cxa_handlers.cpp +++ b/src/cxa_handlers.cpp @@ -47,20 +47,27 @@ static void default_terminate_handler() 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 |