diff options
author | Jim Blandy <jimb@codesourcery.com> | 2002-05-04 00:21:09 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2002-05-04 00:21:09 +0000 |
commit | 0caeef358c41354b32d7734be1955dfa237fd556 (patch) | |
tree | 03d6c5f5fd4c77877f2007a868e2d3d6ea872f2c | |
parent | d67a51785c119fb5f35b5a36ad6f5b5006a929c8 (diff) | |
download | gdb-0caeef358c41354b32d7734be1955dfa237fd556.tar.gz |
* stabsread.c (cleanup_undefined_types): Use replace_type, not memcpy.
(read_type): Doc fix.
* gdbtypes.c (replace_type): Doc fix.
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 8 | ||||
-rw-r--r-- | gdb/stabsread.c | 24 |
3 files changed, 27 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4e8de26967d..d7582011ab5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2002-05-03 Jim Blandy <jimb@redhat.com> + * stabsread.c (cleanup_undefined_types): Use replace_type, not memcpy. + (read_type): Doc fix. + * gdbtypes.c (replace_type): Doc fix. + * stabsread.c (multiply_defined_struct): New complaint. (read_struct_type): If the type we were passed isn't empty, or incomplete, don't read the new struct type into it; complain, diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index fa01f36c50d..9132c40b5fe 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -521,10 +521,10 @@ finish_cv_type (struct type *type) /* Replace the contents of ntype with the type *type. - This function should not be necessary, but is due to quirks in the stabs - reader. This should go away. It does not handle the replacement type - being cv-qualified; it could be easily fixed to, but it should go away, - remember? */ + When building recursive types, it is necessary to update a type's + definition after people already have references to it. The C + language's concept of an `incomplete type' is an acknowledgement of + this. */ void replace_type (struct type *ntype, struct type *type) { diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 74a873eb261..7065b7bbd1a 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2537,7 +2537,24 @@ again: the related problems with unnecessarily stubbed types; someone motivated should attempt to clean up the issue here as well. Once a type pointed to has been created it - should not be modified. */ + should not be modified. + + Well, it's not *absolutely* wrong. Constructing recursive + types (trees, linked lists) necessarily entails modifying + types after creating them. Constructing any loop structure + entails side effects. The Dwarf 2 reader does handle this + more gracefully (it never constructs more than once + instance of a type object, so it doesn't have to copy type + objects wholesale), but it still mutates type objects after + other folks have references to them. + + Keep in mind that this circularity/mutation issue shows up + at the source language level, too: C's "incomplete types", + for example. So the proper cleanup, I think, would be to + limit GDB's type smashing to match exactly those required + by the source language. So GDB could have a + "complete_this_type" function, but never create unnecessary + copies of a type otherwise. */ replace_type (type, xtype); TYPE_NAME (type) = NULL; TYPE_TAG_NAME (type) = NULL; @@ -5122,10 +5139,7 @@ cleanup_undefined_types (void) && (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE (*type)) && STREQ (SYMBOL_NAME (sym), typename)) - { - memcpy (*type, SYMBOL_TYPE (sym), - sizeof (struct type)); - } + replace_type (*type, SYMBOL_TYPE (sym)); } } } |