This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Remove usages of find_inferior in handle_status


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=99078d344db25efc376877e0e4c95157f0c36c60

commit 99078d344db25efc376877e0e4c95157f0c36c60
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Fri Oct 27 23:41:49 2017 -0400

    Remove usages of find_inferior in handle_status
    
    Replace one with find_thread, the other with for_each_thread.
    
    gdb/gdbserver/ChangeLog:
    
    	* server.c (queue_stop_reply_callback): Change prototype, return
    	void.
    	(find_status_pending_thread_callback): Remove.
    	(handle_status): Replace find_inferior with find_thread and
    	for_each_thread.

Diff:
---
 gdb/gdbserver/ChangeLog |  8 ++++++++
 gdb/gdbserver/server.c  | 23 +++++++----------------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index b314076..87d870e 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,11 @@
+2017-10-27  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* server.c (queue_stop_reply_callback): Change prototype, return
+	void.
+	(find_status_pending_thread_callback): Remove.
+	(handle_status): Replace find_inferior with find_thread and
+	for_each_thread.
+
 2017-10-25  Alan Hayward  <alan.hayward@arm.com>
 
 	* linux-aarch64-low.c (aarch64_fill_gregset): Replace defines
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 892d765..650cf1c 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -3230,8 +3230,8 @@ myresume (char *own_buf, int step, int sig)
 /* Callback for for_each_inferior.  Make a new stop reply for each
    stopped thread.  */
 
-static int
-queue_stop_reply_callback (thread_info *thread, void *arg)
+static void
+queue_stop_reply_callback (thread_info *thread)
 {
   /* For now, assume targets that don't have this callback also don't
      manage the thread's last_status field.  */
@@ -3267,8 +3267,6 @@ queue_stop_reply_callback (thread_info *thread, void *arg)
 	  queue_stop_reply (thread->id, &thread->last_status);
 	}
     }
-
-  return 0;
 }
 
 /* Set this inferior threads's state as "want-stopped".  We won't
@@ -3324,15 +3322,6 @@ set_pending_status_callback (thread_info *thread)
     thread->status_pending_p = 1;
 }
 
-/* Callback for find_inferior.  Return true if ENTRY (a thread) has a
-   pending status to report to GDB.  */
-
-static int
-find_status_pending_thread_callback (thread_info *thread, void *data)
-{
-  return thread->status_pending_p;
-}
-
 /* Status handler for the '?' packet.  */
 
 static void
@@ -3349,7 +3338,7 @@ handle_status (char *own_buf)
 
   if (non_stop)
     {
-      find_inferior (&all_threads, queue_stop_reply_callback, NULL);
+      for_each_thread (queue_stop_reply_callback);
 
       /* The first is sent immediatly.  OK is sent if there is no
 	 stopped thread, which is the same handling of the vStopped
@@ -3382,8 +3371,10 @@ handle_status (char *own_buf)
       /* If the last event thread is not found for some reason, look
 	 for some other thread that might have an event to report.  */
       if (thread == NULL)
-	thread = find_inferior (&all_threads,
-				find_status_pending_thread_callback, NULL);
+	thread = find_thread ([] (thread_info *thread)
+	  {
+	    return thread->status_pending_p;
+	  });
 
       /* If we're still out of luck, simply pick the first thread in
 	 the thread list.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]