From 5edf98d7a24eda531ae622ee1b3f9365c2121be2 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Fri, 6 Dec 1991 16:37:20 +0000 Subject: [PATCH] Fixes to improve opaque struct/union handling. Still fails to find the complete definition for files outside the one containing the complete definition, if that file has not yet been read in. (Working on it...) --- gdb/ChangeLog | 7 +++++++ gdb/dwarfread.c | 36 ++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 977dbec..3ec4edc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +Fri Dec 6 08:30:36 1991 Fred Fish (fnf at cygnus.com) + + * dwarfread.c (struct_type): Fixes to improve opaque struct/union + handling. Does not solve all problems, since gdb still fails to + find the complete definition if the file containing the complete + definition has not yet been read in. (FIXME) + Thu Dec 5 21:53:21 1991 John Gilmore (gnu at cygnus.com) * symtab.c (decode_line_1): If SKIP_PROLOGUE leaves us in diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index ab66d6f..6333c6c 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -902,6 +902,7 @@ DEFUN(struct_type, (dip, thisdie, enddie, objfile), if ((type = lookup_utype (dip -> dieref)) == NULL) { + /* No forward references created an empty type, so install one now */ type = alloc_utype (dip -> dieref, NULL); } TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *) @@ -911,7 +912,7 @@ DEFUN(struct_type, (dip, thisdie, enddie, objfile), switch (dip -> dietag) { case TAG_structure_type: - TYPE_CODE (type) = TYPE_CODE_STRUCT; + TYPE_CODE (type) = TYPE_CODE_STRUCT; tpart1 = "struct"; break; case TAG_union_type: @@ -925,9 +926,9 @@ DEFUN(struct_type, (dip, thisdie, enddie, objfile), SQUAWK (("missing structure or union tag")); break; } - /* Some compilers try to be helpful by inventing "fake" names for anonymous - enums, structures, and unions, like "~0fake" or ".0fake". Thanks, but - no thanks... */ + /* Some compilers try to be helpful by inventing "fake" names for + anonymous enums, structures, and unions, like "~0fake" or ".0fake". + Thanks, but no thanks... */ if (dip -> at_name != NULL && *dip -> at_name != '~' && *dip -> at_name != '.') @@ -975,15 +976,26 @@ DEFUN(struct_type, (dip, thisdie, enddie, objfile), } thisdie = nextdie; } - /* Now create the vector of fields, and record how big it is. */ - TYPE_NFIELDS (type) = nfields; - TYPE_FIELDS (type) = (struct field *) - obstack_alloc (symbol_obstack, sizeof (struct field) * nfields); - /* Copy the saved-up fields into the field vector. */ - for (n = nfields; list; list = list -> next) + /* Now create the vector of fields, and record how big it is. We may + not even have any fields, if this DIE was generated due to a reference + to an anonymous structure or union. In this case, TYPE_FLAG_STUB is + set, which clues gdb in to the fact that it needs to search elsewhere + for the full structure definition. */ + if (nfields == 0) { - TYPE_FIELD (type, --n) = list -> field; - } + TYPE_FLAGS (type) |= TYPE_FLAG_STUB; + } + else + { + TYPE_NFIELDS (type) = nfields; + TYPE_FIELDS (type) = (struct field *) + obstack_alloc (symbol_obstack, sizeof (struct field) * nfields); + /* Copy the saved-up fields into the field vector. */ + for (n = nfields; list; list = list -> next) + { + TYPE_FIELD (type, --n) = list -> field; + } + } return (type); } -- 2.7.4