aboutsummaryrefslogtreecommitdiff
path: root/binutils/stabs.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2004-10-25 15:25:20 +0000
committerIan Lance Taylor <ian@airs.com>2004-10-25 15:25:20 +0000
commit2b4c4cc415203ba612b819e52c1a3d1169ce7c99 (patch)
treeca7e4355d71d713fae32305e33d2401b1ab33fb6 /binutils/stabs.c
parent1ffa9a1825124bdf3d99f1f09b720aac99038822 (diff)
downloadgdb-2b4c4cc415203ba612b819e52c1a3d1169ce7c99.zip
gdb-2b4c4cc415203ba612b819e52c1a3d1169ce7c99.tar.gz
gdb-2b4c4cc415203ba612b819e52c1a3d1169ce7c99.tar.bz2
* stabs.c (stab_demangle_v3_arglist): New static function, broken
out of stab_demangle_v3_argtypes. (stab_demangle_v3_argtypes): Call it. (stab_demangle_v3_arg): Handle DEMANGLE_COMPONENT_FUNCTION_TYPE. If we find an unrecognized component, print out its number.
Diffstat (limited to 'binutils/stabs.c')
-rw-r--r--binutils/stabs.c67
1 files changed, 58 insertions, 9 deletions
diff --git a/binutils/stabs.c b/binutils/stabs.c
index 7af10ef..52a20e8 100644
--- a/binutils/stabs.c
+++ b/binutils/stabs.c
@@ -203,6 +203,8 @@ static debug_type *stab_demangle_argtypes
(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 stab_handle *info,
{
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, struct stab_handle *info,
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, struct stab_handle *info,
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, struct stab_handle *info,
*pvarargs = TRUE;
continue;
}
- free (mem);
+ free (pargs);
return NULL;
}
@@ -5138,8 +5161,6 @@ stab_demangle_v3_argtypes (void *dhandle, struct stab_handle *info,
pargs[count] = DEBUG_TYPE_NULL;
- free (mem);
-
return pargs;
}
@@ -5173,12 +5194,12 @@ stab_demangle_v3_arg (void *dhandle, struct stab_handle *info,
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, struct stab_handle *info,
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;