From patchwork Wed Jul 3 07:33:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Muldoon X-Patchwork-Id: 256547 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 54CDD2C009E for ; Wed, 3 Jul 2013 17:33:39 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=TFlIvQXEcOtlSoMI8Ntn2EbkaWEZ5taCThrp97R3C85CfNqThbJTJ oyYsxcx+3NW5g7+sHNGZm7qX5GE+Z5xmYMZSiM+75iT8pq6pfzrdGG5UipIC++hK 4f3vaXkHC2aoXPrdpFy7uX05GJMB9xk0nJxnrs3yYxwIhDB38676H0= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; s=default; bh=Kn1ROUNhXpIC0XJ++t/uhC3izqg=; b=aQVefsBxPZhxF7dMDA/DoHA6LJG0 ya+4SiCtEYwcojKmlNfONIMrNDX8P8AeG4ypGDWFjcmBHJAE5OjCLqy5ngAZ+C4N XUnPadwpp5kw4oNVuol5i7x5242BDLUsEMI5cAMJPJnBX9vZXtnphb5iXgpsPKKx klsz78PucwYHsmI= Received: (qmail 31736 invoked by alias); 3 Jul 2013 07:33:33 -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 31712 invoked by uid 89); 3 Jul 2013 07:33:30 -0000 X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 03 Jul 2013 07:33:29 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r637XSaD030975 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Jul 2013 03:33:28 -0400 Received: from localhost.localdomain (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r637XQjJ007578; Wed, 3 Jul 2013 03:33:27 -0400 Message-ID: <51D3D3C6.2030001@redhat.com> Date: Wed, 03 Jul 2013 08:33:26 +0100 From: Phil Muldoon MIME-Version: 1.0 To: Tom Tromey CC: gcc-patches@sourceware.org Subject: Re: [patch] [python libstdc++ printers] Fix gdb/15195 References: <514ADF9B.1090407@redhat.com> <87mwtw4yy6.fsf@fleche.redhat.com> <51B6E3C5.3000209@redhat.com> <87sj0mglyg.fsf@fleche.redhat.com> In-Reply-To: <87sj0mglyg.fsf@fleche.redhat.com> On 13/06/13 14:49, Tom Tromey wrote: >>>>>> "Phil" == Phil Muldoon writes: > > Phil> Attached is an updated patch correcting the issues that you pointed > Phil> out. > > The patch itself looks fine to me, but I don't think I can approve it. > > Tom This new patch replaces and obsoletes the previous. On further inspection of some other pretty printer related bugs, it seems that all of the printers need to fetch the referenced value where the value type is a reference. This patch applies that change, and adds a number of reference based tests. Cheers, Phil 2013-07-03 Phil Muldoon PR gcc/53477 http://sourceware.org/bugzilla/show_bug.cgi?id=15195 * python/libstdcxx/v6/printers.py (Printer.__call__): If a value is a reference, fetch referenced value. (RxPrinter.invoke): Ditto. * testsuite/libstdc++-prettyprinters/cxx11.cc (main): Add -O0 flag. Add referenced value tests. Index: python/libstdcxx/v6/printers.py =================================================================== --- python/libstdcxx/v6/printers.py (revision 199642) +++ python/libstdcxx/v6/printers.py (working copy) @@ -786,6 +786,10 @@ def invoke(self, value): if not self.enabled: return None + + if value.type.code == gdb.TYPE_CODE_REF: + value = value.referenced_value() + return self.function(self.name, value) # A pretty-printer that conforms to the "PrettyPrinter" protocol from @@ -841,6 +845,10 @@ return None basename = match.group(1) + + if val.type.code == gdb.TYPE_CODE_REF: + val = val.referenced_value() + if basename in self.lookup: return self.lookup[basename].invoke(val) Index: testsuite/libstdc++-prettyprinters/cxx11.cc =================================================================== --- testsuite/libstdc++-prettyprinters/cxx11.cc (revision 199706) +++ testsuite/libstdc++-prettyprinters/cxx11.cc (working copy) @@ -1,5 +1,5 @@ // { dg-do run } -// { dg-options "-std=gnu++11 -g" } +// { dg-options "-std=gnu++11 -g -O0" } // Copyright (C) 2011-2013 Free Software Foundation, Inc. // @@ -25,6 +25,8 @@ #include #include +typedef std::tuple ExTuple; + template void placeholder(const T &s) @@ -63,43 +65,75 @@ std::forward_list efl; // { dg-final { note-test efl "empty std::forward_list" } } + std::forward_list &refl = efl; +// { dg-final { note-test refl "empty std::forward_list" } } + std::forward_list fl; fl.push_front(2); fl.push_front(1); // { dg-final { note-test fl {std::forward_list = {[0] = 1, [1] = 2}} } } + std::forward_list &rfl = fl; +// { dg-final { note-test rfl {std::forward_list = {[0] = 1, [1] = 2}} } } + std::unordered_map eum; // { dg-final { note-test eum "std::unordered_map with 0 elements" } } + std::unordered_map &reum = eum; +// { dg-final { note-test reum "std::unordered_map with 0 elements" } } + std::unordered_multimap eumm; // { dg-final { note-test eumm "std::unordered_multimap with 0 elements" } } + std::unordered_multimap &reumm = eumm; +// { dg-final { note-test reumm "std::unordered_multimap with 0 elements" } } + std::unordered_set eus; // { dg-final { note-test eus "std::unordered_set with 0 elements" } } + std::unordered_set &reus = eus; +// { dg-final { note-test reus "std::unordered_set with 0 elements" } } + std::unordered_multiset eums; // { dg-final { note-test eums "std::unordered_multiset with 0 elements" } } + std::unordered_multiset &reums = eums; +// { dg-final { note-test reums "std::unordered_multiset with 0 elements" } } std::unordered_map uom; uom[5] = "three"; uom[3] = "seven"; // { dg-final { note-test uom {std::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } } + std::unordered_map &ruom = uom; +// { dg-final { note-test ruom {std::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } } + std::unordered_multimap uomm; uomm.insert(std::pair (5, "three")); uomm.insert(std::pair (5, "seven")); // { dg-final { note-test uomm {std::unordered_multimap with 2 elements = {[5] = "seven", [5] = "three"}} } } + std::unordered_multimap &ruomm = uomm; +// { dg-final { note-test ruomm {std::unordered_multimap with 2 elements = {[5] = "seven", [5] = "three"}} } } std::unordered_set uos; uos.insert(5); // { dg-final { note-test uos {std::unordered_set with 1 elements = {[0] = 5}} } } + std::unordered_set &ruos = uos; +// { dg-final { note-test ruos {std::unordered_set with 1 elements = {[0] = 5}} } } std::unordered_multiset uoms; uoms.insert(5); // { dg-final { note-test uoms {std::unordered_multiset with 1 elements = {[0] = 5}} } } + std::unordered_multiset &ruoms = uoms; +// { dg-final { note-test ruoms {std::unordered_multiset with 1 elements = {[0] = 5}} } } std::unique_ptr uptr (new datum); uptr->s = "hi bob"; uptr->i = 23; // { dg-final { regexp-test uptr {std::unique_ptr.datum. containing 0x.*} } } + std::unique_ptr &ruptr = uptr; +// { dg-final { regexp-test ruptr {std::unique_ptr.datum. containing 0x.*} } } + ExTuple tpl(6,7); +// { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } } + ExTuple &rtpl = tpl; +// { dg-final { note-test rtpl {std::tuple containing = {[1] = 6, [2] = 7}} } } placeholder(""); // Mark SPOT use(efl); use(fl);