]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: split inferior and thread setup when opening a core file
authorAndrew Burgess <aburgess@redhat.com>
Thu, 1 Jun 2023 17:30:48 +0000 (18:30 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Sun, 4 Jun 2023 13:35:35 +0000 (14:35 +0100)
commita99db75d461e1d414b49f7c781096658bfb73680
tree8d2fd8b672b1afa13e7b3744619d4acdbd480fe8
parente9683acf5e51c2bac8aa68d30d9ac3683dddcc7d
gdb: split inferior and thread setup when opening a core file

I noticed that in corelow.c, when a core file is opened, both the
thread and inferior setup is done in add_to_thread_list.  In this
patch I propose hoisting the inferior setup out of add_to_thread_list
into core_target_open.

The only thing about this change that gave me cause for concern is
that in add_to_thread_list, we only setup the inferior after finding
the first section with a name like ".reg/NN".  If we find no such
section then the inferior will never be setup.

Is this important?

Well, I don't think so.  Back in core_target_open, if there is no
current thread (which there will not be if no ".reg/NN" section was
found), then we look for a thread in the current inferior.  If there
are no threads (which there will not be if no ".reg/NN" is found),
then we once again setup the current inferior.

What I think this means, is that, in all cases, the current inferior
will end up being setup.  By moving the inferior setup code earlier in
core_target_open and making it non-conditional, we can remove the
later code that sets up the inferior, we now know this will always
have been done.

There should be no user visible changes after this commit.
gdb/corelow.c