Pretty printers for versioned namespace
Jonathan Wakely
jwakely@redhat.com
Fri Dec 9 15:18:00 GMT 2016
On 09/12/16 13:55 +0100, François Dumont wrote:
>On 02/12/2016 01:41, Jonathan Wakely wrote:
>>On 01/12/16 22:51 +0100, François Dumont wrote:
>>>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?
>>
>>
>Yes, tests involving std::any are failing because of the std::string lookup:
>
>Python Exception <class 'gdb.error'> No type named std::string.:
>skipping: Python Exception <class 'gdb.error'> No type named std::string.:
>Python Exception <class 'gdb.error'> No type named std::string.:
>$9 = {_M_manager = 0x4046f4
><std::__7::any::_Manager_internal<bool>::_S_manage(std::__7::any::_Op,
>std::__7::any const*, std::__7::any::_Arg*)>, _M_storage = {_M_ptr =
>0x0skipping:
>Python Exception <class 'gdb.error'> No type named std::string.:
>, _M_buffer = {__data = "\000\000\000\000\000\000\000", __align = {<No
>data fields>}}}}
>got: $9 = {_M_manager = 0x4046f4
><std::__7::any::_Manager_internal<bool>::_S_manage(std::__7::any::_Op,
>std::__7::any const*, std::__7::any::_Arg*)>, _M_storage = {_M_ptr =
>0x0, _M_
>buffer = {__data = "\000\000\000\000\000\000\000", __align = {<No data
>fields>}}}}
>FAIL: libstdc++-prettyprinters/cxx17.cc print ab
>
>This lookup is needed to correctly handle std::any<std::string>. As
>stated in the comment:
>
> # FIXME need to expand 'std::string' so that
>gdb.lookup_type works
Right, it's needed to handle std::any<std::string>.
If you're using the versioned namespace then you're not using that
type, you're using std::__7::any<std::__7::string> instead.
So you don't need to expand std::string, because it isn't there.
And you also don't need to expand std::__7::string, because that isn't
there either.
>But I don't know how to fix this so for the moment I just adapt it to
>correctly handle std::__7::string.
But that's not correct. Please try to understand the point I'm making:
The name "std::__7::string" does not appear in a symbol name. So your
change to replace occurrences of that name is WRONG. We don't need to
replace something that isn't there!
The problem is that lookup for std::string fails in the versioned
namespace mode, so the solution is to not do the lookup.
Doing lookup for a different type and replacing a string that doesn't
need replacing is wrong.
This works for me:
@@ -946,9 +950,10 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
m = re.match(rx, func.function.name)
if not m:
raise ValueError("Unknown manager function in %s" % self.typename)
-
- # FIXME need to expand 'std::string' so that gdb.lookup_type works
- mgrname = re.sub("std::string(?!\w)", str(gdb.lookup_type('std::string').strip_typedefs()), m.group(1))
+ mgrname = m.group(1)
+ if not typename.startswith('std::' + vers_nsp):
+ # FIXME need to expand 'std::string' so that gdb.lookup_type works
+ mgrname = re.sub("std::string(?!\w)", str(gdb.lookup_type('std::string').strip_typedefs()), mgrname)
mgrtype = gdb.lookup_type(mgrname)
self.contained_type = mgrtype.template_argument(0)
valptr = None
More information about the Gcc-patches
mailing list