mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-04-06 14:21:43 +08:00
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:
parent
6672ccafd9
commit
3470a0e144
@ -116,10 +116,6 @@ thread_info *find_thread (ptid_t filter,
|
||||
|
||||
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
|
||||
|
@ -352,25 +352,18 @@ process_info::for_each_thread (gdb::function_view<void (thread_info *)> func)
|
||||
|
||||
/* 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)
|
||||
{
|
||||
|
@ -636,7 +636,7 @@ arm_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
|
||||
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);
|
||||
});
|
||||
@ -681,7 +681,7 @@ arm_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
|
||||
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);
|
||||
});
|
||||
|
@ -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
|
||||
|
@ -575,7 +575,7 @@ mips_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
|
||||
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;
|
||||
}
|
||||
@ -624,7 +624,7 @@ mips_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
|
||||
&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;
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ netbsd_process_target::detach (process_info *process)
|
||||
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);
|
||||
}
|
||||
|
@ -97,8 +97,10 @@ regcache_invalidate_thread (struct thread_info *thread)
|
||||
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. */
|
||||
|
@ -65,7 +65,7 @@ x86_dr_low_set_addr (int regnum, CORE_ADDR addr)
|
||||
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. */
|
||||
@ -74,7 +74,7 @@ static void
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user