]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/python: Reuse gdb.RegisterGroup objects where possible
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 7 Jul 2020 14:26:42 +0000 (15:26 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 21 Jul 2020 20:57:08 +0000 (21:57 +0100)
commitbaf8791efb4b5cb41348b11ad9f63e6c2a004c5f
tree87b92e4e11919ae60839e352c79c4833b5f8a58c
parentf7306dac19c502232f766c3881313857915f330d
gdb/python: Reuse gdb.RegisterGroup objects where possible

Only create one gdb.RegisterGroup Python object for each of GDB's
reggroup objects.

I could have added a field into the reggroup object to hold the Python
object pointer for each reggroup, however, as reggroups are never
deleted within GDB, and are global (not per-architecture) a simpler
solution seemed to be just to hold a single global map from reggroup
pointer to a Python object representing the reggroup.  Then we can
reuse the objects out of this map.

After this commit it is possible for a user to tell that two
gdb.RegisterGroup objects are now identical when previously they were
unique, however, as both these objects are read-only I don't think
this should be a problem.

There should be no other user visible changes after this commit.

gdb/ChangeLog:

* python/py-registers.c : Add 'unordered_map' include.
(gdbpy_new_reggroup): Renamed to...
(gdbpy_get_reggroup): ...this.  Update to only create register
group descriptors when needed.
(gdbpy_reggroup_iter_next): Update.

gdb/testsuite/ChangeLog:

* gdb.python/py-arch-reg-groups.exp: Additional tests.
gdb/ChangeLog
gdb/python/py-registers.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-arch-reg-groups.exp