ruediger / Boost-Pretty-Printer

GDB Pretty Printers for Boost
197 stars 61 forks source link

Minimal support for boost::type_erasure::any. #42

Open redboltz opened 5 years ago

redboltz commented 5 years ago

Just print the address of actual data.

You can get outputs as follows:

(gdb) p multi_index_container
$1 = boost::type_erasure::any<...> data = 0x555555571f10

If you know the acutual type, then you can cast as follows:

(gdb) p *(ActualType)0x555555571f10
redboltz commented 5 years ago

When I use boost::type_erasure::any<...>, especially as the member of the container, I got annoying outputs as follows:

boost::type_erasure::any_constructor_control<boost::type_erasure::any_constructor_impl<boost::mpl::vector<boost::type_erasure::copy_constructible<boost::type_erasure::_self>, has_foo<void () const, boost::type_erasure::_self>, has_get<int () const, boost::type_erasure::_self>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self>, void>> = {
    <boost::type_erasure::any_constructor_impl<boost::mpl::vector<boost::type_erasure::copy_constructible<boost::type_erasure::_self>, has_foo<void () const, boost::type_erasure::_self>, has_get<int () const, boost::type_erasure::_self>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self

This PR suppress the annoying outputs and print the address of the data that is owned by boost::type_erasure::any<...>.

User can cast the address as the actual type. Gdb can't get the actual type because type is erased. So user needs to do try and error the possible types. I think that it is good enough.