This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[type-refcount] Why it is right now not ready for FSF GDB
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Rick Moseley <rmoseley at redhat dot com>, archer at sourceware dot org
- Date: Wed, 28 Jan 2009 18:26:33 +0100
- Subject: [type-refcount] Why it is right now not ready for FSF GDB
- References: <20090116163859.GA26521@host0.dyn.jankratochvil.net> <497F79BA.5010007@redhat.com> <20090127212754.GA28314@host0.dyn.jankratochvil.net> <497F8052.9030409@redhat.com> <20090127215932.GA10602@host0.dyn.jankratochvil.net> <m363k01k66.fsf@fleche.redhat.com> <20090127221023.GA13685@host0.dyn.jankratochvil.net> <m3bptrz7h1.fsf@fleche.redhat.com>
[ 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