This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[type-refcount] Why it is right now not ready for FSF GDB


[ came from an off-list discussion about archer-jankratochvil-type-refcount
which came as part of archer-tromey-python ]

On Wed, 28 Jan 2009 18:05:46 +0100, Tom Tromey wrote:
> Jan> It is currently not ready for the post upstream.
[...]
> What does it still need?
> I'm wondering if I can help somehow.

I did face a problem that currently TYPE_OBJFILE (type) == NULL means either
it is an internal type (which must not be freed) or a type created by
copy_type_recursive (which must be garbage-collected).  It is always true that
TYPE_OBJFILE (type) != NULL means a type is allocated in objfile's obstack.

It is misused at least by - and somehow fixed in the VLA branch:
read_tag_string_type():
   index_type = builtin_type_int32;
-  range_type = create_range_type (NULL, index_type, 1, length);
+  /* RANGE_TYPE is allocated from OBJFILE, not OBJFILE_INTERNAL.  */
+  range_type = alloc_type (objfile, index_type);
+  range_type = create_range_type (range_type, index_type, 1, length);
   type = create_string_type (NULL, range_type);

After `type' gets copy_type_recursive()d it gets NULL TYPE_OBJFILE while it is
malloced but its referenced `index_type' was not duplicated as it already had
NULL TYPE_OBJFILE but in fact it is still the original internal type storage.


I see there three solutions:
(a) Any references to internal types should make a copy (copy_type_recursive)
    of it first.
    [ ineffective but a minimal patchset ]
(b) Create special OBJFILE_INTERNAL for internal types to differentiate them.
    Assume NULL to mean OBJFILE_MALLOC to be most compatible.
    Currently used by type-refcount.
    [ effective, acceptable patch size, a bit hacky assumption ]
(c) Like (b) but disallow any NULL TYPE_OBJFILE and properly use
    OBJFILE_MALLOC everywhere currently NULL is assumed.
    [ effective, correct, it may be a large patchset not well maintainable
    separately ]

+/* Virtual OBJFILE used for builtin types.  */
+#define OBJFILE_INTERNAL ((struct objfile *) 1L)
+
+/* Virtual OBJFILE used for types allocated by malloc.  FIXME: Currently
+   backward compatible with the old NULL value; fix then also init_type.  */
+#define OBJFILE_MALLOC ((struct objfile *) 0L)



Regards,
Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]