On Thu, 26 May 2022 at 00:38, Jonathan Wakely <jwak...@redhat.com> wrote:
>
> On Thu, 26 May 2022 at 00:34, Jonathan Wakely <jwak...@redhat.com> wrote:
> >
> > On Wed, 25 May 2022 at 21:29, François Dumont via Libstdc++
> > <libstd...@gcc.gnu.org> wrote:
> > >
> > > Hi
> > >
> > >      Here is a patch to fix std::span pretty printer in versioned
> > > namespace mode.
> > >
> > >      Note that there is still a problem with std::atomic after this patch.
> > >
> > > got: $13 = std::atomic<std::__8::shared_ptr<int>> (empty) = {get() = 0x0}
> > > FAIL: libstdc++-prettyprinters/cxx20.cc print spe
>
> Does this fix it?
>
> --- a/libstdc++-v3/python/libstdcxx/v6/printers.py
> +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
> @@ -1734,6 +1734,7 @@ class StdAtomicPrinter:
>                 impl = val['_M_impl']
>                 self.shptr_printer = SharedPointerPrinter(typename, impl)
>                 self.children = self._shptr_children
> +                self.typename = self.typename.replace(self.value_type.tag, 
> typ)
>
>     def _shptr_children(self):
>         return SmartPtrIterator(self.shptr_printer.pointer)
>
>
> I'll test it with a versioned-namespace build tomorrow.

No, that didn't work, but the attached patch does. Pushed to trunk.
commit 634b0089f664cca96d71262b295025e057054f2c
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Thu May 26 09:49:40 2022

    libstdc++: Fix printing of std::atomic<shared_ptr<T>> for versioned 
namespace
    
    libstdc++-v3/ChangeLog:
    
            * python/libstdcxx/v6/printers.py (SharedPointerPrinter): Strip
            versioned namespace from the template argument too.

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py 
b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 0bd793c0897..17d5e5b5731 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -242,6 +242,7 @@ class SharedPointerPrinter:
         state = 'empty'
         refcounts = self._get_refcounts()
         targ = self.val.type.template_argument(0)
+        targ = strip_versioned_namespace(str(targ))
 
         if refcounts != 0:
             usecount = refcounts['_M_use_count']
@@ -250,7 +251,7 @@ class SharedPointerPrinter:
                 state = 'expired, weak count %d' % weakcount
             else:
                 state = 'use count %d, weak count %d' % (usecount, weakcount - 
1)
-        return '%s<%s> (%s)' % (self.typename, str(targ), state)
+        return '%s<%s> (%s)' % (self.typename, targ, state)
 
 def _tuple_impl_get(val):
     "Return the tuple element stored in a _Tuple_impl<N, T> base class."

Reply via email to