This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Remove usage of find_inferior in linux_detach
- From: Simon Marchi <simark at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 3 Dec 2017 01:48:19 -0000
- Subject: [binutils-gdb] Remove usage of find_inferior in linux_detach
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=798a38e8de5f0fb5f7b17ae757b2bf4c5139c023
commit 798a38e8de5f0fb5f7b17ae757b2bf4c5139c023
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date: Sat Dec 2 20:36:36 2017 -0500
Remove usage of find_inferior in linux_detach
Replace with for_each_thread with pid filtering.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_detach_lwp_callback): Return void, remove
args parameter, don't check for pid.
(linux_detach): Use for_each_thread.
Diff:
---
gdb/gdbserver/ChangeLog | 6 ++++++
gdb/gdbserver/linux-low.c | 22 +++++++---------------
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index f4f77aa..ce3cfc9 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
2017-12-02 Simon Marchi <simon.marchi@polymtl.ca>
+ * linux-low.c (linux_detach_lwp_callback): Return void, remove
+ args parameter, don't check for pid.
+ (linux_detach): Use for_each_thread.
+
+2017-12-02 Simon Marchi <simon.marchi@polymtl.ca>
+
* linux-low.c (struct counter): Remove.
(second_thread_of_pid_p): Remove.
(last_thread_of_process_p): Use find_thread.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 2e63468..c495c24 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1581,28 +1581,20 @@ linux_detach_one_lwp (struct lwp_info *lwp)
delete_lwp (lwp);
}
-/* Callback for find_inferior. Detaches from non-leader threads of a
+/* Callback for for_each_thread. Detaches from non-leader threads of a
given process. */
-static int
-linux_detach_lwp_callback (thread_info *thread, void *args)
+static void
+linux_detach_lwp_callback (thread_info *thread)
{
- struct lwp_info *lwp = get_thread_lwp (thread);
- int pid = *(int *) args;
- int lwpid = lwpid_of (thread);
-
- /* Skip other processes. */
- if (thread->id.pid () != pid)
- return 0;
-
/* We don't actually detach from the thread group leader just yet.
If the thread group exits, we must reap the zombie clone lwps
before we're able to reap the leader. */
- if (thread->id.pid () == lwpid)
- return 0;
+ if (thread->id.pid () == thread->id.lwp ())
+ return;
+ lwp_info *lwp = get_thread_lwp (thread);
linux_detach_one_lwp (lwp);
- return 0;
}
static int
@@ -1636,7 +1628,7 @@ linux_detach (int 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. */
- find_inferior (&all_threads, linux_detach_lwp_callback, &pid);
+ for_each_thread (pid, linux_detach_lwp_callback);
main_lwp = find_lwp_pid (pid_to_ptid (pid));
linux_detach_one_lwp (main_lwp);