{
/* If we do have an inferior, attempt to fetch its thread's thread_info
struct. */
- thread_info *thread
- = find_thread_ptid (current_inferior ()->process_target (),
- inferior_ptid);
+ thread_info *thread = current_inferior ()->find_thread (inferior_ptid);
/* If the thread is running, we will not be able to fetch the mask
registers. */
if (gptid.is_pid ())
{
- tp = find_thread_ptid (proc_target, gptid);
+ tp = proc_target->find_thread (gptid);
thread_change_ptid (proc_target, gptid, pptid);
aix_thread_info *priv = new aix_thread_info;
priv->pdtid = pbuf[pi].pdtid;
{
/* No need to iterate all non-exited threads if the request is to stop a
specific thread. */
- stop_one_thread (find_thread_ptid (proc_target, ptid));
+ stop_one_thread (proc_target->find_thread (ptid));
return;
}
else
ws.set_stopped (GDB_SIGNAL_0);
- thread_info *thread = find_thread_ptid (proc_target, event_ptid);
+ thread_info *thread = proc_target->find_thread (event_ptid);
if (thread == nullptr)
{
/* Silently create new GPU threads to avoid spamming the
thread_change_ptid (beneath, inferior_ptid, ptid);
/* Don't let the core see a ptid without a corresponding thread. */
- thread_info *thread = find_thread_ptid (beneath, ptid);
+ thread_info *thread = beneath->find_thread (ptid);
if (thread == NULL || thread->state == THREAD_EXITED)
add_thread (beneath, ptid);
process_stratum_target *proc_target
= as_process_stratum_target (this->beneath ());
- thread_info *thread = find_thread_ptid (proc_target, ptid);
+ thread_info *thread = proc_target->find_thread (ptid);
if (thread == nullptr || thread->state == THREAD_EXITED)
{
/* If INFERIOR_PTID doesn't have a tid member yet, then ptid
{
/* A thread was removed. */
struct thread_info *thr
- = find_thread_ptid (this, ptid_t (inf->pid, 0, old_id));
+ = this->find_thread (ptid_t (inf->pid, 0, old_id));
delete_thread (thr);
kret = mach_port_deallocate (gdb_task, old_id);
MACH_CHECK_ERROR (kret);
threads might be skipped during post_attach that
have not yet reported their PL_FLAG_EXITED event.
Ignore EXITED events for an unknown LWP. */
- thread_info *thr = find_thread_ptid (this, wptid);
+ thread_info *thr = this->find_thread (wptid);
if (thr != nullptr)
{
fbsd_lwp_debug_printf ("deleting thread for LWP %u",
global id, not the system's). */
extern int valid_global_thread_id (int global_id);
-/* Search function to lookup a (non-exited) thread by 'ptid'. */
-extern struct thread_info *find_thread_ptid (process_stratum_target *targ,
- ptid_t ptid);
-
/* Find thread by GDB global thread ID. */
struct thread_info *find_thread_global_id (int global_id);
inf_update_procs (inf);
- thread_info *thr
- = find_thread_ptid (this, ptid_t (pid, inf_pick_first_thread ()));
+ thread_info *thr = this->find_thread (ptid_t (pid, inf_pick_first_thread ()));
switch_to_thread (thr);
/* We have to initialize the terminal settings now, since the code
ptid_t last_ptid;
get_last_target_status (&last_target, &last_ptid, nullptr);
- tp = find_thread_ptid (last_target, last_ptid);
+ tp = last_target->find_thread (last_ptid);
}
if (tp != nullptr)
bs = tp->control.stop_bpstat;
/* If we followed the child, switch to it... */
if (follow_child)
{
- tp = find_thread_ptid (parent_targ, child);
+ tp = parent_targ->find_thread (child);
switch_to_thread (tp);
/* ... and preserve the stepping state, in case the
}
else
{
- t = find_thread_ptid (event.target, event.ptid);
+ t = event.target->find_thread (event.ptid);
/* Check if this is the first time we see this thread.
Don't bother adding if it individually exited. */
if (t == nullptr
}
else
{
- thread_info *t = find_thread_ptid (event.target, event.ptid);
+ thread_info *t = event.target->find_thread (event.ptid);
if (t == nullptr)
t = add_thread (event.target, event.ptid);
if (ecs->ws.kind () != TARGET_WAITKIND_EXITED
&& ecs->ws.kind () != TARGET_WAITKIND_SIGNALLED)
{
- ecs->event_thread = find_thread_ptid (ecs->target, ecs->ptid);
+ ecs->event_thread = ecs->target->find_thread (ecs->ptid);
/* If it's a new thread, add it to the thread database. */
if (ecs->event_thread == nullptr)
ecs->event_thread = add_thread (ecs->target, ecs->ptid);
need to have access to the just-exited thread. That is the
case of GNU/Linux's "checkpoint" support, for example.
Call the switch_to_xxx routine as appropriate. */
- thread_info *thr = find_thread_ptid (ecs->target, ecs->ptid);
+ thread_info *thr = ecs->target->find_thread (ecs->ptid);
if (thr != nullptr)
switch_to_thread (thr);
else
/* Note that one of these may be an invalid pointer,
depending on detach_fork. */
thread_info *parent = ecs->event_thread;
- thread_info *child = find_thread_ptid (targ, ecs->ws.child_ptid ());
+ thread_info *child = targ->find_thread (ecs->ws.child_ptid ());
/* At this point, the parent is marked running, and the
child is marked stopped. */
list, waitpid the ptid.
If fi->parent_ptid is a part of lwp and it is stopped, waitpid the
ptid. */
- thread_info *parent = find_thread_ptid (linux_target, pptid);
+ thread_info *parent = linux_target->find_thread (pptid);
if ((parent == NULL && find_fork_ptid (pptid))
|| (parent != NULL && parent->state == THREAD_STOPPED))
{
static void
exit_lwp (struct lwp_info *lp)
{
- struct thread_info *th = find_thread_ptid (linux_target, lp->ptid);
+ struct thread_info *th = linux_target->find_thread (lp->ptid);
if (th)
{
signo = gdb_signal_from_host (WSTOPSIG (lp->status));
else
{
- struct thread_info *tp = find_thread_ptid (linux_target, lp->ptid);
+ thread_info *tp = linux_target->find_thread (lp->ptid);
if (target_is_non_stop_p () && !tp->executing ())
{
/* Check in thread_info::pending_waitstatus. */
- thread_info *tp = find_thread_ptid (linux_target, lp->ptid);
+ thread_info *tp = linux_target->find_thread (lp->ptid);
if (tp->has_pending_waitstatus ())
{
const target_waitstatus &ws = tp->pending_waitstatus ();
{
struct thread_info *thread;
- thread = find_thread_ptid (linux_target, lp->ptid);
+ thread = linux_target->find_thread (lp->ptid);
if (thread != NULL)
{
signo = thread->stop_signal ();
{
struct target_waitstatus *ourstatus = &lp->waitstatus;
struct gdbarch *gdbarch = target_thread_architecture (lp->ptid);
- thread_info *thread = find_thread_ptid (linux_target, lp->ptid);
+ thread_info *thread = linux_target->find_thread (lp->ptid);
int syscall_number = (int) gdbarch_get_syscall_number (gdbarch, thread);
if (stopping)
if (!lp->step
&& WSTOPSIG (status) && sigismember (&pass_mask, WSTOPSIG (status))
&& (WSTOPSIG (status) != SIGSTOP
- || !find_thread_ptid (linux_target, lp->ptid)->stop_requested)
+ || !linux_target->find_thread (lp->ptid)->stop_requested)
&& !linux_wstatus_maybe_breakpoint (status))
{
linux_resume_one_lwp (lp, lp->step, signo);
if (debug_linux_nat)
{
- if (find_thread_ptid (linux_target, lwp->ptid)->stop_requested)
+ if (linux_target->find_thread (lwp->ptid)->stop_requested)
linux_nat_debug_printf ("already stopped/stop_requested %s",
lwp->ptid.to_string ().c_str ());
else
thread_db_err_str (err));
/* Fill the cache. */
- tp = find_thread_ptid (stopped->inf->process_target (), ptid);
+ tp = stopped->inf->process_target ()->find_thread (ptid);
return record_thread (info, tp, ptid, &th, &ti);
}
\f
if (info == NULL)
return 0;
- thread_info *stopped = find_thread_ptid (linux_target, parent);
+ thread_info *stopped = linux_target->find_thread (parent);
thread_from_lwp (stopped, child);
to how GDB accesses TLS could result in this passing
without exercising the calls it's supposed to. */
ptid_t ptid = ptid_t (tdb_testinfo->info->pid, ti.ti_lid);
- thread_info *thread_info = find_thread_ptid (linux_target, ptid);
+ thread_info *thread_info = linux_target->find_thread (ptid);
if (thread_info != NULL && thread_info->priv != NULL)
{
LOG ("; errno");
return ptid;
/* Fill in the thread's user-level thread id and status. */
- thread_from_lwp (find_thread_ptid (beneath, ptid), ptid);
+ thread_from_lwp (beneath->find_thread (ptid), ptid);
return ptid;
}
}
ptid_t ptid (info->pid, ti.ti_lid);
- tp = find_thread_ptid (info->process_target, ptid);
+ tp = info->process_target->find_thread (ptid);
if (tp == NULL || tp->priv == NULL)
record_thread (info, tp, ptid, th_p, &ti);
process_stratum_target *beneath
= as_process_stratum_target (this->beneath ());
/* Find the matching thread. */
- thread_info = find_thread_ptid (beneath, ptid);
+ thread_info = beneath->find_thread (ptid);
/* We may not have discovered the thread yet. */
if (thread_info != NULL && thread_info->priv == NULL)
if (ptid == minus_one_ptid || ptid.is_pid ())
tp = inferior_thread ();
else
- tp = find_thread_ptid (target, ptid);
+ tp = target->find_thread (ptid);
/* Suppress output while calling an inferior function. */
if (tp->control.in_infcall)
threads might be skipped during post_attach that
have not yet reported their PTRACE_LWP_EXIT event.
Ignore exited events for an unknown LWP. */
- thread_info *thr = find_thread_ptid (this, wptid);
+ thread_info *thr = this->find_thread (wptid);
if (thr == nullptr)
ourstatus->set_spurious ();
else
(e.g. thread exited). */
continue;
ptid = ptid_t (pid, 0, tid);
- new_thread = find_thread_ptid (this, ptid);
+ new_thread = this->find_thread (ptid);
if (!new_thread)
new_thread = add_thread (ptid);
update_thread_private_data (new_thread, tid, status.state, 0);
update_thread_list ();
- switch_to_thread (find_thread_ptid (this, ptid));
+ switch_to_thread (this->find_thread (ptid));
}
void
ptid_t ptid = do_attach (ptid_t (pid));
update_thread_list ();
- switch_to_thread (find_thread_ptid (this, ptid));
+ switch_to_thread (this->find_thread (ptid));
inf = current_inferior ();
inferior_appeared (inf, pid);
/* See process-stratum-target.h. */
+thread_info *
+process_stratum_target::find_thread (ptid_t ptid)
+{
+ inferior *inf = find_inferior_ptid (this, ptid);
+ if (inf == NULL)
+ return NULL;
+ return inf->find_thread (ptid);
+}
+
+/* See process-stratum-target.h. */
+
std::set<process_stratum_target *>
all_non_exited_process_targets ()
{
thread_info *random_resumed_with_pending_wait_status
(inferior *inf, ptid_t filter_ptid);
+ /* Search function to lookup a (non-exited) thread by 'ptid'. */
+ thread_info *find_thread (ptid_t ptid);
+
/* The connection number. Visible in "info connections". */
int connection_number = 0;
if (print_thread_events)
gdb_printf (_("[%s exited]\n"),
target_pid_to_str (retval).c_str ());
- delete_thread (find_thread_ptid (this, retval));
+ delete_thread (this->find_thread (retval));
target_continue_no_signal (ptid);
goto wait_again;
}
if (print_thread_events)
gdb_printf (_("[%s exited]\n"),
target_pid_to_str (retval).c_str ());
- delete_thread (find_thread_ptid (this, retval));
+ delete_thread (this->find_thread (retval));
status->set_spurious ();
return retval;
}
{
ptid_t gdb_threadid = ptid_t (pi->pid, thread->tid, 0);
- thread_info *thr = find_thread_ptid (&the_procfs_target, gdb_threadid);
+ thread_info *thr = the_procfs_target.find_thread (gdb_threadid);
if (thr == NULL || thr->state == THREAD_EXITED)
add_thread (&the_procfs_target, gdb_threadid);
process_stratum_target *proc_target
= as_process_stratum_target (this->beneath ());
ptid_t underlying = get_base_thread_from_ravenscar_task (tp->ptid);
- tp = find_thread_ptid (proc_target, underlying);
+ tp = proc_target->find_thread (underlying);
return beneath ()->enable_btrace (tp, conf);
}
process_stratum_target *proc_target
= as_process_stratum_target (this->beneath ());
ptid_t underlying = get_base_thread_from_ravenscar_task (ptid);
- switch_to_thread (find_thread_ptid (proc_target, underlying));
+ switch_to_thread (proc_target->find_thread (underlying));
}
/* Some targets use lazy FPU initialization. On these, the FP
/* The running thread may not have been added to
system.tasking.debug's list yet; so ravenscar_update_thread_list
may not always add it to the thread list. Add it here. */
- thread_info *active_thr = find_thread_ptid (proc_target, active_ptid);
+ thread_info *active_thr = proc_target->find_thread (active_ptid);
if (active_thr == nullptr)
{
active_thr = ::add_thread (proc_target, active_ptid);
record_btrace_target::record_method (ptid_t ptid)
{
process_stratum_target *proc_target = current_inferior ()->process_target ();
- thread_info *const tp = find_thread_ptid (proc_target, ptid);
+ thread_info *const tp = proc_target->find_thread (ptid);
if (tp == NULL)
error (_("No thread."));
/* Thread-db may ask for a thread's registers before GDB knows about the
thread. We forward the request to the target beneath in this
case. */
- thread_info *tp = find_thread_ptid (regcache->target (), regcache->ptid ());
+ thread_info *tp = regcache->target ()->find_thread (regcache->ptid ());
if (tp != nullptr)
replay = tp->btrace.replay;
/* If this is a new thread, add it to GDB's thread list.
If we leave it up to WFI to do this, bad things will happen. */
- thread_info *tp = find_thread_ptid (this, currthread);
+ thread_info *tp = this->find_thread (currthread);
if (tp != NULL && tp->state == THREAD_EXITED)
{
/* We're seeing an event on a thread id we knew had exited.
static remote_thread_info *
get_remote_thread_info (remote_target *target, ptid_t ptid)
{
- thread_info *thr = find_thread_ptid (target, ptid);
+ thread_info *thr = target->find_thread (ptid);
return get_remote_thread_info (thr);
}
remote_notice_new_inferior (item.ptid, executing);
- thread_info *tp = find_thread_ptid (this, item.ptid);
+ thread_info *tp = this->find_thread (item.ptid);
remote_thread_info *info = get_remote_thread_info (tp);
info->core = item.core;
info->extra = std::move (item.extra);
if (ignore_event)
continue;
- thread_info *evthread = find_thread_ptid (this, event_ptid);
+ thread_info *evthread = this->find_thread (event_ptid);
if (ws.kind () == TARGET_WAITKIND_STOPPED)
{
}
}
else
- switch_to_thread (find_thread_ptid (this, curr_thread));
+ switch_to_thread (this->find_thread (curr_thread));
}
/* init_wait_for_inferior should be called before get_offsets in order
remote_detach_pid (reply->ws.child_ptid ().pid ());
}
- thread_info *tp = find_thread_ptid (this, inferior_ptid);
+ thread_info *tp = this->find_thread (inferior_ptid);
/* Check to see if we are detaching a fork parent. Note that if we
are detaching a fork child, tp == NULL. */
{
/* If we don't know about the target thread's tid, then
we're resuming magic_null_ptid (see caller). */
- tp = find_thread_ptid (this, magic_null_ptid);
+ tp = this->find_thread (magic_null_ptid);
}
else
- tp = find_thread_ptid (this, ptid);
+ tp = this->find_thread (ptid);
gdb_assert (tp != NULL);
if (tp->control.may_range_step)
int
remote_target::core_of_thread (ptid_t ptid)
{
- thread_info *info = find_thread_ptid (this, ptid);
+ thread_info *info = this->find_thread (ptid);
if (info != NULL && info->priv != NULL)
return get_remote_thread_info (info)->core;
/* Iterate on a single thread. */
m_mode = mode::SINGLE_THREAD;
- m_thr = find_thread_ptid (filter_target, filter_ptid);
+ m_thr = filter_target->find_thread (filter_ptid);
}
}
}
/* See gdbthread.h. */
-struct thread_info *
-find_thread_ptid (process_stratum_target *targ, ptid_t ptid)
-{
- inferior *inf = find_inferior_ptid (targ, ptid);
- if (inf == NULL)
- return NULL;
- return inf->find_thread (ptid);
-}
-
-/* See gdbthread.h. */
-
struct thread_info *
find_thread_by_handle (gdb::array_view<const gdb_byte> handle,
struct inferior *inf)
bool
in_thread_list (process_stratum_target *targ, ptid_t ptid)
{
- return find_thread_ptid (targ, ptid) != nullptr;
+ return targ->find_thread (ptid) != nullptr;
}
/* Finds the first thread of the inferior. */
void
switch_to_thread (process_stratum_target *proc_target, ptid_t ptid)
{
- thread_info *thr = find_thread_ptid (proc_target, ptid);
+ thread_info *thr = proc_target->find_thread (ptid);
switch_to_thread (thr);
}
target_pid_to_str (ptid).c_str (),
(unsigned) exit_code);
- ::delete_thread (find_thread_ptid (this, ptid));
+ ::delete_thread (this->find_thread (ptid));
auto iter = std::find_if (windows_process.thread_list.begin (),
windows_process.thread_list.end (),
this->resume (minus_one_ptid, 0, GDB_SIGNAL_0);
}
- switch_to_thread (find_thread_ptid (this, last_ptid));
+ switch_to_thread (this->find_thread (last_ptid));
/* Now that the inferior has been started and all DLLs have been mapped,
we can iterate over all DLLs and load them in.