Enhance print type in debug mode

François Dumont frs.dumont@gmail.com
Sat Dec 20 19:27:00 GMT 2014


Hi

     I plan to work on new debug diagnostics for which I would like to 
display the type having a problem so this is a patch to add this kind of 
parameter.

     Moreover I dealt with demangling to move from this kind of diagnostic:

/home/fdt/dev/gcc/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/debug/unordered_map:191:
     error: attempt to access container with out-of-bounds bucket index 1,
     container only holds 1 buckets.

Objects involved in the operation:
sequence "this" @ 0x0x7fff24fe33c0 {
   type = 
NSt7__debug13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEE;
}

to:

/home/fdt/dev/gcc/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/debug/unordered_map:191:
     error: attempt to access container with out-of-bounds bucket index 1,
     container only holds 1 buckets.

Objects involved in the operation:
sequence "this" @ 0x0x7fff1ee0ef00 {
   type = std::__debug::unordered_map<int, int, std::hash<int>, 
std::equal_to<int>, std::allocator<std::pair<int const, int> > >;
}

I just want to make sure it is safe and especially portable to use 
__cxa_demangle and that it is ok to do this now.

2014-12-20  François Dumont  <fdumont@gcc.gnu.org>

     * include/debug/formatter.h
     (_Error_formatter::_Parameter::_M_kind): Add __type enum entry.
     (_Error_formatter::_Parameter::_M_variant._M_type): New.
     (_Error_formatter::_Parameter::_M_type<>()): New.
     (_Error_formatter::_Parameter::_M_print_type): New.
     * src/c++11/debug.cc
     (_Error_formatter::_Parameter::_M_print_field): Use latter.
     Use __cxaabiv1::__cxa_demangle to print demangled type name.

François



More information about the Libstdc++ mailing list