From patchwork Tue Jun 28 20:15:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 102484 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]) by ozlabs.org (Postfix) with SMTP id 77F5DB6F69 for ; Wed, 29 Jun 2011 06:15:30 +1000 (EST) Received: (qmail 32271 invoked by alias); 28 Jun 2011 20:15:24 -0000 Received: (qmail 32210 invoked by uid 22791); 28 Jun 2011 20:15:22 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Jun 2011 20:15:08 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5SKF7gJ027531 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Jun 2011 16:15:08 -0400 Received: from host1.jankratochvil.net ([10.3.113.13]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5SKF5ex025220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 28 Jun 2011 16:15:07 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p5SKF4Dj010396 for ; Tue, 28 Jun 2011 22:15:04 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p5SKF4KT010395 for gcc-patches@gcc.gnu.org; Tue, 28 Jun 2011 22:15:04 +0200 Date: Tue, 28 Jun 2011 22:15:04 +0200 From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Subject: [patch] libiberty/cp-demangle.c: Fix CP_DEMANGLE_DEBUG SIGSEGV Message-ID: <20110628201504.GA8860@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi, a mechanical patch which fixes during #define CP_DEMANGLE_DEBUG make check -> /bin/sh: line 1: 9179 Segmentation fault ./test-demangle < ./demangle-expected which also fixes confusing output for _Z1hI1AIiEdEDTcldtfp_1gIT0_EEET_S2_ binary operator arguments binary operator operator . binary operator arguments ???---> template name 'g' template argument list template parameter 1 argument list Thanks, Jan libiberty/ 2011-06-28 Jan Kratochvil * cp-demangle.c (d_dump): Add " (zero-based)" to DEMANGLE_COMPONENT_TEMPLATE_PARAM. Implement DEMANGLE_COMPONENT_FUNCTION_PARAM, DEMANGLE_COMPONENT_VECTOR_TYPE, DEMANGLE_COMPONENT_NUMBER, DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, DEMANGLE_COMPONENT_LAMBDA, DEMANGLE_COMPONENT_DEFAULT_ARG and DEMANGLE_COMPONENT_UNNAMED_TYPE. Print "??? %d" on unknown dc->type. --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -506,7 +507,10 @@ d_dump (struct demangle_component *dc, int indent) printf ("name '%.*s'\n", dc->u.s_name.len, dc->u.s_name.s); return; case DEMANGLE_COMPONENT_TEMPLATE_PARAM: - printf ("template parameter %ld\n", dc->u.s_number.number); + printf ("template parameter %ld (zero-based)\n", dc->u.s_number.number); + return; + case DEMANGLE_COMPONENT_FUNCTION_PARAM: + printf ("function parameter %ld (zero-based)\n", dc->u.s_number.number); return; case DEMANGLE_COMPONENT_CTOR: printf ("constructor %d\n", (int) dc->u.s_ctor.kind); @@ -633,6 +637,9 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_FIXED_TYPE: printf ("fixed-point type\n"); break; + case DEMANGLE_COMPONENT_VECTOR_TYPE: + printf ("vector type\n"); + break; case DEMANGLE_COMPONENT_ARGLIST: printf ("argument list\n"); break; @@ -675,12 +682,35 @@ 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; + case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: + printf ("global constructors keyed to name\n"); + break; + case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: + printf ("global destructors keyed to name\n"); + break; + case DEMANGLE_COMPONENT_LAMBDA: + printf ("lambda %d (zero-based)\n", dc->u.s_unary_num.num); + d_dump (dc->u.s_unary_num.sub, indent + 2); + return; + case DEMANGLE_COMPONENT_DEFAULT_ARG: + printf ("default argument %d (zero-based)\n", dc->u.s_unary_num.num); + d_dump (dc->u.s_unary_num.sub, indent + 2); + return; + case DEMANGLE_COMPONENT_UNNAMED_TYPE: + printf ("unnamed type %ld\n", dc->u.s_number.number); + return; case DEMANGLE_COMPONENT_PACK_EXPANSION: printf ("pack expansion\n"); break; + default: + printf ("??? %d\n", dc->type); + break; } d_dump (d_left (dc), indent + 2);