From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 580 invoked by alias); 11 Jul 2009 20:19:57 -0000 Received: (qmail 439 invoked by uid 22791); 11 Jul 2009 20:19:55 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_24,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 11 Jul 2009 20:19:54 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6BKJiI8012814; Sat, 11 Jul 2009 16:19:44 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6BKJiBd007982; Sat, 11 Jul 2009 16:19:44 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6BKJgP3007779; Sat, 11 Jul 2009 16:19:43 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n6BKJgdg012277; Sat, 11 Jul 2009 22:19:42 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id n6BKJebX012272; Sat, 11 Jul 2009 22:19:40 +0200 Date: Sat, 11 Jul 2009 23:29:00 -0000 From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Cc: binutils@sourceware.org, gdb-patches@sourceware.org Subject: [patch] libiberty: demangle_component for `global {constructors,destructors} keyed to' Message-ID: <20090711201940.GA7327@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-07/txt/msg00339.txt.bz2 Hi, asking if this patch gets accepted to be able to clean up gdb/cp-name-parser.y. GDB has now a gcc-4.5 enum comparison warning: http://sourceware.org/ml/gdb-patches/2009-07/msg00323.html GDB would benefit only from the include/ and d_print_comp part of the patch. The d_demangle_callback part just tries to use it, it can be safely dropped. There still remains s similiar but more complicated _GLOBAL_$[ID]$ demangler in libiberty/cplus-dem.c. Regression tested gcc, binutils and gdb on x86_64-fedora11-linux-gnu. (I do not have the gcc svn check-in technical rights.) Thanks, Jan include/ 2009-07-11 Jan Kratochvil * demangle.h (enum demangle_component_type ) (enum demangle_component_type ): New. libiberty/ 2009-07-11 Jan Kratochvil * cp-demangle.c (d_print_comp ) (d_print_comp ) (d_make_comp u.s_binary.left); + return; + + case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: + d_append_string (dpi, "global destructors keyed to "); + d_print_comp (dpi, dc->u.s_binary.left); + return; + default: d_print_error (dpi); return; @@ -4484,33 +4496,30 @@ static int d_demangle_callback (const char *mangled, int options, demangle_callbackref callback, void *opaque) { - int type; + enum + { + DCT_TYPE, + DCT_MANGLED, + DCT_GLOBAL_CTORS, + DCT_GLOBAL_DTORS + } + type; struct d_info di; struct demangle_component *dc; int status; if (mangled[0] == '_' && mangled[1] == 'Z') - type = 0; + type = DCT_MANGLED; else if (strncmp (mangled, "_GLOBAL_", 8) == 0 && (mangled[8] == '.' || mangled[8] == '_' || mangled[8] == '$') && (mangled[9] == 'D' || mangled[9] == 'I') && mangled[10] == '_') - { - const char *intro; - - intro = (mangled[9] == 'I') - ? "global constructors keyed to " - : "global destructors keyed to "; - - callback (intro, strlen (intro), opaque); - callback (mangled + 11, strlen (mangled + 11), opaque); - return 1; - } + type = mangled[9] == 'I' ? DCT_GLOBAL_CTORS : DCT_GLOBAL_DTORS; else { if ((options & DMGL_TYPES) == 0) return 0; - type = 1; + type = DCT_TYPE; } cplus_demangle_init_info (mangled, options, strlen (mangled), &di); @@ -4527,10 +4536,25 @@ d_demangle_callback (const char *mangled, int options, di.subs = alloca (di.num_subs * sizeof (*di.subs)); #endif - if (type) - dc = cplus_demangle_type (&di); - else - dc = cplus_demangle_mangled_name (&di, 1); + switch (type) + { + case DCT_TYPE: + dc = cplus_demangle_type (&di); + break; + case DCT_MANGLED: + dc = cplus_demangle_mangled_name (&di, 1); + break; + case DCT_GLOBAL_CTORS: + case DCT_GLOBAL_DTORS: + d_advance (&di, 11); + dc = d_make_comp (&di, type == DCT_GLOBAL_CTORS + ? DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS + : DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, + d_make_name (&di, d_str (&di), strlen (d_str (&di))), + NULL); + d_advance (&di, strlen (d_str (&di))); + break; + } /* If DMGL_PARAMS is set, then if we didn't consume the entire mangled string, then we didn't successfully demangle it. If