Strange output from boost::exception diagnostic_information

--------------------------------------------------------------------------------
I've been having a look at the diagnostic_information function in the boost
exception library, but seem to be getting a strangely formatted output.
The code I'm using is as follows
Code:
#include

On Sun, Jan 31, 2010 at 4:41 AM, pholding
Throw in function (unknown) Dynamic exception type: N5boost16exception_detail19error_info_injectorISt1 1range_errorEE std::exception::what: blah
Your code is correct and the output is correct too. The weird type name you're seeing is the mangled C++ identifier, see http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B. Note that by design, the diagnostic_information message is not intended to be user-friendly. However I will accept any patches that improve the output from diagnostic_information, not only in terms of prettifying the mangled names but also including more diagnostic information, even if it is platform-specific. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

On Sunday 31 January 2010 13:37:08 Emil Dotchevski wrote:
Note that by design, the diagnostic_information message is not intended to be user-friendly. However I will accept any patches that improve the output from diagnostic_information, not only in terms of prettifying the mangled names but also including more diagnostic information, even if it is platform-specific.
Is there a reason not use the following directly? http://www.boost.org/doc/libs/1_41_0/boost/units/detail/utility.hpp The above produces pretty clean demangling on gcc; I have used variants of it in my projects with plenty of success. Regards, Ravi

Ravi wrote:
On Sunday 31 January 2010 13:37:08 Emil Dotchevski wrote:
Note that by design, the diagnostic_information message is not intended to be user-friendly. However I will accept any patches that improve the output from diagnostic_information, not only in terms of prettifying the mangled names but also including more diagnostic information, even if it is platform-specific.
Is there a reason not use the following directly? http://www.boost.org/doc/libs/1_41_0/boost/units/detail/utility.hpp
The above produces pretty clean demangling on gcc; I have used variants of it in my projects with plenty of success.
On the OP's platform, one would ordinarily use the stand-alone c++filt program. c++filt fails on this particular example, though, for reasons that escape me. (I happen to be sitting at a machine with the same OS and compiler versions as the OP.) Thanks for pointing out the Boost version; I didn't know about it. Since the OP is using GCC, the following will also work: char* demangle(char const* const name, int* const status) { typedef char* buffer_pointer_t; typedef std::size_t* length_pointer_t; return abi::__cxa_demangle( name , buffer_pointer_t( ) , length_pointer_t( ) , status); } For example, wrapping this function in a c++filt work-alike: ./main N5boost16exception_detail19error_info_injectorISt11range_errorEE boost::exception_detail::error_info_injectorstd::range_error I've just posted sample code on GitHub; see demangle.hh and main.cc: http://github.com/jeffs/jms/tree/master/src/jms/demangle

AMDG Jeff Schwab wrote:
Thanks for pointing out the Boost version; I didn't know about it. Since the OP is using GCC, the following will also work:
The version in Boost.Units effectively does the same thing wrapped in #ifdefs to make it compile for non-GCC.
char* demangle(char const* const name, int* const status) { typedef char* buffer_pointer_t; typedef std::size_t* length_pointer_t; return abi::__cxa_demangle( name , buffer_pointer_t( ) , length_pointer_t( ) , status); }
For example, wrapping this function in a c++filt work-alike: ./main N5boost16exception_detail19error_info_injectorISt11range_errorEE boost::exception_detail::error_info_injectorstd::range_error
I've just posted sample code on GitHub; see demangle.hh and main.cc: http://github.com/jeffs/jms/tree/master/src/jms/demangle
In Christ, Steven Watanabe

On Sun, Jan 31, 2010 at 12:01 PM, Ravi
On Sunday 31 January 2010 13:37:08 Emil Dotchevski wrote:
Note that by design, the diagnostic_information message is not intended to be user-friendly. However I will accept any patches that improve the output from diagnostic_information, not only in terms of prettifying the mangled names but also including more diagnostic information, even if it is platform-specific.
Is there a reason not use the following directly? http://www.boost.org/doc/libs/1_41_0/boost/units/detail/utility.hpp
OK, trunk revision 59398 uses boost/units/detail/utility.hpp for demangling type names used in diagnostic_information (except under rtti=off). We should probably do a mini-review and make this an official utility function. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
participants (5)
-
Emil Dotchevski
-
Jeff Schwab
-
pholding
-
Ravi
-
Steven Watanabe