On 01/12/16 22:51 +0100, François Dumont wrote:
On 29/11/2016 21:17, Jonathan Wakely wrote:
On 28/11/16 22:19 +0100, François Dumont wrote:
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.

But I don't see any std::__7::string in the relevant symbols.  Here's
the manager function for an std:experimental::__7::any storing a
std::__7::string:

std::experimental::fundamentals_v1::__7::any::_Manager_internal<std::__7::basic_string<char, 
std::__7::char_traits<char>, std::__7::allocator<char> > 
>::_S_manage(std::experimental::fundamentals_v1::__7::any::_Op, 
>std::experimental::fundamentals_v1::__7::any const*, 
>std::experimental::fundamentals_v1::__7::any::_Arg*)

Since this has no std::__7::string it doesn't need to be substituted.

Do any tests fail without the change to StdExpAnyPrinter? Which ones?

Reply via email to