From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10477 invoked by alias); 15 Dec 2003 23:23:38 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 10428 invoked from network); 15 Dec 2003 23:23:36 -0000 Received: from unknown (HELO yosemite.airs.com) (209.128.65.135) by sources.redhat.com with SMTP; 15 Dec 2003 23:23:36 -0000 Received: (qmail 23379 invoked by uid 10); 15 Dec 2003 23:23:32 -0000 Received: (qmail 25846 invoked by uid 500); 15 Dec 2003 23:23:22 -0000 From: Ian Lance Taylor To: David Carlton Cc: gdb Subject: Re: new demangler References: <20031215225452.GA23169@nevyn.them.org> Date: Mon, 15 Dec 2003 23:23:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-12/txt/msg00224.txt.bz2 Ian Lance Taylor writes: > David Carlton writes: > > > So is there a problem with the way class_name_from_physname invokes > > the demangler? It does this: > > > > char *demangled_name = cplus_demangle (physname, DMGL_ANSI); > > > > Compared to other places in GDB where the demangler is called, this is > > unusual since DMGL_PARAMS isn't passed in as well, but I don't see why > > that would cause the demangling to fail completely. > > Well, in fact, there was a bug in the case where DMGL_PARAMS was not > set. I just checked in a patch for it. > > Sorry about that. I've had the patch for a while, but I haven't had a > chance to check it in. BTW, when I say that I just checked in the patch, I mean that I just checked it in to the master sources in the gcc repository. Here's the patch. Ian Index: cp-demangle.c =================================================================== RCS file: /cvs/gcc/gcc/libiberty/cp-demangle.c,v retrieving revision 1.58 diff -u -p -r1.58 cp-demangle.c --- cp-demangle.c 15 Dec 2003 14:37:25 -0000 1.58 +++ cp-demangle.c 15 Dec 2003 23:14:02 -0000 @@ -3622,9 +3622,11 @@ d_demangle (mangled, options, palc) else dc = d_type (&di); - /* If we didn't consume the entire mangled string, then we didn't - successfully demangle it. */ - if (d_peek_char (&di) != '\0') + /* If DMGL_PARAMS is set, then if we didn't consume the entire + mangled string, then we didn't successfully demangle it. If + DMGL_PARAMS is not set, we didn't look at the trailing + parameters. */ + if (((options & DMGL_PARAMS) != 0) && d_peek_char (&di) != '\0') dc = NULL; #ifdef CP_DEMANGLE_DEBUG @@ -3829,37 +3831,37 @@ is_ctor_or_dtor (mangled, ctor_kind, dto dc = d_mangled_name (&di, 1); + /* Note that because we did not pass DMGL_PARAMS, we don't expect to + demangle the entire string. */ + ret = 0; - if (d_peek_char (&di) == '\0') + while (dc != NULL) { - while (dc != NULL) + switch (dc->type) { - switch (dc->type) - { - default: - dc = NULL; - break; - case D_COMP_TYPED_NAME: - case D_COMP_TEMPLATE: - case D_COMP_RESTRICT_THIS: - case D_COMP_VOLATILE_THIS: - case D_COMP_CONST_THIS: - dc = d_left (dc); - break; - case D_COMP_QUAL_NAME: - dc = d_right (dc); - break; - case D_COMP_CTOR: - *ctor_kind = dc->u.s_ctor.kind; - ret = 1; - dc = NULL; - break; - case D_COMP_DTOR: - *dtor_kind = dc->u.s_dtor.kind; - ret = 1; - dc = NULL; - break; - } + default: + dc = NULL; + break; + case D_COMP_TYPED_NAME: + case D_COMP_TEMPLATE: + case D_COMP_RESTRICT_THIS: + case D_COMP_VOLATILE_THIS: + case D_COMP_CONST_THIS: + dc = d_left (dc); + break; + case D_COMP_QUAL_NAME: + dc = d_right (dc); + break; + case D_COMP_CTOR: + *ctor_kind = dc->u.s_ctor.kind; + ret = 1; + dc = NULL; + break; + case D_COMP_DTOR: + *dtor_kind = dc->u.s_dtor.kind; + ret = 1; + dc = NULL; + break; } }