From patchwork Tue May 27 11:57:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 352880 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 66C6B1400D2 for ; Tue, 27 May 2014 21:58:22 +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:from :to:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=EygTD+k31xTglS7GCBD7XP0leAv0D8Wqz+eaznR6mMkTszMzOwT2w FB6eHeIRDncnCnDqavbqhE45HtGFvhygeVpfDEBtuEeJ55GguVVMHfjWjCRXVzDp 7Wvn64zGiqVtD5pklaUSmUHKW/PVtiGrhgrebwtWpTOEHAfzj3I5jk= 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:from :to:subject:date:message-id:in-reply-to:references; s=default; bh=3fR3id6XqTAfqcdQ56U33MDKFmA=; b=NC+d5qXMSWvwNqJw3mfrK2Pn2c6X 8uyJlUb1XeiSFliL83uKknLeOkUs0132oChuKhaRdPjSrfh6gcH6pElo+8CBTA36 feuDNT3B8N1y9t0MGbwkywOl6+C/NgbsDuubMIJpHUrmfFrNuAThLWLKE8z9dVwS XPPpQGE2/oHS/JQ= Received: (qmail 5158 invoked by alias); 27 May 2014 11:57:44 -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 4997 invoked by uid 89); 27 May 2014 11:57:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 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; Tue, 27 May 2014 11:57:41 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4RBvdNi025157 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 May 2014 07:57:39 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4RBvapc007322 for ; Tue, 27 May 2014 07:57:38 -0400 From: Pedro Alves To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/3] Fix demangler testsuite crashes with CP_DEMANGLE_DEBUG defined Date: Tue, 27 May 2014 12:57:34 +0100 Message-Id: <1401191856-27585-2-git-send-email-palves@redhat.com> In-Reply-To: <1401191856-27585-1-git-send-email-palves@redhat.com> References: <1401191856-27585-1-git-send-email-palves@redhat.com> I tried running the demangler's testsuite with CP_DEMANGLE_DEBUG defined, but it crashed, with: Program received signal SIGSEGV, Segmentation fault. 0x000000000040a8c3 in d_dump (dc=0x1, indent=12) at ../../src/libiberty/cp-demangle.c:567 567 switch (dc->type) (gdb) bt 3 #0 0x000000000040a8c3 in d_dump (dc=0x1, indent=12) at ../../src/libiberty/cp-demangle.c:567 #1 0x000000000040ae47 in d_dump (dc=0x7fffffffd098, indent=10) at ../../src/libiberty/cp-demangle.c:787 #2 0x000000000040ae47 in d_dump (dc=0x7fffffffd0c8, indent=8) at ../../src/libiberty/cp-demangle.c:787 Note dc=0x1, which is obviously a bogus pointer. This is the end of d_dump recursing for a component type that that doesn't actually have subtrees: 787 d_dump (d_left (dc), indent + 2); 788 d_dump (d_right (dc), indent + 2); This fixes the two cases the testsuite trips on. libiberty/ 2014-05-26 Pedro Alves * cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_FUNCTION_PARAM and DEMANGLE_COMPONENT_NUMBER. --- libiberty/cp-demangle.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 68d8ee1..c0d2ffe 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -575,6 +575,9 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_TEMPLATE_PARAM: printf ("template parameter %ld\n", dc->u.s_number.number); return; + case DEMANGLE_COMPONENT_FUNCTION_PARAM: + printf ("function parameter %ld\n", dc->u.s_number.number); + return; case DEMANGLE_COMPONENT_CTOR: printf ("constructor %d\n", (int) dc->u.s_ctor.kind); d_dump (dc->u.s_ctor.name, indent + 2); @@ -760,6 +763,9 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_CHARACTER: printf ("character '%c'\n", dc->u.s_character.character); return; + case DEMANGLE_COMPONENT_NUMBER: + printf ("number %ld\n", dc->u.s_number.number); + return; case DEMANGLE_COMPONENT_DECLTYPE: printf ("decltype\n"); break;