[PATCH 1/3] gdb: split inferior and thread setup when opening a core file

Kevin Buettner kevinb@redhat.com
Sat Jun 10 00:04:45 GMT 2023


On Mon,  5 Jun 2023 10:11:07 +0100
Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> wrote:

> 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 | 62 ++++++++++++++++++++++++---------------------------
>  1 file changed, 29 insertions(+), 33 deletions(-)

LGTM.

Reviewed-by: Kevin Buettner <kevinb@redhat.com>



More information about the Gdb-patches mailing list