From 84ce6717b0c2f599ad27436302ea027e78c99745 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Fri, 6 Dec 1991 19:51:01 +0000 Subject: [PATCH] More fixes for opaque and anonymous enumerations, structures, and unions. Now passes all current gdb test suite tests. --- gdb/ChangeLog | 7 +++---- gdb/dwarfread.c | 54 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3ec4edcced1..34c2e95bcf4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,9 +1,8 @@ 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) + * dwarfread.c (enum_type, struct_type): Fixes for opaque and + anonymous enumerations, structures, and unions. Now passes all + the current gdb test suite tests. Thu Dec 5 21:53:21 1991 John Gilmore (gnu at cygnus.com) diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 6333c6c52cc..ab5b27f8454 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -1020,8 +1020,17 @@ DESCRIPTION NOTES Note that we need to call struct_type regardless of whether or not - we have a symbol, since we might have a structure or union without - a tag name (thus no symbol for the tagname). + the DIE has an at_name attribute, since it might be an anonymous + structure or union. This gets the type entered into our set of + user defined types. + + However, if the structure is incomplete (an opaque struct/union) + then suppress creating a symbol table entry for it since gdb only + wants to find the one with the complete definition. Note that if + it is complete, we just call new_symbol, which does it's own + checking about whether the struct/union is anonymous or not (and + suppresses creating a symbol table entry itself). + */ static void @@ -1035,9 +1044,12 @@ DEFUN(read_structure_scope, (dip, thisdie, enddie, objfile), struct symbol *sym; type = struct_type (dip, thisdie, enddie, objfile); - if ((sym = new_symbol (dip)) != NULL) + if (!(TYPE_FLAGS (type) & TYPE_FLAG_STUB)) { - SYMBOL_TYPE (sym) = type; + if ((sym = new_symbol (dip)) != NULL) + { + SYMBOL_TYPE (sym) = type; + } } } @@ -1368,12 +1380,13 @@ DEFUN(enum_type, (dip), struct dieinfo *dip) 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_CODE (type) = TYPE_CODE_ENUM; - /* 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 != '.') @@ -1421,18 +1434,23 @@ DEFUN(enum_type, (dip), struct dieinfo *dip) SYMBOL_VALUE (sym) = list -> field.bitpos; add_symbol_to_list (sym, &scope -> symbols); } + /* Now create the vector of fields, and record how big it is. This is + where we reverse the order, by pulling the members of the list in + reverse order from how they were inserted. If we have no fields + (this is apparently possible in C++) then skip building a field + vector. */ + if (nfields > 0) + { + 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 = 0; (n < nfields) && (list != NULL); list = list -> next) + { + TYPE_FIELD (type, n++) = list -> field; + } + } } - /* Now create the vector of fields, and record how big it is. This is where - we reverse the order, by pulling the members of the list in reverse order - from how they were inserted. */ - 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 = 0; (n < nfields) && (list != NULL); list = list -> next) - { - TYPE_FIELD (type, n++) = list -> field; - } return (type); } -- 2.30.2