them. Deleting them now rather than at the next user-visible
stop provides a nicer sequence of events for user and MI
notifications. */
- for (thread_info *th : all_threads_safe ())
- if (th->ptid.pid () == pid && th->ptid != ptid)
- delete_thread (th);
+ for (thread_info &th : all_threads_safe ())
+ if (th.ptid.pid () == pid && th.ptid != ptid)
+ delete_thread (&th);
/* We also need to clear any left over stale state for the
leader/event thread. E.g., if there was any step-resume
{
scoped_restore_current_thread restore_thread;
- for (thread_info *thr : all_threads_safe ())
+ for (thread_info &thr : all_threads_safe ())
{
- if (thr->state == THREAD_EXITED)
+ if (thr.state == THREAD_EXITED)
continue;
- if (thr == ecs->event_thread)
+ if (&thr == ecs->event_thread)
continue;
- if (thr->thread_fsm () != nullptr)
+ if (thr.thread_fsm () != nullptr)
{
- switch_to_thread (thr);
- thr->thread_fsm ()->clean_up (thr);
+ switch_to_thread (&thr);
+ thr.thread_fsm ()->clean_up (&thr);
}
/* As we are cancelling the command/FSM of this thread,
exited event to the user, that reason is gone. Delete
the thread, so that the user doesn't see it in the thread
list, the next proceed doesn't try to resume it, etc. */
- if (thr->has_pending_waitstatus ()
- && (thr->pending_waitstatus ().kind ()
+ if (thr.has_pending_waitstatus ()
+ && (thr.pending_waitstatus ().kind ()
== TARGET_WAITKIND_THREAD_EXITED))
- delete_thread (thr);
+ delete_thread (&thr);
}
}
}
if (start_step_over ())
return true;
- for (thread_info *tp : all_threads_safe ())
+ for (thread_info &tp : all_threads_safe ())
{
- if (tp->state == THREAD_EXITED)
+ if (tp.state == THREAD_EXITED)
continue;
- if (tp->has_pending_waitstatus ())
+ if (tp.has_pending_waitstatus ())
continue;
/* Ignore threads of processes the caller is not
resuming. */
if (!sched_multi
- && (tp->inf->process_target () != resume_target
- || tp->inf->pid != resume_ptid.pid ()))
+ && (tp.inf->process_target () != resume_target
+ || tp.inf->pid != resume_ptid.pid ()))
continue;
- if (tp->control.trap_expected)
+ if (tp.control.trap_expected)
{
infrun_debug_printf ("switching back to stepped thread (step-over)");
- if (keep_going_stepped_thread (tp))
+ if (keep_going_stepped_thread (&tp))
return true;
}
}
- for (thread_info *tp : all_threads_safe ())
+ for (thread_info &tp : all_threads_safe ())
{
- if (tp->state == THREAD_EXITED)
+ if (tp.state == THREAD_EXITED)
continue;
- if (tp->has_pending_waitstatus ())
+ if (tp.has_pending_waitstatus ())
continue;
/* Ignore threads of processes the caller is not
resuming. */
if (!sched_multi
- && (tp->inf->process_target () != resume_target
- || tp->inf->pid != resume_ptid.pid ()))
+ && (tp.inf->process_target () != resume_target
+ || tp.inf->pid != resume_ptid.pid ()))
continue;
/* Did we find the stepping thread? */
- if (tp->control.step_range_end)
+ if (tp.control.step_range_end)
{
infrun_debug_printf ("switching back to stepped thread (stepping)");
- if (keep_going_stepped_thread (tp))
+ if (keep_going_stepped_thread (&tp))
return true;
}
}
/* CONTEXT now holds the current thread list on the remote
target end. Delete GDB-side threads no longer found on the
target. */
- for (thread_info *tp : all_threads_safe ())
+ for (thread_info &tp : all_threads_safe ())
{
- if (tp->inf->process_target () != this)
+ if (tp.inf->process_target () != this)
continue;
- if (!context.contains_thread (tp->ptid))
+ if (!context.contains_thread (tp.ptid))
{
/* Do not remove the thread if it is the last thread in
the inferior. This situation happens when we have a
pending exit process status to process. Otherwise we
may end up with a seemingly live inferior (i.e. pid
!= 0) that has no threads. */
- if (has_single_non_exited_thread (tp->inf))
+ if (has_single_non_exited_thread (tp.inf))
continue;
/* Do not remove the thread if we've requested to be
exit event, and displaced stepping info is recorded
in the thread object. If we deleted the thread now,
we'd lose that info. */
- if ((tp->thread_options () & GDB_THREAD_OPTION_EXIT) != 0)
+ if ((tp.thread_options () & GDB_THREAD_OPTION_EXIT) != 0)
continue;
/* Not found. */
- delete_thread (tp);
+ delete_thread (&tp);
}
}
struct thread_info *
iterate_over_threads (gdb::function_view<bool (struct thread_info *)> callback)
{
- for (thread_info *tp : all_threads_safe ())
- if (callback (tp))
- return tp;
+ for (thread_info &tp : all_threads_safe ())
+ if (callback (&tp))
+ return &tp;
return NULL;
}
{
scoped_restore_current_thread restore_thread;
- for (thread_info *tp : all_threads_safe ())
+ for (thread_info &tp : all_threads_safe ())
{
- switch_to_inferior_no_thread (tp->inf);
+ switch_to_inferior_no_thread (tp.inf);
- if (!thread_alive (tp))
- delete_thread (tp);
+ if (!thread_alive (&tp))
+ delete_thread (&tp);
}
}
void
delete_exited_threads (void)
{
- for (thread_info *tp : all_threads_safe ())
- if (tp->state == THREAD_EXITED)
- delete_thread (tp);
+ for (thread_info &tp : all_threads_safe ())
+ if (tp.state == THREAD_EXITED)
+ delete_thread (&tp);
}
/* Return true value if stack temporaries are enabled for the thread