gdbserver: remove for_each_thread(pid, func)

Remove this overload, prefer to use `process_info::for_each_thread`.  In
many instances, the `process_info` is already available, so this saves a
map lookup.  In other instances, add the `process_info` lookup at the
call site.

In `linux-arm-low.cc` and `win32-i386-low.cc`, use `current_process ()`
instead of `current_thread->id.pid ()`.  I presume that if
`current_process ()` and `current_thread` don't match, it's a bug
orthogonal to this change.

Change-Id: I751ed497cb1f313cf937b35125151bee9316fc51
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
This commit is contained in:
Simon Marchi
2024-11-06 13:39:48 -05:00
parent 6672ccafd9
commit 3470a0e144
8 changed files with 24 additions and 33 deletions

View File

@@ -1385,7 +1385,7 @@ linux_process_target::kill (process_info *process)
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);
});
@@ -1588,7 +1588,7 @@ linux_process_target::detach (process_info *process)
/* 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
@@ -1621,7 +1621,7 @@ linux_process_target::mourn (process_info *process)
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));
});
@@ -1756,14 +1756,14 @@ find_lwp_pid (ptid_t ptid)
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++;
});
@@ -1802,7 +1802,7 @@ linux_process_target::check_zombie_leaders ()
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