From patchwork Wed Jan 4 12:52:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 89832 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp8473395qgi; Wed, 4 Jan 2017 04:53:10 -0800 (PST) X-Received: by 10.84.234.9 with SMTP id m9mr114906241plk.49.1483534390462; Wed, 04 Jan 2017 04:53:10 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u64si72337195pgc.175.2017.01.04.04.53.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jan 2017 04:53:10 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445339-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445339-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445339-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; q=dns; s= default; b=Xhieu1eHeDWezW+OIIvZaWBquc6wIrcski4kDlg8Rhc8vj8jJ//zA n1tFNJuDpnNGg930OFV3VqwX0UCS/qGULB+7ObAyg8LGA++LNtMSGhaePSxhW9Z+ lIzKFvynk5XZiysKJjZMi+ZsgEyp8ww1GagSsIjAyPCvCQF4QGxAuk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=default; bh=0fAYZMq4fqNZtfJNlS0DbL8gHWQ=; b=sw3gL21BVpsDrxPtovH6IPFqiER6 67FyifHmeDKKAVrOD/JMt614hhV3/Y7VMYH14jMESNTERnkKRFqWHo/b9fyZSl7Y i2+LwwtcTAI+z1sxqIs11VPf19YdDrmzjDWAXPZLN7cC2yjROVpTpaiLuAyG0mYm broMcn3jlLD8lUk= Received: (qmail 118109 invoked by alias); 4 Jan 2017 12:52:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 118085 invoked by uid 89); 4 Jan 2017 12:52:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-5.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=hiding, fran=e7ois, Franois, Fran=e7ois?= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Jan 2017 12:52:42 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88E32C04B317; Wed, 4 Jan 2017 12:52:42 +0000 (UTC) Received: from localhost (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v04CqfR8023721; Wed, 4 Jan 2017 07:52:42 -0500 Date: Wed, 4 Jan 2017 12:52:40 +0000 From: Jonathan Wakely To: =?iso-8859-1?Q?Fran=E7ois?= Dumont Cc: "libstdc++@gcc.gnu.org" , gcc-patches Subject: Re: Pretty printers for versioned namespace Message-ID: <20170104125240.GH895@redhat.com> References: <37f043c2-5022-feb2-598b-5cb8ba11d762@gmail.com> <20161129201709.GL3301@redhat.com> <71a8120b-494a-c074-bb13-1ddfa560fdf2@gmail.com> <20161202004150.GI3301@redhat.com> <1a5de3bf-9cfc-3569-6dc8-7ffcd99c286f@gmail.com> <20161209151830.GH6326@redhat.com> <20161215145717.GB22266@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.1 (2016-10-04) On 24/12/16 14:47 +0100, François Dumont wrote: >On 15/12/2016 15:57, Jonathan Wakely wrote: >> >>And we could avoid three re.match expressions with complicated regular >>expressions by creating a helper function to do the "startswith" >>checks: >> >>def is_specialization_of(type, template_name): >> return re.match('^std::(%s)?%s<.*>$' % (vers_nsp, template_name), >>type) is not None >> >>Then replace impl_type.startswith('std::__uniq_ptr_impl<') with >>is_specialization_of(impl_type, '__uniq_ptr_impl') >> >>And replace impl_type.startswith('std::tuple<') with >>is_specialization_of(impl_type, 'tuple') >> >>And replace nodetype.name.startswith('std::_Rb_tree_node') with >>is_specialization_of(nodetype.name, '_Rb_tree_node') >> >>That makes the code much easier to read. >> >> >I agree that hiding the version namespace will be nicer. I just hope >it is possible. I don't think we can really dictate gdb to hide this >namespace during the rendering. In the attached path you will see what >I tried to do. Problem is that I am not sure that printers.py is >intercepting rendering of all types so version namespace will stay >visible in those cases. > >I think the 2 failures that I have with this patch are reflecting this >problem: > >type = holderstd::__7::char_traits, std::__7::allocatorchar> > > >got: type = holderstd::__7::char_traits, std::__7::allocatorchar> > > >FAIL: libstdc++-prettyprinters/whatis.cc whatis ustring_holder >type = holderstd::__7::char_traits, std::__7::allocator > >> >got: type = holderstd::__7::char_traits, std::__7::allocator > >> >FAIL: libstdc++-prettyprinters/whatis.cc whatis sstring_holder > >Shall I simply use regex in those cases and adopt this approach ? I'd prefer not to have to use the regex matches in libstdc++.exp as they complicate things. For the two examples above, the whatis results are bad even for the non-versioned namespace. For specializations of basic_string we only have type printers that recognize the standard typedefs like std::u16string, but not other specializations. We really want it to show std::basic_string not the full name. That would require a TemplateTypePrinter for basic_string. The attached patch works, and should be easy to incorporate into your changes for the versioned namespace. diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 7690a6b..fd63a5c 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -1372,6 +1372,7 @@ def register_type_printers(obj): # Note that we can't have a printer for std::wstreampos, because # it shares the same underlying type as std::streampos. add_one_type_printer(obj, 'fpos', 'streampos') + add_one_type_printer(obj, 'basic_string', 'u16string') add_one_type_printer(obj, 'basic_string', 'u32string') @@ -1397,6 +1398,10 @@ def register_type_printers(obj): 'unique_ptr<(.*), std::default_delete<\\1 ?> >', 'unique_ptr<{1}>') + add_one_template_type_printer(obj, 'basic_string', + 'basic_string<((un)?signed char), std::char_traits<\\1 ?>, std::allocator<\\1 ?> >', + 'basic_string<{1}>') + add_one_template_type_printer(obj, 'deque', 'deque<(.*), std::allocator<\\1 ?> >', 'deque<{1}>') diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc index 31ded8b..7a55bb7 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc @@ -166,11 +166,11 @@ holder knuth_b_holder; ustring *ustring_ptr; holder ustring_holder; -// { dg-final { whatis-test ustring_holder "holder, std::allocator > >" } } +// { dg-final { whatis-test ustring_holder "holder >" } } std::basic_string *sstring_ptr; holder< std::basic_string > sstring_holder; -// { dg-final { whatis-test sstring_holder "holder, std::allocator > >" } } +// { dg-final { whatis-test sstring_holder "holder >" } } std::vector>> *seq1_ptr; holder< std::vector>> > seq1_holder;