(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 *);
{
struct demangle_component *dc;
void *mem;
- unsigned int alloc, count;
debug_type *pargs;
dc = cplus_demangle_v3_components (physname, DMGL_PARAMS | DMGL_ANSI, &mem);
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)
{
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;
}
*pvarargs = TRUE;
continue;
}
- free (mem);
+ free (pargs);
return NULL;
}
pargs[count] = DEBUG_TYPE_NULL;
- free (mem);
-
return pargs;
}
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:
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;