Pretty printers for versioned namespace
François Dumont
frs.dumont@gmail.com
Thu Dec 1 21:51:00 GMT 2016
On 29/11/2016 21:17, Jonathan Wakely wrote:
> On 28/11/16 22:19 +0100, François Dumont wrote:
>> Hi
>>
>> Here is a patch to fix pretty printers when versioned namespace is
>> activated.
>>
>> You will see that I have hesitated in making the fix independant
>> of the version being used. In source files you will find (__7::)?
>> patterns while in xmethods.py I chose (__\d+::)? making it ready for
>> __8 and forward. Do you want to generalize one option ? If so which
>> one ?
>
> I don't really mind, but I note that the point of the path
> libstdcxx/v6/printers.py was that we'd have different printers for v7,
> v8 etc. ... I think it's simpler to keep everything in one place
> though.
Ok, I think the folder v6 depends more on a potential gdb api change.
>> At the moment version namespace is visible within gdb, it displays
>> for instance 'std::__7::string'. I am pretty sure we could hide it,
>> is it preferable ? I would need some time to do so as I am neither a
>> python nor regex expert.
>
> It's fine to display it.
>
>> I am not fully happy with the replication in printers.py of
>> StdRbtreeIteratorPrinter and
>> StdExpAnyPrinter(SingleObjContainerPrinter in respectively
>> StdVersionedRbtreeIteratorPrinter and
>> StdExpVerAnyPrinter(SingleObjContainerPrinter just to adapt 2 lines
>> where regex is not an option. We could surely keep only one and pass
>> it '' or '__7'. But as I said I am not a python expert so any help
>> would be appreciated.
>
> We definitely want to avoid that duplication. For
> StdRbtreeIteratorPrinter you can just look at 'typename' and see
> whether it starts with "std::__7" or not. If it does, you need to lookup
> std::__7::_Rb_tree_node<...>, otherwise you need to lookup
> std::_Rb_tree_node<...> instead.
>
> For StdExpAnyPrinter just do two replacements: first replace
> std::string with the result of gdb.lookup_type('std::string') and then
> replace std::__7::string with the result of looking that up. Are you
> sure that's even needed though? Does std::__7::string actually appear
> in the manager function's name? I would expect it to appear as
> std::__7::basic_string<char, std::__7::char_traits<char>,
> std::__7::allocator<char> > >
> which doesn't need to be expanded anyway. So I think you can just
> remove your StdExpVerAnyPrinter.
We needed the StdExpVerAnyPrinter just because of the loopkup for
'std::string' which has to be 'std::__7::string'. But I used similar
technique exposed previously to get rid of it.
So here is the simplified version I plan to test without versioned
namespace.
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prettyprinters.patch
Type: text/x-patch
Size: 54356 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20161201/9d0b4600/attachment.bin>
More information about the Libstdc++
mailing list