unsigned int mark;
/* Another mark used by debug_write. */
unsigned int class_mark;
+ /* A struct/class ID used by debug_write. */
+ unsigned int class_id;
+ /* The base for class_id for this call to debug_write. */
+ unsigned int base_id;
};
/* Information we keep for a single compilation unit. */
debug_field *fields;
/* A mark field used to avoid recursively printing out structs. */
unsigned int mark;
+ /* This is used to uniquely identify unnamed structs when printing. */
+ unsigned int id;
/* The remaining fields are only used for DEBUG_KIND_CLASS and
DEBUG_KIND_UNION_CLASS. */
/* NULL terminated array of base classes. */
struct debug_method_variant
{
- /* The argument types of the function. */
- const char *argtypes;
+ /* The physical name of the function. */
+ const char *physname;
/* The type of the function. */
struct debug_type *type;
/* The visibility of the function. */
} u;
};
+/* This variable is an ellipsis type. The contents are not used; its
+ address is returned by debug_make_ellipsis_type, and anything which
+ needs to know whether it is dealing with an ellipsis compares
+ addresses. */
+
+static const struct debug_type debug_ellipsis_type;
+
+#define ELLIPSIS_P(t) ((t) == &debug_ellipsis_type)
+
+/* Local functions. */
+
static void debug_error PARAMS ((const char *));
static struct debug_name *debug_add_to_namespace
PARAMS ((struct debug_handle *, struct debug_namespace **, const char *,
enum debug_object_linkage));
static struct debug_type *debug_make_type
PARAMS ((struct debug_handle *, enum debug_type_kind, unsigned int));
+static struct debug_type *debug_get_real_type PARAMS ((PTR, debug_type));
static boolean debug_write_name
PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
struct debug_name *));
return t;
}
+/* Make an ellipsis type. This is not a type at all, but is a marker
+ suitable for appearing in the list of argument types passed to
+ debug_make_method_type. It should be used to indicate a method
+ which takes a variable number of arguments. */
+
+debug_type
+debug_make_ellipsis_type (handle)
+ PTR handle;
+{
+ return (debug_type) &debug_ellipsis_type;
+}
+
/* Make a void type. There is only one of these. */
debug_type
/*ARGSUSED*/
debug_method_variant
-debug_make_method_variant (handle, argtypes, type, visibility, constp,
+debug_make_method_variant (handle, physname, type, visibility, constp,
volatilep, voffset, context)
PTR handle;
- const char *argtypes;
+ const char *physname;
debug_type type;
enum debug_visibility visibility;
boolean constp;
m = (struct debug_method_variant *) xmalloc (sizeof *m);
memset (m, 0, sizeof *m);
- m->argtypes = argtypes;
+ m->physname = physname;
m->type = type;
m->visibility = visibility;
m->constp = constp;
since a static method can not also be virtual. */
debug_method_variant
-debug_make_static_method_variant (handle, argtypes, type, visibility,
+debug_make_static_method_variant (handle, physname, type, visibility,
constp, volatilep)
PTR handle;
- const char *argtypes;
+ const char *physname;
debug_type type;
enum debug_visibility visibility;
boolean constp;
m = (struct debug_method_variant *) xmalloc (sizeof *m);
memset (m, 0, sizeof *m);
- m->argtypes = argtypes;
+ m->physname = physname;
m->type = type;
m->visibility = visibility;
m->constp = constp;
if (name == NULL || type == NULL)
return DEBUG_TYPE_NULL;
+ if (info->current_unit == NULL
+ || info->current_file == NULL)
+ {
+ debug_error ("debug_record_variable: no current file");
+ return false;
+ }
+
t = debug_make_type (info, DEBUG_KIND_NAMED, 0);
if (t == NULL)
return DEBUG_TYPE_NULL;
t->u.knamed = n;
- /* We also need to add the name to the current namespace. */
+ /* We always add the name to the global namespace. This is probably
+ wrong in some cases, but it seems to be right for stabs. FIXME. */
- nm = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_TYPE,
- DEBUG_LINKAGE_NONE);
+ nm = debug_add_to_namespace (info, &info->current_file->globals, name,
+ DEBUG_OBJECT_TYPE, DEBUG_LINKAGE_NONE);
if (nm == NULL)
return false;
return true;
}
+/* Find a named type. */
+
+debug_type
+debug_find_named_type (handle, name)
+ PTR handle;
+ const char *name;
+{
+ struct debug_handle *info = (struct debug_handle *) handle;
+ struct debug_block *b;
+ struct debug_file *f;
+
+ /* We only search the current compilation unit. I don't know if
+ this is right or not. */
+
+ if (info->current_unit == NULL)
+ {
+ debug_error ("debug_find_named_type: no current compilation unit");
+ return DEBUG_TYPE_NULL;
+ }
+
+ for (b = info->current_block; b != NULL; b = b->parent)
+ {
+ if (b->locals != NULL)
+ {
+ struct debug_name *n;
+
+ for (n = b->locals->list; n != NULL; n = n->next)
+ {
+ if (n->kind == DEBUG_OBJECT_TYPE
+ && n->name[0] == name[0]
+ && strcmp (n->name, name) == 0)
+ return n->u.type;
+ }
+ }
+ }
+
+ for (f = info->current_unit->files; f != NULL; f = f->next)
+ {
+ if (f->globals != NULL)
+ {
+ struct debug_name *n;
+
+ for (n = f->globals->list; n != NULL; n = n->next)
+ {
+ if (n->kind == DEBUG_OBJECT_TYPE
+ && n->name[0] == name[0]
+ && strcmp (n->name, name) == 0)
+ return n->u.type;
+ }
+ }
+ }
+
+ return DEBUG_TYPE_NULL;
+}
+
/* Find a tagged type. */
debug_type
for (n = f->globals->list; n != NULL; n = n->next)
{
if (n->kind == DEBUG_OBJECT_TAG
- && (kind == DEBUG_KIND_VOID
+ && (kind == DEBUG_KIND_ILLEGAL
|| n->u.tag->kind == kind)
&& n->name[0] == name[0]
&& strcmp (n->name, name) == 0)
return DEBUG_TYPE_NULL;
}
+/* Get a base type. */
+
+static struct debug_type *
+debug_get_real_type (handle, type)
+ PTR handle;
+ debug_type type;
+{
+ switch (type->kind)
+ {
+ default:
+ return type;
+ case DEBUG_KIND_INDIRECT:
+ if (*type->u.kindirect->slot != NULL)
+ return debug_get_real_type (handle, *type->u.kindirect->slot);
+ return type;
+ case DEBUG_KIND_NAMED:
+ return debug_get_real_type (handle, type->u.knamed->type);
+ }
+ /*NOTREACHED*/
+}
+
+/* Get the kind of a type. */
+
+enum debug_type_kind
+debug_get_type_kind (handle, type)
+ PTR handle;
+ debug_type type;
+{
+ if (type == NULL)
+ return DEBUG_KIND_ILLEGAL;
+ type = debug_get_real_type (handle, type);
+ return type->kind;
+}
+
/* Get the name of a type. */
-/*ARGSUSED*/
const char *
debug_get_type_name (handle, type)
PTR handle;
return type->u.knamed->name->name;
return NULL;
}
+
+/* Get the return type of a function or method type. */
+
+debug_type
+debug_get_return_type (handle, type)
+ PTR handle;
+ debug_type type;
+{
+ if (type == NULL)
+ return DEBUG_TYPE_NULL;
+ type = debug_get_real_type (handle, type);
+ switch (type->kind)
+ {
+ default:
+ return DEBUG_TYPE_NULL;
+ case DEBUG_KIND_FUNCTION:
+ return type->u.kfunction->return_type;
+ case DEBUG_KIND_METHOD:
+ return type->u.kmethod->return_type;
+ }
+ /*NOTREACHED*/
+}
+
+/* Get the parameter types of a function or method type (except that
+ we don't currently store the parameter types of a function). */
+
+const debug_type *
+debug_get_parameter_types (handle, type)
+ PTR handle;
+ debug_type type;
+{
+ if (type == NULL)
+ return NULL;
+ type = debug_get_real_type (handle, type);
+ switch (type->kind)
+ {
+ default:
+ return NULL;
+ case DEBUG_KIND_METHOD:
+ return type->u.kmethod->arg_types;
+ }
+ /*NOTREACHED*/
+}
+
+/* Get the NULL terminated array of fields for a struct, union, or
+ class. */
+
+const debug_field *
+debug_get_fields (handle, type)
+ PTR handle;
+ debug_type type;
+{
+ if (type == NULL)
+ return NULL;
+ type = debug_get_real_type (handle, type);
+ switch (type->kind)
+ {
+ default:
+ return NULL;
+ case DEBUG_KIND_STRUCT:
+ case DEBUG_KIND_UNION:
+ case DEBUG_KIND_CLASS:
+ case DEBUG_KIND_UNION_CLASS:
+ return type->u.kclass->fields;
+ }
+ /*NOTREACHED*/
+}
+
+/* Get the type of a field. */
+
+/*ARGSUSED*/
+debug_type
+debug_get_field_type (handle, field)
+ PTR handle;
+ debug_field field;
+{
+ if (field == NULL)
+ return NULL;
+ return field->type;
+}
\f
/* Write out the debugging information. This is given a handle to
debugging information, and a set of function pointers to call. */
information more than once. */
++info->mark;
+ /* The base_id field holds an ID value which will never be used, so
+ that we can tell whether we have assigned an ID during this call
+ to debug_write. */
+ info->base_id = info->class_id;
+
for (u = info->units; u != NULL; u = u->next)
{
struct debug_file *f;
if (type->kind == DEBUG_KIND_NAMED)
return (*fns->typedef_type) (fhandle, type->u.knamed->name->name);
else
- return (*fns->tag_type) (fhandle, type->u.knamed->name->name,
+ return (*fns->tag_type) (fhandle, type->u.knamed->name->name, 0,
type->u.knamed->type->kind);
}
switch (type->kind)
{
+ case DEBUG_KIND_ILLEGAL:
+ debug_error ("debug_write_type: illegal type encountered");
+ return false;
case DEBUG_KIND_INDIRECT:
if (*type->u.kindirect->slot == DEBUG_TYPE_NULL)
return (*fns->empty_type) (fhandle);
case DEBUG_KIND_UNION:
if (type->u.kclass != NULL)
{
- if (info->class_mark == type->u.kclass->mark)
+ if (info->class_mark == type->u.kclass->mark
+ || type->u.kclass->id > info->base_id)
{
- /* 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);
+ /* We are currently outputting this struct, or we have
+ already output it. I don't know if this can happen,
+ but it can happen for a class. */
+ assert (type->u.kclass->id > info->base_id);
+ return (*fns->tag_type) (fhandle, tag, type->u.kclass->id,
+ type->kind);
}
type->u.kclass->mark = info->class_mark;
+ ++info->class_id;
+ type->u.kclass->id = info->class_id;
}
if (! (*fns->start_struct_type) (fhandle, tag,
+ (type->u.kclass != NULL
+ ? type->u.kclass->id
+ : 0),
type->kind == DEBUG_KIND_STRUCT,
type->size))
return false;
{
for (i = 0; type->u.kmethod->arg_types[i] != NULL; i++)
{
- if (! debug_write_type (info, fns, fhandle,
- type->u.kmethod->arg_types[i],
- (struct debug_name *) NULL))
- return false;
+ if (ELLIPSIS_P (type->u.kmethod->arg_types[i]))
+ {
+ if (! (*fns->ellipsis_type) (fhandle))
+ return false;
+ }
+ else
+ {
+ if (! debug_write_type (info, fns, fhandle,
+ type->u.kmethod->arg_types[i],
+ (struct debug_name *) NULL))
+ return false;
+ }
}
}
if (type->u.kmethod->domain_type != NULL)
const char *tag;
{
unsigned int i;
+ unsigned int id;
+ struct debug_type *vptrbase;
- if (type->u.kclass != NULL)
+ if (type->u.kclass == NULL)
{
- if (info->class_mark == type->u.kclass->mark)
+ id = 0;
+ vptrbase = NULL;
+ }
+ else
+ {
+ if (info->class_mark == type->u.kclass->mark
+ || type->u.kclass->id > info->base_id)
{
- /* 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);
+ /* We are currently outputting this class, or we have
+ already output it. This can happen when there are
+ methods for an anonymous class. */
+ assert (type->u.kclass->id > info->base_id);
+ return (*fns->tag_type) (fhandle, tag, type->u.kclass->id,
+ type->kind);
}
type->u.kclass->mark = info->class_mark;
+ ++info->class_id;
+ id = info->class_id;
+ type->u.kclass->id = id;
- if (type->u.kclass->vptrbase != NULL
- && type->u.kclass->vptrbase != type)
+ vptrbase = type->u.kclass->vptrbase;
+ if (vptrbase != NULL && vptrbase != type)
{
- if (! debug_write_type (info, fns, fhandle,
- type->u.kclass->vptrbase,
+ if (! debug_write_type (info, fns, fhandle, vptrbase,
(struct debug_name *) NULL))
return false;
}
}
- if (! (*fns->start_class_type) (fhandle, tag,
+ if (! (*fns->start_class_type) (fhandle, tag, id,
type->kind == DEBUG_KIND_CLASS,
type->size,
- type->u.kclass->vptrbase != NULL,
- type->u.kclass->vptrbase == type))
+ vptrbase != NULL,
+ vptrbase == type))
return false;
if (type->u.kclass != NULL)
return false;
if (v->voffset != VOFFSET_STATIC_METHOD)
{
- if (! (*fns->class_method_variant) (fhandle, v->argtypes,
+ if (! (*fns->class_method_variant) (fhandle, v->physname,
v->visibility,
v->constp,
v->volatilep,
else
{
if (! (*fns->class_static_method_variant) (fhandle,
- v->argtypes,
+ v->physname,
v->visibility,
v->constp,
v->volatilep))
enum debug_type_kind
{
+ /* Not used. */
+ DEBUG_KIND_ILLEGAL,
/* Indirect via a pointer. */
DEBUG_KIND_INDIRECT,
/* Void. */
/* Each writer must keep a stack of types. */
+ /* Push an ellipsis type onto the type stack. This is not a real
+ type, but is used when a method takes a variable number of
+ arguments. */
+ boolean (*ellipsis_type) PARAMS ((PTR));
+
/* Push an empty type onto the type stack. This type can appear if
there is a reference to a type which is never defined. */
boolean (*empty_type) PARAMS ((PTR));
/* Start building a struct. This is followed by calls to the
struct_field function, and finished by a call to the
end_struct_type function. The second argument is the tag; this
- will be NULL if there isn't one. The boolean argument is true
- for a struct, false for a union. The unsigned int argument is
- the size. If this is an undefined struct or union, the size will
- be 0 and struct_field will not be called before end_struct_type
- is called. */
- boolean (*start_struct_type) PARAMS ((PTR, const char *, boolean,
- unsigned int));
+ will be NULL if there isn't one. If the second argument is NULL,
+ the third argument is a constant identifying this struct for use
+ with tag_type. The fourth argument is true for a struct, false
+ for a union. The fifth argument is the size. If this is an
+ undefined struct or union, the size will be 0 and struct_field
+ will not be called before end_struct_type is called. */
+ boolean (*start_struct_type) PARAMS ((PTR, const char *, unsigned int,
+ boolean, unsigned int));
/* Add a field to the struct type currently being built. The type
of the field should be popped off the type stack. The arguments
functions: struct_field, class_static_member, class_baseclass,
class_start_method, class_method_variant,
class_static_method_variant, and class_end_method. The class is
- finished by a call to end_class_type. The second argument is the
- tag; this will be NULL if there isn't one. The boolean argument
- is true for a struct, false for a union. The next argument is
- the size. The next argument is true if there is a virtual
- function table; if there is, the next argument is true if the
- virtual function table can be found in the type itself, and is
- false if the type of the object holding the virtual function
- table should be popped from the type stack. */
- boolean (*start_class_type) PARAMS ((PTR, const char *, boolean,
- unsigned int, boolean, boolean));
+ finished by a call to end_class_type. The first five arguments
+ are the same as for start_struct_type. The sixth argument is
+ true if there is a virtual function table; if there is, the
+ seventh argument is true if the virtual function table can be
+ found in the type itself, and is false if the type of the object
+ holding the virtual function table should be popped from the type
+ stack. */
+ boolean (*start_class_type) PARAMS ((PTR, const char *, unsigned int,
+ boolean, unsigned int, boolean,
+ boolean));
/* Add a static member to the class currently being built. The
arguments are the field name, the physical name, and the
/* Describe a variant to the class method currently being built.
The type of the variant must be popped off the type stack. The
- second argument is a string which is either the physical name of
- the function or describes the argument types; see the comment for
- debug_make_method variant. The following arguments are the
- visibility, whether the variant is const, whether the variant is
- volatile, the offset in the virtual function table, and whether
- the context is on the type stack (below the variant type). */
+ second argument is the physical name of the function. The
+ following arguments are the visibility, whether the variant is
+ const, whether the variant is volatile, the offset in the virtual
+ function table, and whether the context is on the type stack
+ (below the variant type). */
boolean (*class_method_variant) PARAMS ((PTR, const char *,
enum debug_visibility,
boolean, boolean,
call to typdef. */
boolean (*typedef_type) PARAMS ((PTR, const char *));
- /* Push a type on the stack which was given a name by an earlier
- call to tag. */
- boolean (*tag_type) PARAMS ((PTR, const char *, enum debug_type_kind));
+ /* Push a tagged type on the stack which was defined earlier. If
+ the second argument is not NULL, the type was defined by a call
+ to tag. If the second argument is NULL, the type was defined by
+ a call to start_struct_type or start_class_type with a tag of
+ NULL and the number of the third argument. Either way, the
+ fourth argument is the tag kind. Note that this may be called
+ for a struct (class) being defined, in between the call to
+ start_struct_type (start_class_type) and the call to
+ end_struct_type (end_class_type). */
+ boolean (*tag_type) PARAMS ((PTR, const char *, unsigned int,
+ enum debug_type_kind));
/* Pop the type stack, and typedef it to the given name. */
boolean (*typdef) PARAMS ((PTR, const char *));
extern debug_type debug_make_indirect_type
PARAMS ((PTR, debug_type *, const char *));
+/* Make an ellipsis type. This is not a type at all, but is a marker
+ suitable for appearing in the list of argument types passed to
+ debug_make_method_type. It should be used to indicate a method
+ which takes a variable number of arguments. */
+
+extern debug_type debug_make_ellipsis_type PARAMS ((PTR));
+
/* Make a void type. */
extern debug_type debug_make_void_type PARAMS ((PTR));
extern debug_method debug_make_method
PARAMS ((PTR, const char *, debug_method_variant *));
-/* Make a method variant. The second argument is either the physical
- name of the function, or the encoded argument types, depending upon
- whether the third argument specifies the argument types or not.
- The third argument is the type of the function. The fourth
+/* Make a method variant. The second argument is the physical name of
+ the function. The third argument is the type of the function,
+ probably constructed by debug_make_method_type. The fourth
argument is the visibility. The fifth argument is whether this is
a const function. The sixth argument is whether this is a volatile
function. The seventh argument is the offset in the virtual
extern boolean debug_record_type_size PARAMS ((PTR, debug_type, unsigned int));
+/* Find a named type. */
+
+extern debug_type debug_find_named_type PARAMS ((PTR, const char *));
+
/* Find a tagged type. */
extern debug_type debug_find_tagged_type
PARAMS ((PTR, const char *, enum debug_type_kind));
+/* Get the kind of a type. */
+
+extern enum debug_type_kind debug_get_type_kind PARAMS ((PTR, debug_type));
+
/* Get the name of a type. */
extern const char *debug_get_type_name PARAMS ((PTR, debug_type));
+/* Get the return type of a function or method type. */
+
+extern debug_type debug_get_return_type PARAMS ((PTR, debug_type));
+
+/* Get the NULL terminated array of parameter types for a function or
+ method type (actually, parameter types are not currently stored for
+ function types). This may be used to determine whether a method
+ type is a stub method or not. */
+
+extern const debug_type *debug_get_parameter_types PARAMS ((PTR, debug_type));
+
+/* Get the NULL terminated array of fields for a struct, union, or
+ class. */
+
+extern const debug_field *debug_get_fields PARAMS ((PTR, debug_type));
+
+/* Get the type of a field. */
+
+extern debug_type debug_get_field_type PARAMS ((PTR, debug_field));
+
/* Write out the recorded debugging information. This takes a set of
function pointers which are called to do the actual writing. The
first PTR is the debugging handle. The second PTR is a handle
/* Type. */
struct ieee_write_type type;
/* If this is a tag which has not yet been defined, this is the
- kind. If the tag has been defined, this is DEBUG_KIND_VOID. */
+ kind. If the tag has been defined, this is DEBUG_KIND_ILLEGAL. */
enum debug_type_kind kind;
};
static boolean ieee_start_compilation_unit PARAMS ((PTR, const char *));
static boolean ieee_start_source PARAMS ((PTR, const char *));
+static boolean ieee_ellipsis_type PARAMS ((PTR));
static boolean ieee_empty_type PARAMS ((PTR));
static boolean ieee_void_type PARAMS ((PTR));
static boolean ieee_int_type PARAMS ((PTR, unsigned int, boolean));
static boolean ieee_const_type PARAMS ((PTR));
static boolean ieee_volatile_type PARAMS ((PTR));
static boolean ieee_start_struct_type
- PARAMS ((PTR, const char *, boolean, unsigned int));
+ PARAMS ((PTR, const char *, unsigned int, boolean, unsigned int));
static boolean ieee_struct_field
PARAMS ((PTR, const char *, bfd_vma, bfd_vma, enum debug_visibility));
static boolean ieee_end_struct_type PARAMS ((PTR));
static boolean ieee_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 ieee_class_static_member
PARAMS ((PTR, const char *, const char *, enum debug_visibility));
static boolean ieee_class_baseclass
static boolean ieee_end_class_type PARAMS ((PTR));
static boolean ieee_typedef_type PARAMS ((PTR, const char *));
static boolean ieee_tag_type
- PARAMS ((PTR, const char *, enum debug_type_kind));
+ PARAMS ((PTR, const char *, unsigned int, enum debug_type_kind));
static boolean ieee_typdef PARAMS ((PTR, const char *));
static boolean ieee_tag PARAMS ((PTR, const char *));
static boolean ieee_int_constant PARAMS ((PTR, const char *, bfd_vma));
{
ieee_start_compilation_unit,
ieee_start_source,
+ ieee_ellipsis_type,
ieee_empty_type,
ieee_void_type,
ieee_int_type,
nt->type.size = size;
nt->type.unsignedp = unsignedp;
- nt->kind = DEBUG_KIND_VOID;
+ nt->kind = DEBUG_KIND_ILLEGAL;
type_indx = nt->type.indx;
}
unsigned int name_indx;
char code;
- if (nt->kind == DEBUG_KIND_VOID)
+ if (nt->kind == DEBUG_KIND_ILLEGAL)
continue;
if (tags == NULL)
{
return true;
}
+/* Make an ellipsis type. */
+
+static boolean
+ieee_ellipsis_type (p)
+ PTR p;
+{
+ abort ();
+}
+
/* Make an empty type. */
static boolean
fields with the struct type itself. */
static boolean
-ieee_start_struct_type (p, tag, structp, size)
+ieee_start_struct_type (p, tag, id, structp, size)
PTR p;
const char *tag;
+ unsigned int id;
boolean structp;
unsigned int size;
{
/* Start a class type. */
static boolean
-ieee_start_class_type (p, tag, structp, size, vptr, ownvptr)
+ieee_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;
/* FIXME. */
if (vptr && ! ownvptr)
(void) ieee_pop_type (info);
- return ieee_start_struct_type (p, tag, structp, size);
+ return ieee_start_struct_type (p, tag, id, structp, size);
}
/* Add a static member to a class. */
/* Define a new method variant. */
static boolean
-ieee_class_method_variant (p, name, visibility, constp, volatilep,
+ieee_class_method_variant (p, physname, visibility, constp, volatilep,
voffset, context)
PTR p;
- const char *name;
+ const char *physname;
enum debug_visibility visibility;
boolean constp;
boolean volatilep;
/* Define a new static method variant. */
static boolean
-ieee_class_static_method_variant (p, name, visibility, constp, volatilep)
+ieee_class_static_method_variant (p, physname, visibility, constp, volatilep)
PTR p;
- const char *name;
+ const char *physname;
enum debug_visibility visibility;
boolean constp;
boolean volatilep;
/* Push a tagged type onto the type stack. */
static boolean
-ieee_tag_type (p, name, kind)
+ieee_tag_type (p, name, id, kind)
PTR p;
const char *name;
+ unsigned int id;
enum debug_type_kind kind;
{
struct ieee_handle *info = (struct ieee_handle *) p;
register struct ieee_name_type *nt;
+ if (name == NULL)
+ return true;
+
for (nt = info->tags; nt != NULL; nt = nt->next)
{
if (nt->name[0] == name[0]
memset (nt, 0, sizeof *nt);
nt->name = name;
nt->type = info->type_stack->type;
- nt->kind = DEBUG_KIND_VOID;
+ nt->kind = DEBUG_KIND_ILLEGAL;
nt->next = info->typedefs;
info->typedefs = nt;
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));
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
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));
{
pr_start_compilation_unit,
pr_start_source,
+ pr_ellipsis_type,
pr_empty_type,
pr_void_type,
pr_int_type,
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
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, "*|");
}
/* 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;
{
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;
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)
{
}
/* 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);
info->stack->visibility = visibility;
- info->stack = top;
-
return true;
}
{
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;
|| ! 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. */
/* 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;
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)
{
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. */
{
struct pr_handle *info = (struct pr_handle *) p;
- if (! push_type (info, ""))
- return false;
+ assert (info->stack != NULL);
info->stack->method = name;
return true;
}
/* 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;
/* 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;
}
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)
{
/* 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;
/* 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;
}
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));
}
{
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. */
/* 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)
{
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. */