[13/19] Remove usages of find_inferior in stop_all_lwps

Message ID 1511195683-2055-14-git-send-email-simon.marchi@ericsson.com
State New, archived
Headers

Commit Message

Simon Marchi Nov. 20, 2017, 4:34 p.m. UTC
  From: Simon Marchi <simon.marchi@polymtl.ca>

Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (send_sigstop_callback): Return void, change
	parameter type.  Rename to...
	(send_sigstop): ... this.
	(suspend_and_send_sigstop_callback): Return void, change parameter
	type.  Rename to...
	(suspend_and_send_sigstop): ... this.
	(stop_all_lwps): Use for_each_thread.
---
 gdb/gdbserver/linux-low.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
  

Patch

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 63a187e..76a88c1 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -3932,36 +3932,35 @@  send_sigstop (struct lwp_info *lwp)
   kill_lwp (pid, SIGSTOP);
 }
 
-static int
-send_sigstop_callback (thread_info *thread, void *except)
+static void
+send_sigstop (thread_info *thread, lwp_info *except)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
 
   /* Ignore EXCEPT.  */
   if (lwp == except)
-    return 0;
+    return;
 
   if (lwp->stopped)
-    return 0;
+    return;
 
   send_sigstop (lwp);
-  return 0;
 }
 
 /* Increment the suspend count of an LWP, and stop it, if not stopped
    yet.  */
-static int
-suspend_and_send_sigstop_callback (thread_info *thread, void *except)
+static void
+suspend_and_send_sigstop (thread_info *thread, lwp_info *except)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
 
   /* Ignore EXCEPT.  */
   if (lwp == except)
-    return 0;
+    return;
 
   lwp_suspended_inc (lwp);
 
-  return send_sigstop_callback (thread, except);
+  send_sigstop (thread, except);
 }
 
 static void
@@ -4156,9 +4155,16 @@  stop_all_lwps (int suspend, struct lwp_info *except)
 		      : STOPPING_THREADS);
 
   if (suspend)
-    find_inferior (&all_threads, suspend_and_send_sigstop_callback, except);
+    for_each_thread ([&] (thread_info *thread)
+      {
+	suspend_and_send_sigstop (thread, except);
+      });
   else
-    find_inferior (&all_threads, send_sigstop_callback, except);
+    for_each_thread ([&] (thread_info *thread)
+      {
+	 send_sigstop (thread, except);
+      });
+
   wait_for_sigstop ();
   stopping_threads = NOT_STOPPING_THREADS;