if (uiout->is_mi_like_p ())
{
thread_info *thread = (ada_task_is_alive (task_info)
- ? find_thread_ptid (inf, task_info->ptid)
+ ? inf->find_thread (task_info->ptid)
: nullptr);
if (thread != NULL)
computed if target_get_ada_task_ptid has not been implemented for
our target (yet). Rather than cause an assertion error in that case,
it's nicer for the user to just refuse to perform the task switch. */
- thread_info *tp = find_thread_ptid (inf, task_info->ptid);
+ thread_info *tp = inf->find_thread (task_info->ptid);
if (tp == NULL)
error (_("Unable to compute thread ID for task %s.\n"
"Cannot switch to this task."),
if (!ada_task_is_alive (&task))
continue;
- thread_info *tp = find_thread_ptid (inf, task.ptid);
+ thread_info *tp = inf->find_thread (task.ptid);
if (tp == nullptr)
warning (_("Unable to compute thread ID for task %s.\n"
"Cannot switch to this task."),
if (!ada_task_is_alive (&task))
continue;
- thread_info *tp = find_thread_ptid (inf, task.ptid);
+ thread_info *tp = inf->find_thread (task.ptid);
if (tp == nullptr)
warning (_("Unable to compute thread ID for task %s.\n"
"Cannot switch to this task."),
}
else
{
- thread = find_thread_ptid (current_inferior (), ptid);
+ thread = current_inferior ()->find_thread (ptid);
if (!thread)
error (_("aix-thread resume: unknown pthread %ld"),
ptid.lwp ());
beneath ()->fetch_registers (regcache, regno);
else
{
- thread = find_thread_ptid (current_inferior (), regcache->ptid ());
+ thread = current_inferior ()->find_thread (regcache->ptid ());
aix_thread_info *priv = get_aix_thread_info (thread);
tid = priv->tid;
beneath ()->store_registers (regcache, regno);
else
{
- thread = find_thread_ptid (current_inferior (), regcache->ptid ());
+ thread = current_inferior ()->find_thread (regcache->ptid ());
aix_thread_info *priv = get_aix_thread_info (thread);
tid = priv->tid;
struct btrace_thread_info *btinfo;
unsigned int size, begin, end, from, to;
- thread_info *tp = find_thread_ptid (current_inferior (), inferior_ptid);
+ thread_info *tp = current_inferior ()->find_thread (inferior_ptid);
if (tp == NULL)
error (_("No thread."));
global id, not the system's). */
extern int valid_global_thread_id (int global_id);
-/* Find (non-exited) thread PTID of inferior INF. */
-extern thread_info *find_thread_ptid (inferior *inf, ptid_t ptid);
-
/* Search function to lookup a (non-exited) thread by 'ptid'. */
extern struct thread_info *find_thread_ptid (process_stratum_target *targ,
ptid_t ptid);
/* See inferior.h. */
+thread_info *
+inferior::find_thread (ptid_t ptid)
+{
+ auto it = this->ptid_thread_map.find (ptid);
+ if (it != this->ptid_thread_map.end ())
+ return it->second;
+ else
+ return nullptr;
+}
+
+/* See inferior.h. */
+
void
inferior::clear_thread_list (bool silent)
{
inline safe_inf_threads_range threads_safe ()
{ return safe_inf_threads_range (this->thread_list.begin ()); }
+ /* Find (non-exited) thread PTID of this inferior. */
+ thread_info *find_thread (ptid_t ptid);
+
/* Delete all threads in the thread list. If SILENT, exit threads
silently. */
void clear_thread_list (bool silent);
The former case will have pending_follow cleared, the later will have
pending_follow set. */
- thread_info *parent_thread = find_thread_ptid (parent_inf, parent_ptid);
+ thread_info *parent_thread = parent_inf->find_thread (parent_ptid);
gdb_assert (parent_thread != nullptr);
parent_thread->pending_follow.set_spurious ();
ptid.to_string ().c_str ());
/* We have a specific thread to check. */
- tp = find_thread_ptid (inf, ptid);
+ tp = inf->find_thread (ptid);
gdb_assert (tp != nullptr);
if (!tp->has_pending_waitstatus ())
tp = nullptr;
std::string
thread_db_target::pid_to_str (ptid_t ptid)
{
- thread_info *thread_info = find_thread_ptid (current_inferior (), ptid);
+ thread_info *thread_info = current_inferior ()->find_thread (ptid);
if (thread_info != NULL && thread_info->priv != NULL)
{
if (non_stop)
{
thread_info *thread
- = find_thread_ptid (current_inferior ()->process_target (),
- ptid);
+ = current_inferior ()->find_thread (ptid);
if (thread != nullptr)
return thread_to_thread_object (thread);
PyErr_SetString (PyExc_RuntimeError, "Could not find event thread");
void
ravenscar_thread_target::add_thread (struct ada_task_info *task)
{
- if (find_thread_ptid (current_inferior (), task->ptid) == NULL)
+ if (current_inferior ()->find_thread (task->ptid) == NULL)
{
::add_thread (current_inferior ()->process_target (), task->ptid);
m_cpu_map[task->ptid.tid ()] = task->base_cpu;
/* See if we have a new thread. */
if (rtnval.tid_p ())
{
- thread_info *thr = find_thread_ptid (current_inferior (), rtnval);
+ thread_info *thr = current_inferior ()->find_thread (rtnval);
if (thr == NULL || thr->state == THREAD_EXITED)
{
process_stratum_target *proc_target
return -1;
ptid_t ptid = ptid_t (current_inferior ()->pid, 0, ti.ti_tid);
- thread_info *thr = find_thread_ptid (current_inferior (), ptid);
+ thread_info *thr = current_inferior ()->find_thread (ptid);
if (thr == NULL || thr->state == THREAD_EXITED)
{
process_stratum_target *proc_target
clear_thread_inferior_resources (tp);
/* Remove from the ptid_t map. We don't want for
- find_thread_ptid to find exited threads. Also, the target
+ inferior::find_thread to find exited threads. Also, the target
may reuse the ptid for a new thread, and there can only be
one value per key; adding a new thread with the same ptid_t
would overwrite the exited thread's ptid entry. */
If we do, it must be dead, otherwise we wouldn't be adding a new
thread with the same id. The OS is reusing this id --- delete
the old thread, and create a new one. */
- thread_info *tp = find_thread_ptid (inf, ptid);
+ thread_info *tp = inf->find_thread (ptid);
if (tp != nullptr)
delete_thread (tp);
inferior *inf = find_inferior_ptid (targ, ptid);
if (inf == NULL)
return NULL;
- return find_thread_ptid (inf, ptid);
-}
-
-/* See gdbthread.h. */
-
-struct thread_info *
-find_thread_ptid (inferior *inf, ptid_t ptid)
-{
- gdb_assert (inf != nullptr);
-
- auto it = inf->ptid_thread_map.find (ptid);
- if (it != inf->ptid_thread_map.end ())
- return it->second;
- else
- return nullptr;
+ return inf->find_thread (ptid);
}
/* See gdbthread.h. */
inf = find_inferior_ptid (targ, old_ptid);
inf->pid = new_ptid.pid ();
- tp = find_thread_ptid (inf, old_ptid);
+ tp = inf->find_thread (old_ptid);
gdb_assert (tp != nullptr);
int num_erased = inf->ptid_thread_map.erase (old_ptid);