]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/python: preserve identity for gdb.Type objects
authorJan Vrany <jan.vrany@labware.com>
Wed, 19 Mar 2025 21:12:53 +0000 (21:12 +0000)
committerJan Vrany <jan.vrany@labware.com>
Wed, 19 Mar 2025 21:12:53 +0000 (21:12 +0000)
commit974c8ea576353d58fc024898dbc349da3c13984b
tree9a6aceac2c0d8892169c2b989eb93c66b53a4010
parentaaefa9023e6c7835c37ad62a4542b7171651479e
gdb/python: preserve identity for gdb.Type objects

This commit changes type_to_type_object() so that each it is called
with a particular struct type * it returns the very same gdb.Type
object.

This is done in the same way as for gdb.Symtab objects in earlier commit
("gdb/python: preserve identity for gdb.Symtab objects") except that
types may be either objfile-owned or arch-owned.

Prior this commit, arch-owned objects we not put into any list (like
objfile-owned ones) so they could not be easily looked up. This commit
changes the code so arch-owned list are put into per-architecture list
which is then used (solely) for looking up arch-owned gdb.Type.

Another complication comes from the fact that when objfile is about to
be freed, associated gdb.Type instances are not merely invalidated
(like it is done with gdb.Symtab or gdb.Symbol objects) but instead the
type is copied and the copy is arch-owned. So we need two different
"deleters", one for objfile-owned types that copies the type (as before)
and then insert the object to per-architecture list and another one
for arch-owned types.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/python/py-type.c
gdb/testsuite/gdb.python/py-arch.exp
gdb/testsuite/gdb.python/py-type.exp