void for_each_thread (gdb::function_view<void (thread_info *)> func);
-/* Like the above, but only consider threads with pid PID. */
-
-void for_each_thread (int pid, gdb::function_view<void (thread_info *)> func);
-
/* Like the above, but only consider threads matching PTID. */
void for_each_thread
/* See gdbthread.h. */
-void
-for_each_thread (int pid, gdb::function_view<void (thread_info *)> func)
-{
- process_info *process = find_process_pid (pid);
- if (process == nullptr)
- return;
-
- process->for_each_thread (func);
-}
-
-/* See gdbthread.h. */
-
void
for_each_thread (ptid_t ptid, gdb::function_view<void (thread_info *)> func)
{
if (ptid == minus_one_ptid)
for_each_thread (func);
else if (ptid.is_pid ())
- for_each_thread (ptid.pid (), func);
+ {
+ process_info *process = find_process_pid (ptid.pid ());
+
+ if (process != nullptr)
+ process->for_each_thread (func);
+ }
else
find_thread (ptid, [func] (thread_info *thread)
{
pts[i] = p;
/* Only update the threads of the current process. */
- for_each_thread (current_thread->id.pid (), [&] (thread_info *thread)
+ current_process ()->for_each_thread ([&] (thread_info *thread)
{
update_registers_callback (thread, watch, i);
});
pts[i].control = arm_hwbp_control_disable (pts[i].control);
/* Only update the threads of the current process. */
- for_each_thread (current_thread->id.pid (), [&] (thread_info *thread)
+ current_process ()->for_each_thread ([&] (thread_info *thread)
{
update_registers_callback (thread, watch, i);
});
first, as PTRACE_KILL will not work otherwise. */
stop_all_lwps (0, NULL);
- for_each_thread (pid, [&] (thread_info *thread)
+ process->for_each_thread ([&] (thread_info *thread)
{
kill_one_lwp_callback (thread, pid);
});
/* Detach from the clone lwps first. If the thread group exits just
while we're detaching, we must reap the clone lwps before we're
able to reap the leader. */
- for_each_thread (process->pid, [this] (thread_info *thread)
+ process->for_each_thread ([this] (thread_info *thread)
{
/* We don't actually detach from the thread group leader just yet.
If the thread group exits, we must reap the zombie clone lwps
thread_db_mourn (process);
#endif
- for_each_thread (process->pid, [this] (thread_info *thread)
+ process->for_each_thread ([this] (thread_info *thread)
{
delete_lwp (get_thread_lwp (thread));
});
return get_thread_lwp (thread);
}
-/* Return the number of known LWPs in the tgid given by PID. */
+/* Return the number of known LWPs in PROCESS. */
static int
-num_lwps (int pid)
+num_lwps (process_info *process)
{
int count = 0;
- for_each_thread (pid, [&] (thread_info *thread)
+ process->for_each_thread ([&] (thread_info *thread)
{
count++;
});
threads_debug_printf ("leader_pid=%d, leader_lp!=NULL=%d, "
"num_lwps=%d, zombie=%d",
- leader_pid, leader_lp!= NULL, num_lwps (leader_pid),
+ leader_pid, leader_lp!= NULL, num_lwps (proc),
linux_proc_pid_is_zombie (leader_pid));
if (leader_lp != NULL && !leader_lp->stopped
priv->watch_mirror = regs;
/* Only update the threads of this process. */
- for_each_thread (proc->pid, update_watch_registers_callback);
+ proc->for_each_thread (update_watch_registers_callback);
return 0;
}
&priv->watch_mirror);
/* Only update the threads of this process. */
- for_each_thread (proc->pid, update_watch_registers_callback);
+ proc->for_each_thread (pid, update_watch_registers_callback);
return 0;
}
void
netbsd_process_target::mourn (struct process_info *proc)
{
- for_each_thread (proc->pid, remove_thread);
+ proc->for_each_thread (remove_thread);
remove_process (proc);
}
void
regcache_invalidate_pid (int pid)
{
- /* Only invalidate the regcaches of threads of this process. */
- for_each_thread (pid, regcache_invalidate_thread);
+ process_info *process = find_process_pid (pid);
+
+ if (process != nullptr)
+ process->for_each_thread (regcache_invalidate_thread);
}
/* See regcache.h. */
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
/* Only update the threads of this process. */
- for_each_thread (current_thread->id.pid (), update_debug_registers);
+ current_process ()->for_each_thread (update_debug_registers);
}
/* Update the inferior's DR7 debug control register from STATE. */
x86_dr_low_set_control (unsigned long control)
{
/* Only update the threads of this process. */
- for_each_thread (current_thread->id.pid (), update_debug_registers);
+ current_process ()->for_each_thread (update_debug_registers);
}
/* Return the current value of a DR register of the current thread's