Pretty printers for versioned namespace

Jonathan Wakely jwakely@redhat.com
Tue Nov 29 20:17:00 GMT 2016


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. 

>    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.


>--- a/libstdc++-v3/testsuite/lib/gdb-test.exp
>+++ b/libstdc++-v3/testsuite/lib/gdb-test.exp
>@@ -74,6 +74,14 @@ proc whatis-test {var result} {
>     lappend gdb_tests $var $result whatis
> }
> 
>+# A test of 'whatis'.  This tests a type rather than a variable through a
>+# regexp.

Please use "regular expression" here rather than "regexp".

>+proc whatis-regexp-test {var result} {
>+    global gdb_tests
>+
>+    lappend gdb_tests $var $result whatisrexp
>+}
>+

And something other than "whatisrexp" e.g. "whatis_regexp" would be
OK, but "rexp" is not a conventional abbreviation.



More information about the Libstdc++ mailing list