Boost logo

Boost Users :

Subject: Re: [Boost-users] Strange output from boost::exception diagnostic_information
From: Jeff Schwab (jeff_at_[hidden])
Date: 2010-01-31 16:09:49


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_injector<std::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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net