diff options
author | Fred Fish <fnf@specifix.com> | 1991-12-06 16:37:20 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1991-12-06 16:37:20 +0000 |
commit | 5edf98d7a24eda531ae622ee1b3f9365c2121be2 (patch) | |
tree | 97f5adbc596b210954c0f03c3de0393baa5b51e7 /gdb/dwarfread.c | |
parent | 7b2a87cab2884bec54b51082e409c46f3d94d912 (diff) | |
download | gdb-5edf98d7a24eda531ae622ee1b3f9365c2121be2.zip gdb-5edf98d7a24eda531ae622ee1b3f9365c2121be2.tar.gz gdb-5edf98d7a24eda531ae622ee1b3f9365c2121be2.tar.bz2 |
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...)
Diffstat (limited to 'gdb/dwarfread.c')
-rw-r--r-- | gdb/dwarfread.c | 36 |
1 files changed, 24 insertions, 12 deletions
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); } |