public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer
@ 2022-05-25 20:26 François Dumont
  2022-05-25 23:34 ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: François Dumont @ 2022-05-25 20:26 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 635 bytes --]

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

     libstdc++: [_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer

     libstdc++-v3/ChangeLog:

             * python/libstdcxx/v6/printers.py (StdSpanPrinter.__init__):
             Strip typename from version namespace.

Tested under Linux x86_64 _GLIBCXX_INLINE_VERSION mode.

Ok to commit ?

François

[-- Attachment #2: span_printers.patch --]
[-- Type: text/x-patch, Size: 991 bytes --]

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 0bd793c0897..fafdff3e5c0 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1687,7 +1687,7 @@ class StdSpanPrinter:
             return '[%d]' % count, (self.begin + count).dereference()
 
     def __init__(self, typename, val):
-        self.typename = typename
+        self.typename = strip_versioned_namespace(typename)
         self.val = val
         if val.type.template_argument(1) == gdb.parse_and_eval('static_cast<std::size_t>(-1)'):
             self.size = val['_M_extent']['_M_extent_value']
@@ -1994,7 +1994,7 @@ class FilteringTypePrinter(object):
         self.enabled = True
 
     class _recognizer(object):
-        "The recognizer class for TemplateTypePrinter."
+        "The recognizer class for FilteringTypePrinter."
 
         def __init__(self, match, name):
             self.match = match

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer
  2022-05-25 20:26 [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer François Dumont
@ 2022-05-25 23:34 ` Jonathan Wakely
  2022-05-25 23:38   ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2022-05-25 23:34 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

On Wed, 25 May 2022 at 21:29, François Dumont via Libstdc++
<libstdc++@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
>
>      libstdc++: [_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer
>
>      libstdc++-v3/ChangeLog:
>
>              * python/libstdcxx/v6/printers.py (StdSpanPrinter.__init__):
>              Strip typename from version namespace.
>
> Tested under Linux x86_64 _GLIBCXX_INLINE_VERSION mode.
>
> Ok to commit ?

OK, thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer
  2022-05-25 23:34 ` Jonathan Wakely
@ 2022-05-25 23:38   ` Jonathan Wakely
  2022-05-26  9:21     ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2022-05-25 23:38 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

On Thu, 26 May 2022 at 00:34, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Wed, 25 May 2022 at 21:29, François Dumont via Libstdc++
> <libstdc++@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.





> >
> >      libstdc++: [_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer
> >
> >      libstdc++-v3/ChangeLog:
> >
> >              * python/libstdcxx/v6/printers.py (StdSpanPrinter.__init__):
> >              Strip typename from version namespace.
> >
> > Tested under Linux x86_64 _GLIBCXX_INLINE_VERSION mode.
> >
> > Ok to commit ?
>
> OK, thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer
  2022-05-25 23:38   ` Jonathan Wakely
@ 2022-05-26  9:21     ` Jonathan Wakely
  2022-05-26  9:40       ` François Dumont
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2022-05-26  9:21 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]

On Thu, 26 May 2022 at 00:38, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Thu, 26 May 2022 at 00:34, Jonathan Wakely <jwakely@redhat.com> wrote:
> >
> > On Wed, 25 May 2022 at 21:29, François Dumont via Libstdc++
> > <libstdc++@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.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1375 bytes --]

commit 634b0089f664cca96d71262b295025e057054f2c
Author: Jonathan Wakely <jwakely@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."

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer
  2022-05-26  9:21     ` Jonathan Wakely
@ 2022-05-26  9:40       ` François Dumont
  2022-05-26 14:49         ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: François Dumont @ 2022-05-26  9:40 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++

On 26/05/22 11:21, Jonathan Wakely wrote:
> On Thu, 26 May 2022 at 00:38, Jonathan Wakely <jwakely@redhat.com> wrote:
>> On Thu, 26 May 2022 at 00:34, Jonathan Wakely <jwakely@redhat.com> wrote:
>>> On Wed, 25 May 2022 at 21:29, François Dumont via Libstdc++
>>> <libstdc++@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.

Great, I just pushed mine too.

Thanks


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer
  2022-05-26  9:40       ` François Dumont
@ 2022-05-26 14:49         ` Jonathan Wakely
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2022-05-26 14:49 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++

On Thu, 26 May 2022 at 10:40, François Dumont wrote:
>
> On 26/05/22 11:21, Jonathan Wakely wrote:
> > On Thu, 26 May 2022 at 00:38, Jonathan Wakely <jwakely@redhat.com> wrote:
> >> On Thu, 26 May 2022 at 00:34, Jonathan Wakely <jwakely@redhat.com> wrote:
> >>> On Wed, 25 May 2022 at 21:29, François Dumont via Libstdc++
> >>> <libstdc++@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.
>
> Great, I just pushed mine too.

I have patches to fix the cxx11.cc printer test for
std::__v8::iostream_category() and std::__v8::atomic too.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-26 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25 20:26 [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::span pretty printer François Dumont
2022-05-25 23:34 ` Jonathan Wakely
2022-05-25 23:38   ` Jonathan Wakely
2022-05-26  9:21     ` Jonathan Wakely
2022-05-26  9:40       ` François Dumont
2022-05-26 14:49         ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).