Move deleting thread on TARGET_WAITKIND_THREAD_EXITED to core

Currently, infrun assumes that when TARGET_WAITKIND_THREAD_EXITED is
reported, the corresponding GDB thread has already been removed from
the GDB thread list.

Later in the series, that will no longer work, as infrun will need to
refer to the thread's thread_info when it processes
TARGET_WAITKIND_THREAD_EXITED.

As preparation, this patch makes deleting the GDB thread
responsibility of infrun, instead of the target.

Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Change-Id: I013d87f61ffc9aaca49f0d6ce2a43e3ea69274de
This commit is contained in:
Pedro Alves
2022-12-05 20:44:39 +00:00
parent ad320fbf91
commit 7730e5c6c2
2 changed files with 41 additions and 12 deletions

View File

@@ -898,14 +898,15 @@ linux_nat_switch_fork (ptid_t new_ptid)
registers_changed ();
}
/* Handle the exit of a single thread LP. */
/* Handle the exit of a single thread LP. If DEL_THREAD is true,
delete the thread_info associated to LP, if it exists. */
static void
exit_lwp (struct lwp_info *lp)
exit_lwp (struct lwp_info *lp, bool del_thread = true)
{
struct thread_info *th = linux_target->find_thread (lp->ptid);
if (th)
if (th != nullptr && del_thread)
delete_thread (th);
delete_lwp (lp->ptid);
@@ -3155,11 +3156,17 @@ filter_exit_event (struct lwp_info *event_child,
if (!is_leader (event_child))
{
if (report_thread_events)
ourstatus->set_thread_exited (0);
{
ourstatus->set_thread_exited (0);
/* Delete lwp, but not thread_info, infrun will need it to
process the event. */
exit_lwp (event_child, false);
}
else
ourstatus->set_ignore ();
exit_lwp (event_child);
{
ourstatus->set_ignore ();
exit_lwp (event_child);
}
}
return ptid;