aboutsummaryrefslogtreecommitdiff
path: root/binutils/prdbg.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1996-01-19 18:03:04 +0000
committerIan Lance Taylor <ian@airs.com>1996-01-19 18:03:04 +0000
commit07aa1e1b7a4a32b727bb943186680cbd3fc77b94 (patch)
tree4218394effa8aecb53d6e3e17f31e99bc716df86 /binutils/prdbg.c
parent8c038399b5bda6b16758e4a264248b32ad5aa2de (diff)
downloadgdb-07aa1e1b7a4a32b727bb943186680cbd3fc77b94.zip
gdb-07aa1e1b7a4a32b727bb943186680cbd3fc77b94.tar.gz
gdb-07aa1e1b7a4a32b727bb943186680cbd3fc77b94.tar.bz2
* debug.h (enum debug_type_kind): Add DEBUG_KIND_ILLEGAL.
(struct debug_write_fns): Add field ellipsis_type. Add id parameter to start_struct_type, start_class_type, and tag_type. (debug_make_ellipsis_type): Declare. (debug_find_named_type): Declare. (debug_get_type_kind): Declare. (debug_get_return_type): Declare. (debug_get_parameter_types): Declare. (debug_get_fields): Declare. (debug_get_field_type): Declare. * debug.c (struct debug_handle): Add fields class_id and base_id. (struct debug_class_type): Add field id. (struct debug_method_variant): Rename argtypes to physname. Change all uses. (debug_ellipsis_type): New static variable. (ELLIPSIS_P): New macro. (debug_make_ellipsis_type): New function. (debug_make_method_variant): Rename argtypes to physname. (debug_make_static_method_variant): Likewise. (debug_name_type): Always put types in the global namespace. (debug_find_named_type): New function. (debug_find_tagged_type): Treat DEBUG_KIND_ILLEGAL specially, rather than DEBUG_KIND_VOID. (debug_get_real_type): New static function. (debug_get_type_kind): New function. (debug_get_return_type): New function. (debug_get_parameter_types): New function. (debug_get_fields): New function. (debug_get_field_type): New function. (debug_write): Initialize base_id. (debug_write_type): Pass new id argument to tag_type. Handle DEBUG_KIND_ILLEGAL. Use id for DEBUG_KIND_STRUCT and DEBUG_KIND_UNION. Handle ellipsis for method arguments. (debug_write_class_type): Don't dereference kclass if it is NULL. Use id. * prdbg.c (pr_fns): Add pr_ellipsis_type. (pr_ellipsis_type): New static function. (pr_pointer_type): If this is a pointer to an array, parenthesize it correctly. (pr_start_struct_type): Add id parameter. (pr_start_class_type): Likewise. (pr_tag_type): Likewise. (pr_fix_visibility): Add the visibility to the top of the stack, not the second element on the stack. (pr_struct_field): Pop the stack before calling pr_fix_visibility. (pr_class_static_member): Likewise. (pr_class_start_method): Don't push a type, just set the method name in the type on the top of the stack. (pr_class_end_method): Don't pop the stack. (pr_class_method_variant): Rename argtypes parameter to physname. Append const and volatile rather than prepending them. Add a space after the physname. (pr_class_static_method_variant): Likewise. * ieee.c (ieee_fns): Add ieee_ellipsis_type. (ieee_define_named_type): Use DEBUG_KIND_ILLEGAL rather than DEBUG_KIND_VOID. (write_ieee_debugging_info): Likewise. (ieee_typdef): Likewise. (ieee_ellipsis_type): New static function. (ieee_start_struct_type): Add id parameter. (ieee_start_class_type): Likewise. (ieee_tag_type): Likewise. (ieee_class_method_variant): Rename name to physname. (ieee_class_static_method_variant): Likewise.
Diffstat (limited to 'binutils/prdbg.c')
-rw-r--r--binutils/prdbg.c169
1 files changed, 108 insertions, 61 deletions
diff --git a/binutils/prdbg.c b/binutils/prdbg.c
index 133973c..f7383bb 100644
--- a/binutils/prdbg.c
+++ b/binutils/prdbg.c
@@ -72,6 +72,7 @@ static boolean pr_fix_visibility
static boolean pr_start_compilation_unit PARAMS ((PTR, const char *));
static boolean pr_start_source PARAMS ((PTR, const char *));
+static boolean pr_ellipsis_type PARAMS ((PTR));
static boolean pr_empty_type PARAMS ((PTR));
static boolean pr_void_type PARAMS ((PTR));
static boolean pr_int_type PARAMS ((PTR, unsigned int, boolean));
@@ -92,12 +93,13 @@ static boolean pr_method_type PARAMS ((PTR, boolean, int));
static boolean pr_const_type PARAMS ((PTR));
static boolean pr_volatile_type PARAMS ((PTR));
static boolean pr_start_struct_type
- PARAMS ((PTR, const char *, boolean, unsigned int));
+ PARAMS ((PTR, const char *, unsigned int, boolean, unsigned int));
static boolean pr_struct_field
PARAMS ((PTR, const char *, bfd_vma, bfd_vma, enum debug_visibility));
static boolean pr_end_struct_type PARAMS ((PTR));
static boolean pr_start_class_type
- PARAMS ((PTR, const char *, boolean, unsigned int, boolean, boolean));
+ PARAMS ((PTR, const char *, unsigned int, boolean, unsigned int, boolean,
+ boolean));
static boolean pr_class_static_member
PARAMS ((PTR, const char *, const char *, enum debug_visibility));
static boolean pr_class_baseclass
@@ -111,7 +113,8 @@ static boolean pr_class_static_method_variant
static boolean pr_class_end_method PARAMS ((PTR));
static boolean pr_end_class_type PARAMS ((PTR));
static boolean pr_typedef_type PARAMS ((PTR, const char *));
-static boolean pr_tag_type PARAMS ((PTR, const char *, enum debug_type_kind));
+static boolean pr_tag_type
+ PARAMS ((PTR, const char *, unsigned int, enum debug_type_kind));
static boolean pr_typdef PARAMS ((PTR, const char *));
static boolean pr_tag PARAMS ((PTR, const char *));
static boolean pr_int_constant PARAMS ((PTR, const char *, bfd_vma));
@@ -131,6 +134,7 @@ static const struct debug_write_fns pr_fns =
{
pr_start_compilation_unit,
pr_start_source,
+ pr_ellipsis_type,
pr_empty_type,
pr_void_type,
pr_int_type,
@@ -409,6 +413,17 @@ pr_start_source (p, filename)
return true;
}
+/* Push an ellipsis type onto the type stack. */
+
+static boolean
+pr_ellipsis_type (p)
+ PTR p;
+{
+ struct pr_handle *info = (struct pr_handle *) p;
+
+ return push_type (info, "...");
+}
+
/* Push an empty type onto the type stack. */
static boolean
@@ -563,9 +578,13 @@ pr_pointer_type (p)
PTR p;
{
struct pr_handle *info = (struct pr_handle *) p;
+ char *s;
assert (info->stack != NULL);
+ s = strchr (info->stack->type, '|');
+ if (s != NULL && s[1] == '[')
+ return substitute_type (info, "(*|)");
return substitute_type (info, "*|");
}
@@ -838,9 +857,10 @@ pr_volatile_type (p)
/* Start accumulating a struct type. */
static boolean
-pr_start_struct_type (p, tag, structp, size)
+pr_start_struct_type (p, tag, id, structp, size)
PTR p;
const char *tag;
+ unsigned int id;
boolean structp;
unsigned int size;
{
@@ -853,14 +873,22 @@ pr_start_struct_type (p, tag, structp, size)
return false;
if (tag != NULL)
{
- if (! append_type (info, tag)
- || ! append_type (info, " "))
+ if (! append_type (info, tag))
+ return false;
+ }
+ else
+ {
+ char idbuf[20];
+
+ sprintf (idbuf, "%%anon%u", id);
+ if (! append_type (info, idbuf))
return false;
}
+
if (size != 0)
- sprintf (ab, "{ /* size %u */\n", size);
+ sprintf (ab, " { /* size %u */\n", size);
else
- strcpy (ab, "{\n");
+ strcpy (ab, " {\n");
if (! append_type (info, ab))
return false;
info->stack->visibility = DEBUG_VISIBILITY_PUBLIC;
@@ -875,16 +903,15 @@ pr_fix_visibility (info, visibility)
enum debug_visibility visibility;
{
const char *s;
- struct pr_stack *top;
char *t;
unsigned int len;
- assert (info->stack != NULL && info->stack->next != NULL);
+ assert (info->stack != NULL);
- if (info->stack->next->visibility == visibility)
+ if (info->stack->visibility == visibility)
return true;
- assert (info->stack->next->visibility != DEBUG_VISIBILITY_IGNORE);
+ assert (info->stack->visibility != DEBUG_VISIBILITY_IGNORE);
switch (visibility)
{
@@ -903,12 +930,7 @@ pr_fix_visibility (info, visibility)
}
/* Trim off a trailing space in the struct string, to make the
- output look a bit better, then stick on the visibility string.
- Pop the stack temporarily to make the string manipulation
- simpler. */
-
- top = info->stack;
- info->stack = top->next;
+ output look a bit better, then stick on the visibility string. */
t = info->stack->type;
len = strlen (t);
@@ -922,8 +944,6 @@ pr_fix_visibility (info, visibility)
info->stack->visibility = visibility;
- info->stack = top;
-
return true;
}
@@ -939,9 +959,7 @@ pr_struct_field (p, name, bitpos, bitsize, visibility)
{
struct pr_handle *info = (struct pr_handle *) p;
char ab[20];
-
- if (! pr_fix_visibility (info, visibility))
- return false;
+ char *t;
if (! substitute_type (info, name))
return false;
@@ -965,7 +983,14 @@ pr_struct_field (p, name, bitpos, bitsize, visibility)
|| ! indent_type (info))
return false;
- return append_type (info, pop_type (info));
+ t = pop_type (info);
+ if (t == NULL)
+ return false;
+
+ if (! pr_fix_visibility (info, visibility))
+ return false;
+
+ return append_type (info, t);
}
/* Finish a struct type. */
@@ -995,9 +1020,10 @@ pr_end_struct_type (p)
/* Start a class type. */
static boolean
-pr_start_class_type (p, tag, structp, size, vptr, ownvptr)
+pr_start_class_type (p, tag, id, structp, size, vptr, ownvptr)
PTR p;
const char *tag;
+ unsigned int id;
boolean structp;
unsigned int size;
boolean vptr;
@@ -1019,11 +1045,19 @@ pr_start_class_type (p, tag, structp, size, vptr, ownvptr)
return false;
if (tag != NULL)
{
- if (! append_type (info, tag)
- || ! append_type (info, " "))
+ if (! append_type (info, tag))
return false;
}
- if (! append_type (info, "{"))
+ else
+ {
+ char idbuf[20];
+
+ sprintf (idbuf, "%%anon%u", id);
+ if (! append_type (info, idbuf))
+ return false;
+ }
+
+ if (! append_type (info, " {"))
return false;
if (size != 0 || vptr || ownvptr)
{
@@ -1077,19 +1111,26 @@ pr_class_static_member (p, name, physname, visibility)
enum debug_visibility visibility;
{
struct pr_handle *info = (struct pr_handle *) p;
+ char *t;
- if (! pr_fix_visibility (info, visibility))
+ if (! substitute_type (info, name))
return false;
- if (! substitute_type (info, name))
+ if (! prepend_type (info, "static ")
+ || ! append_type (info, "; /* ")
+ || ! append_type (info, physname)
+ || ! append_type (info, " */\n")
+ || ! indent_type (info))
return false;
- return (prepend_type (info, "static ")
- && append_type (info, "; /* physname ")
- && append_type (info, physname)
- && append_type (info, " */\n")
- && indent_type (info)
- && append_type (info, pop_type (info)));
+ t = pop_type (info);
+ if (t == NULL)
+ return false;
+
+ if (! pr_fix_visibility (info, visibility))
+ return false;
+
+ return append_type (info, t);
}
/* Add a base class to a class. */
@@ -1200,8 +1241,7 @@ pr_class_start_method (p, name)
{
struct pr_handle *info = (struct pr_handle *) p;
- if (! push_type (info, ""))
- return false;
+ assert (info->stack != NULL);
info->stack->method = name;
return true;
}
@@ -1209,10 +1249,10 @@ pr_class_start_method (p, name)
/* Add a variant to a method. */
static boolean
-pr_class_method_variant (p, argtypes, visibility, constp, volatilep, voffset,
+pr_class_method_variant (p, physname, visibility, constp, volatilep, voffset,
context)
PTR p;
- const char *argtypes;
+ const char *physname;
enum debug_visibility visibility;
boolean constp;
boolean volatilep;
@@ -1229,12 +1269,12 @@ pr_class_method_variant (p, argtypes, visibility, constp, volatilep, voffset,
/* Put the const and volatile qualifiers on the type. */
if (volatilep)
{
- if (! prepend_type (info, "volatile "))
+ if (! append_type (info, " volatile"))
return false;
}
if (constp)
{
- if (! prepend_type (info, "const "))
+ if (! append_type (info, " const"))
return false;
}
@@ -1260,15 +1300,15 @@ pr_class_method_variant (p, argtypes, visibility, constp, volatilep, voffset,
return false;
}
- /* Now the top of the stack is the holder for the method, and the
- second element on the stack is the class. */
+ /* Now the top of the stack is the class. */
if (! pr_fix_visibility (info, visibility))
return false;
if (! append_type (info, method_type)
|| ! append_type (info, " /* ")
- || ! append_type (info, argtypes))
+ || ! append_type (info, physname)
+ || ! append_type (info, " "))
return false;
if (context || voffset != 0)
{
@@ -1294,9 +1334,9 @@ pr_class_method_variant (p, argtypes, visibility, constp, volatilep, voffset,
/* Add a static variant to a method. */
static boolean
-pr_class_static_method_variant (p, argtypes, visibility, constp, volatilep)
+pr_class_static_method_variant (p, physname, visibility, constp, volatilep)
PTR p;
- const char *argtypes;
+ const char *physname;
enum debug_visibility visibility;
boolean constp;
boolean volatilep;
@@ -1311,12 +1351,12 @@ pr_class_static_method_variant (p, argtypes, visibility, constp, volatilep)
/* Put the const and volatile qualifiers on the type. */
if (volatilep)
{
- if (! prepend_type (info, "volatile "))
+ if (! append_type (info, " volatile"))
return false;
}
if (constp)
{
- if (! prepend_type (info, "const "))
+ if (! append_type (info, " const"))
return false;
}
@@ -1333,15 +1373,14 @@ pr_class_static_method_variant (p, argtypes, visibility, constp, volatilep)
if (method_type == NULL)
return false;
- /* Now the top of the stack is the holder for the method, and the
- second element on the stack is the class. */
+ /* Now the top of the stack is the class. */
if (! pr_fix_visibility (info, visibility))
return false;
return (append_type (info, method_type)
&& append_type (info, " /* ")
- && append_type (info, argtypes)
+ && append_type (info, physname)
&& append_type (info, " */;\n")
&& indent_type (info));
}
@@ -1354,11 +1393,8 @@ pr_class_end_method (p)
{
struct pr_handle *info = (struct pr_handle *) p;
- /* The method variants have been appended to the string on top of
- the stack with the correct indentation. We just need the append
- the string on top of the stack to the class string that is second
- on the stack. */
- return append_type (info, pop_type (info));
+ info->stack->method = NULL;
+ return true;
}
/* Finish up a class. */
@@ -1385,13 +1421,15 @@ pr_typedef_type (p, name)
/* Push a type on the stack using a tag name. */
static boolean
-pr_tag_type (p, name, kind)
+pr_tag_type (p, name, id, kind)
PTR p;
const char *name;
+ unsigned int id;
enum debug_type_kind kind;
{
struct pr_handle *info = (struct pr_handle *) p;
- const char *t;
+ const char *t, *tag;
+ char idbuf[20];
switch (kind)
{
@@ -1415,8 +1453,17 @@ pr_tag_type (p, name, kind)
return false;
}
- return (push_type (info, t)
- && append_type (info, name));
+ if (! push_type (info, t))
+ return false;
+ if (name != NULL)
+ tag = name;
+ else
+ {
+ sprintf (idbuf, "%%anon%u", id);
+ tag = idbuf;
+ }
+
+ return append_type (info, tag);
}
/* Output a typedef. */