public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] libstdc++: Fix compatibility support in unique_ptr pretty printer Date: Fri, 23 Apr 2021 10:37:29 +0000 (GMT) [thread overview] Message-ID: <20210423103729.271A83A77044@sourceware.org> (raw) https://gcc.gnu.org/g:c44d03afd63c8f537e053d00289ac3f517e1d43b commit c44d03afd63c8f537e053d00289ac3f517e1d43b Author: Jonathan Wakely <jwakely@redhat.com> Date: Mon Aug 10 18:44:06 2020 +0100 libstdc++: Fix compatibility support in unique_ptr pretty printer The support for the old std::unique_ptr implementation was failing, because it tried to work on a typedef instead of the underlying type. The test supposed to verify the support worked wasn't using a typedef, so didn't notice the problem. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (UniquePointerPrinter.__init__): Use gdb.Type.strip_typedefs(). * testsuite/libstdc++-prettyprinters/compat.cc: Use a typedef in the emulated old type. (cherry picked from commit ed11f7e84bcae89f486f5023e566726a7faa7dd4) Diff: --- libstdc++-v3/python/libstdcxx/v6/printers.py | 10 ++++++---- libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 36352b8d0a8..69d5835e0c2 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -179,13 +179,13 @@ class UniquePointerPrinter: def __init__ (self, typename, val): self.val = val - impl_type = val.type.fields()[0].type.tag - if is_specialization_of(impl_type, '__uniq_ptr_impl'): # New implementation + impl_type = val.type.fields()[0].type.strip_typedefs() + if is_specialization_of(str(impl_type), '__uniq_ptr_impl'): # New implementation tuple_member = val['_M_t']['_M_t'] - elif is_specialization_of(impl_type, 'tuple'): + elif is_specialization_of(str(impl_type), 'tuple'): tuple_member = val['_M_t'] else: - raise ValueError("Unsupported implementation for unique_ptr: %s" % impl_type) + raise ValueError("Unsupported implementation for unique_ptr: %s" % str(impl_type)) tuple_impl_type = tuple_member.type.fields()[0].type # _Tuple_impl tuple_head_type = tuple_impl_type.fields()[1].type # _Head_base head_field = tuple_head_type.fields()[0] @@ -193,6 +193,8 @@ class UniquePointerPrinter: self.pointer = tuple_member['_M_head_impl'] elif head_field.is_base_class: self.pointer = tuple_member.cast(head_field.type) + else: + raise ValueError("Unsupported implementation for tuple in unique_ptr: %s" % str(impl_type)) def children (self): return SmartPtrIterator(self.pointer) diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc index 1555ba8e798..81e0ce7213f 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc @@ -54,7 +54,9 @@ namespace std { unique_ptr(T* p) { _M_t._M_head_impl = p; } - tuple<T*, D> _M_t; + using __tuple_type = tuple<T*, D>; + + __tuple_type _M_t; }; // Old representation of std::optional, before GCC 9
reply other threads:[~2021-04-23 10:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210423103729.271A83A77044@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).