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 | fe2052d63594f6c206f1ee9049c317ac9314c4fb (patch) | |
tree | 9ba131ce2c6983e01c92b949db9e14376da5225f /libcxxabi/src/cxa_handlers.cpp | |
parent | 6addc79087f3e641eb3a9093eeba56699d1be412 (diff) | |
download | bcm5719-llvm-fe2052d63594f6c206f1ee9049c317ac9314c4fb.tar.gz bcm5719-llvm-fe2052d63594f6c206f1ee9049c317ac9314c4fb.zip |
Have the default unexpected/terminate handler output *demangled* names for the type of exception instead of the mangled name.
llvm-svn: 149409
Diffstat (limited to 'libcxxabi/src/cxa_handlers.cpp')
-rw-r--r-- | libcxxabi/src/cxa_handlers.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libcxxabi/src/cxa_handlers.cpp b/libcxxabi/src/cxa_handlers.cpp index 93cc2691789..015a06e223d 100644 --- a/libcxxabi/src/cxa_handlers.cpp +++ b/libcxxabi/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 |