Pretty printers for versioned namespace
Jonathan Wakely
jwakely@redhat.com
Wed Jan 4 12:52:00 GMT 2017
On 24/12/16 14:47 +0100, François Dumont wrote:
>On 15/12/2016 15:57, Jonathan Wakely wrote:
>>
>>And we could avoid three re.match expressions with complicated regular
>>expressions by creating a helper function to do the "startswith"
>>checks:
>>
>>def is_specialization_of(type, template_name):
>> return re.match('^std::(%s)?%s<.*>$' % (vers_nsp, template_name),
>>type) is not None
>>
>>Then replace impl_type.startswith('std::__uniq_ptr_impl<') with
>>is_specialization_of(impl_type, '__uniq_ptr_impl')
>>
>>And replace impl_type.startswith('std::tuple<') with
>>is_specialization_of(impl_type, 'tuple')
>>
>>And replace nodetype.name.startswith('std::_Rb_tree_node') with
>>is_specialization_of(nodetype.name, '_Rb_tree_node')
>>
>>That makes the code much easier to read.
>>
>>
>I agree that hiding the version namespace will be nicer. I just hope
>it is possible. I don't think we can really dictate gdb to hide this
>namespace during the rendering. In the attached path you will see what
>I tried to do. Problem is that I am not sure that printers.py is
>intercepting rendering of all types so version namespace will stay
>visible in those cases.
>
>I think the 2 failures that I have with this patch are reflecting this
>problem:
>
>type = holder<std::__7::basic_string<unsigned char,
>std::__7::char_traits<unsigned char>, std::__7::allocator<unsigned
>char> > >
>got: type = holder<std::__7::basic_string<unsigned char,
>std::__7::char_traits<unsigned char>, std::__7::allocator<unsigned
>char> > >
>FAIL: libstdc++-prettyprinters/whatis.cc whatis ustring_holder
>type = holder<std::__7::basic_string<signed char,
>std::__7::char_traits<signed char>, std::__7::allocator<signed char> >
>>
>got: type = holder<std::__7::basic_string<signed char,
>std::__7::char_traits<signed char>, std::__7::allocator<signed char> >
>>
>FAIL: libstdc++-prettyprinters/whatis.cc whatis sstring_holder
>
>Shall I simply use regex in those cases and adopt this approach ?
I'd prefer not to have to use the regex matches in libstdc++.exp as
they complicate things.
For the two examples above, the whatis results are bad even for the
non-versioned namespace. For specializations of basic_string we only
have type printers that recognize the standard typedefs like
std::u16string, but not other specializations. We really want it to
show std::basic_string<unsigned char> not the full name. That would
require a TemplateTypePrinter for basic_string. The attached patch
works, and should be easy to incorporate into your changes for the
versioned namespace.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 2209 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170104/604e55c9/attachment.bin>
More information about the Libstdc++
mailing list