]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: ensure all targets are popped before an inferior is destructed
authorAndrew Burgess <aburgess@redhat.com>
Thu, 22 Sep 2022 17:11:30 +0000 (18:11 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 14 Dec 2022 13:57:22 +0000 (13:57 +0000)
commit740a579fd5f5cd56bfb42a3f62c61ffd42d43186
treeb2eb14597b6f799a94a82bca55f3630824b79e9b
parentc8181f706f5a481e9667195d1f5d1623db6cc7f2
gdb: ensure all targets are popped before an inferior is destructed

Now that the inferiors target_stack automatically manages target
reference counts, we might think that we don't need to unpush targets
when an inferior is deleted...

...unfortunately that is not the case.  The inferior::unpush function
can do some work depending on the type of target, so it is important
that we still pass through this function.

To ensure that this is the case, in this commit I've added an assert
to inferior::~inferior that ensures the inferior's target_stack is
empty (except for the ever present dummy_target).

I've then added a pop_all_targets call to delete_inferior, otherwise
the new assert will fire in, e.g. the gdb.python/py-inferior.exp test.
gdb/inferior.c