aboutsummaryrefslogtreecommitdiff
path: root/binutils/debug.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1996-01-11 16:47:10 +0000
committerIan Lance Taylor <ian@airs.com>1996-01-11 16:47:10 +0000
commit36302909f2b0b51c792b8c775ac53c6d404f7d25 (patch)
tree072564bdccc3dd2764b1b1d50295fc7173fae00f /binutils/debug.c
parent761f377fecdc962ad40882e3a65df6cb12906af6 (diff)
downloadbinutils-36302909f2b0b51c792b8c775ac53c6d404f7d25.zip
binutils-36302909f2b0b51c792b8c775ac53c6d404f7d25.tar.gz
binutils-36302909f2b0b51c792b8c775ac53c6d404f7d25.tar.bz2
* debug.c (debug_make_undefined_tagged_type): Make sure we are
given a kind of type we can handle. (debug_write_type): Handle undefined enums and structs. (debug_write_class_type): Handle undefined classes. * prdbg.c (pr_enum_type): Handle an undefined enum. Also comment changes to debug.h.
Diffstat (limited to 'binutils/debug.c')
-rw-r--r--binutils/debug.c201
1 files changed, 116 insertions, 85 deletions
diff --git a/binutils/debug.c b/binutils/debug.c
index 239abdb..02a80ae 100644
--- a/binutils/debug.c
+++ b/binutils/debug.c
@@ -1706,6 +1706,20 @@ debug_make_undefined_tagged_type (handle, name, kind)
if (name == NULL)
return DEBUG_TYPE_NULL;
+ switch (kind)
+ {
+ case DEBUG_KIND_STRUCT:
+ case DEBUG_KIND_UNION:
+ case DEBUG_KIND_CLASS:
+ case DEBUG_KIND_UNION_CLASS:
+ case DEBUG_KIND_ENUM:
+ break;
+
+ default:
+ debug_error ("debug_make_undefined_type: unsupported kind");
+ return DEBUG_TYPE_NULL;
+ }
+
t = debug_make_type (info, kind, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
@@ -2250,19 +2264,24 @@ debug_write_type (info, fns, fhandle, type, name)
return (*fns->bool_type) (fhandle, type->size);
case DEBUG_KIND_STRUCT:
case DEBUG_KIND_UNION:
- if (info->class_mark == type->u.kclass->mark)
+ if (type->u.kclass != NULL)
{
- /* We are currently outputting this struct. I don't know if
- this can happen, but it can happen for a class. */
- return (*fns->tag_type) (fhandle, "?defining?", type->kind);
+ if (info->class_mark == type->u.kclass->mark)
+ {
+ /* We are currently outputting this struct. I don't
+ know if this can happen, but it can happen for a
+ class. */
+ return (*fns->tag_type) (fhandle, "?defining?", type->kind);
+ }
+ type->u.kclass->mark = info->class_mark;
}
- type->u.kclass->mark = info->class_mark;
if (! (*fns->start_struct_type) (fhandle, tag,
type->kind == DEBUG_KIND_STRUCT,
type->size))
return false;
- if (type->u.kclass->fields != NULL)
+ if (type->u.kclass != NULL
+ && type->u.kclass->fields != NULL)
{
for (i = 0; type->u.kclass->fields[i] != NULL; i++)
{
@@ -2281,6 +2300,9 @@ debug_write_type (info, fns, fhandle, type, name)
case DEBUG_KIND_UNION_CLASS:
return debug_write_class_type (info, fns, fhandle, type, tag);
case DEBUG_KIND_ENUM:
+ if (type->u.kenum == NULL)
+ return (*fns->enum_type) (fhandle, tag, (const char **) NULL,
+ (bfd_signed_vma *) NULL);
return (*fns->enum_type) (fhandle, tag, type->u.kenum->names,
type->u.kenum->values);
case DEBUG_KIND_POINTER:
@@ -2389,20 +2411,24 @@ debug_write_class_type (info, fns, fhandle, type, tag)
{
unsigned int i;
- if (info->class_mark == type->u.kclass->mark)
+ if (type->u.kclass != NULL)
{
- /* We are currently outputting this class. This can happen when
- there are methods for an anonymous class. */
- return (*fns->tag_type) (fhandle, "?defining?", type->kind);
- }
- type->u.kclass->mark = info->class_mark;
+ if (info->class_mark == type->u.kclass->mark)
+ {
+ /* We are currently outputting this class. This can happen
+ when there are methods for an anonymous class. */
+ return (*fns->tag_type) (fhandle, "?defining?", type->kind);
+ }
+ type->u.kclass->mark = info->class_mark;
- if (type->u.kclass->vptrbase != NULL
- && type->u.kclass->vptrbase != type)
- {
- if (! debug_write_type (info, fns, fhandle, type->u.kclass->vptrbase,
- (struct debug_name *) NULL))
- return false;
+ if (type->u.kclass->vptrbase != NULL
+ && type->u.kclass->vptrbase != type)
+ {
+ if (! debug_write_type (info, fns, fhandle,
+ type->u.kclass->vptrbase,
+ (struct debug_name *) NULL))
+ return false;
+ }
}
if (! (*fns->start_class_type) (fhandle, tag,
@@ -2411,93 +2437,98 @@ debug_write_class_type (info, fns, fhandle, type, tag)
type->u.kclass->vptrbase != NULL,
type->u.kclass->vptrbase == type))
return false;
- if (type->u.kclass->fields != NULL)
+
+ if (type->u.kclass != NULL)
{
- for (i = 0; type->u.kclass->fields[i] != NULL; i++)
+ if (type->u.kclass->fields != NULL)
{
- struct debug_field *f;
-
- f = type->u.kclass->fields[i];
- if (! debug_write_type (info, fns, fhandle, f->type,
- (struct debug_name *) NULL))
- return false;
- if (f->static_member)
- {
- if (! (*fns->class_static_member) (fhandle, f->name,
- f->u.s.physname,
- f->visibility))
- return false;
- }
- else
+ for (i = 0; type->u.kclass->fields[i] != NULL; i++)
{
- if (! (*fns->struct_field) (fhandle, f->name, f->u.f.bitpos,
- f->u.f.bitsize, f->visibility))
+ struct debug_field *f;
+
+ f = type->u.kclass->fields[i];
+ if (! debug_write_type (info, fns, fhandle, f->type,
+ (struct debug_name *) NULL))
return false;
+ if (f->static_member)
+ {
+ if (! (*fns->class_static_member) (fhandle, f->name,
+ f->u.s.physname,
+ f->visibility))
+ return false;
+ }
+ else
+ {
+ if (! (*fns->struct_field) (fhandle, f->name, f->u.f.bitpos,
+ f->u.f.bitsize, f->visibility))
+ return false;
+ }
}
}
- }
- if (type->u.kclass->baseclasses != NULL)
- {
- for (i = 0; type->u.kclass->baseclasses[i] != NULL; i++)
+ if (type->u.kclass->baseclasses != NULL)
{
- struct debug_baseclass *b;
+ for (i = 0; type->u.kclass->baseclasses[i] != NULL; i++)
+ {
+ struct debug_baseclass *b;
- b = type->u.kclass->baseclasses[i];
- if (! debug_write_type (info, fns, fhandle, b->type,
- (struct debug_name *) NULL))
- return false;
- if (! (*fns->class_baseclass) (fhandle, b->bitpos, b->virtual,
- b->visibility))
- return false;
+ b = type->u.kclass->baseclasses[i];
+ if (! debug_write_type (info, fns, fhandle, b->type,
+ (struct debug_name *) NULL))
+ return false;
+ if (! (*fns->class_baseclass) (fhandle, b->bitpos, b->virtual,
+ b->visibility))
+ return false;
+ }
}
- }
- if (type->u.kclass->methods != NULL)
- {
- for (i = 0; type->u.kclass->methods[i] != NULL; i++)
+ if (type->u.kclass->methods != NULL)
{
- struct debug_method *m;
- unsigned int j;
-
- m = type->u.kclass->methods[i];
- if (! (*fns->class_start_method) (fhandle, m->name))
- return false;
- for (j = 0; m->variants[j] != NULL; j++)
+ for (i = 0; type->u.kclass->methods[i] != NULL; i++)
{
- struct debug_method_variant *v;
+ struct debug_method *m;
+ unsigned int j;
- v = m->variants[j];
- if (v->context != NULL)
+ m = type->u.kclass->methods[i];
+ if (! (*fns->class_start_method) (fhandle, m->name))
+ return false;
+ for (j = 0; m->variants[j] != NULL; j++)
{
- if (! debug_write_type (info, fns, fhandle, v->context,
+ struct debug_method_variant *v;
+
+ v = m->variants[j];
+ if (v->context != NULL)
+ {
+ if (! debug_write_type (info, fns, fhandle, v->context,
+ (struct debug_name *) NULL))
+ return false;
+ }
+ if (! debug_write_type (info, fns, fhandle, v->type,
(struct debug_name *) NULL))
return false;
+ if (v->voffset != VOFFSET_STATIC_METHOD)
+ {
+ if (! (*fns->class_method_variant) (fhandle, v->argtypes,
+ v->visibility,
+ v->constp,
+ v->volatilep,
+ v->voffset,
+ v->context != NULL))
+ return false;
+ }
+ else
+ {
+ if (! (*fns->class_static_method_variant) (fhandle,
+ v->argtypes,
+ v->visibility,
+ v->constp,
+ v->volatilep))
+ return false;
+ }
}
- if (! debug_write_type (info, fns, fhandle, v->type,
- (struct debug_name *) NULL))
+ if (! (*fns->class_end_method) (fhandle))
return false;
- if (v->voffset != VOFFSET_STATIC_METHOD)
- {
- if (! (*fns->class_method_variant) (fhandle, v->argtypes,
- v->visibility,
- v->constp, v->volatilep,
- v->voffset,
- v->context != NULL))
- return false;
- }
- else
- {
- if (! (*fns->class_static_method_variant) (fhandle,
- v->argtypes,
- v->visibility,
- v->constp,
- v->volatilep))
- return false;
- }
}
- if (! (*fns->class_end_method) (fhandle))
- return false;
}
}