From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23559 invoked by alias); 25 Oct 2004 15:26:33 -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 23521 invoked from network); 25 Oct 2004 15:26:30 -0000 Received: from unknown (209.128.65.135) by sourceware.org with QMTP; 25 Oct 2004 15:26:30 -0000 Received: (qmail 19937 invoked by uid 10); 25 Oct 2004 15:26:29 -0000 Received: (qmail 1786 invoked by uid 500); 25 Oct 2004 15:26:19 -0000 Mail-Followup-To: binutils@sources.redhat.com, gdb@sources.redhat.com, dk@artimi.com From: Ian Lance Taylor To: "Dave Korn" Cc: , Subject: Re: "Unrecognized demangle component" error References: Date: Tue, 26 Oct 2004 09:32:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-10/txt/msg00415.txt.bz2 "Dave Korn" writes: > > I wonder which component it was. I should have had the error message > > print it out the number. It would probably also be friendlier to > > print a warning and then return debug_make_void_type (dhandle). > > OK, I quickly plumbed in those changes (using 2.15 release sources), and see > that they're all without exception references to type #34 which I make out to be > DEMANGLE_COMPONENT_FUNCTION_TYPE. Ummm. I would imagine that's a slightly > surprising result, perhaps? That's what I would expect from a static method which takes a function pointer as a parameter. For example, I can recreate the problem with this one-liner: class C { static int foo(int (*pfn)(int)); }; So it's not especially unlikely, it's just not handled. Since you bring it up, I just checked in this patch to handle it. Ian Index: stabs.c =================================================================== RCS file: /cvs/src/src/binutils/stabs.c,v retrieving revision 1.20 diff -u -p -r1.20 stabs.c --- stabs.c 12 Jan 2004 21:08:00 -0000 1.20 +++ stabs.c 25 Oct 2004 15:24:44 -0000 @@ -203,6 +203,8 @@ static debug_type *stab_demangle_argtype (void *, struct stab_handle *, const char *, bfd_boolean *, unsigned int); static debug_type *stab_demangle_v3_argtypes (void *, struct stab_handle *, const char *, bfd_boolean *); +static debug_type *stab_demangle_v3_arglist + (void *, struct stab_handle *, struct demangle_component *, bfd_boolean *); static debug_type stab_demangle_v3_arg (void *, struct stab_handle *, struct demangle_component *, debug_type, bfd_boolean *); @@ -5073,7 +5075,6 @@ stab_demangle_v3_argtypes (void *dhandle { struct demangle_component *dc; void *mem; - unsigned int alloc, count; debug_type *pargs; dc = cplus_demangle_v3_components (physname, DMGL_PARAMS | DMGL_ANSI, &mem); @@ -5093,13 +5094,35 @@ stab_demangle_v3_argtypes (void *dhandle return NULL; } + pargs = stab_demangle_v3_arglist (dhandle, info, + dc->u.s_binary.right->u.s_binary.right, + pvarargs); + + free (mem); + + return pargs; +} + +/* Demangle an argument list in a struct demangle_component tree. + Returns a DEBUG_TYPE_NULL terminated array of argument types, and + sets *PVARARGS to indicate whether this is a varargs function. */ + +static debug_type * +stab_demangle_v3_arglist (void *dhandle, struct stab_handle *info, + struct demangle_component *arglist, + bfd_boolean *pvarargs) +{ + struct demangle_component *dc; + unsigned int alloc, count; + debug_type *pargs; + alloc = 10; pargs = (debug_type *) xmalloc (alloc * sizeof *pargs); *pvarargs = FALSE; count = 0; - for (dc = dc->u.s_binary.right->u.s_binary.right; + for (dc = arglist; dc != NULL; dc = dc->u.s_binary.right) { @@ -5108,8 +5131,8 @@ stab_demangle_v3_argtypes (void *dhandle if (dc->type != DEMANGLE_COMPONENT_ARGLIST) { - fprintf (stderr, _("Unexpected type in demangle tree\n")); - free (mem); + fprintf (stderr, _("Unexpected type in v3 arglist demangling\n")); + free (pargs); return NULL; } @@ -5122,7 +5145,7 @@ stab_demangle_v3_argtypes (void *dhandle *pvarargs = TRUE; continue; } - free (mem); + free (pargs); return NULL; } @@ -5138,8 +5161,6 @@ stab_demangle_v3_argtypes (void *dhandle pargs[count] = DEBUG_TYPE_NULL; - free (mem); - return pargs; } @@ -5173,12 +5194,12 @@ stab_demangle_v3_arg (void *dhandle, str case DEMANGLE_COMPONENT_COMPLEX: case DEMANGLE_COMPONENT_IMAGINARY: case DEMANGLE_COMPONENT_VENDOR_TYPE: - case DEMANGLE_COMPONENT_FUNCTION_TYPE: case DEMANGLE_COMPONENT_ARRAY_TYPE: case DEMANGLE_COMPONENT_PTRMEM_TYPE: case DEMANGLE_COMPONENT_ARGLIST: default: - fprintf (stderr, _("Unrecognized demangle component\n")); + fprintf (stderr, _("Unrecognized demangle component %d\n"), + (int) dc->type); return NULL; case DEMANGLE_COMPONENT_NAME: @@ -5269,6 +5290,34 @@ stab_demangle_v3_arg (void *dhandle, str return debug_make_reference_type (dhandle, dt); } + case DEMANGLE_COMPONENT_FUNCTION_TYPE: + { + debug_type *pargs; + bfd_boolean varargs; + + if (dc->u.s_binary.left == NULL) + { + /* In this case the return type is actually unknown. + However, I'm not sure this will ever arise in practice; + normally an unknown return type would only appear at + the top level, which is handled above. */ + dt = debug_make_void_type (dhandle); + } + else + dt = stab_demangle_v3_arg (dhandle, info, dc->u.s_binary.left, NULL, + NULL); + if (dt == NULL) + return NULL; + + pargs = stab_demangle_v3_arglist (dhandle, info, + dc->u.s_binary.right, + &varargs); + if (pargs == NULL) + return NULL; + + return debug_make_function_type (dhandle, dt, pargs, varargs); + } + case DEMANGLE_COMPONENT_BUILTIN_TYPE: { char *p;