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 usage of find_inferior in resume


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

commit eaddb425928bb4ae21c0c6644b4bedf3d16cb6fa
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Fri Oct 27 23:43:11 2017 -0400

    Remove usage of find_inferior in resume
    
    Change find_inferior with find_thread.  Since we can now pass arguments
    directly instead of through a void pointer, we don't need the
    visit_actioned_threads_data structure anymore.
    
    gdb/gdbserver/ChangeLog:
    
    	* server.c (struct visit_actioned_threads_data): Remove.
    	(visit_actioned_threads): Change prototype to take arguments
    	directly.
    	(resume): Use find_thread instead of find_inferior.

Diff:
---
 gdb/gdbserver/ChangeLog |  7 +++++++
 gdb/gdbserver/server.c  | 43 ++++++++++++++++---------------------------
 2 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 87d870e..72201f1 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,12 @@
 2017-10-27  Simon Marchi  <simon.marchi@ericsson.com>
 
+	* server.c (struct visit_actioned_threads_data): Remove.
+	(visit_actioned_threads): Change prototype to take arguments
+	directly.
+	(resume): Use find_thread instead of find_inferior.
+
+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.
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 650cf1c..e827b9c 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2677,31 +2677,18 @@ static void resume (struct thread_resume *actions, size_t n);
 typedef int (visit_actioned_threads_callback_ftype)
   (const struct thread_resume *, struct thread_info *);
 
-/* Struct to pass data to visit_actioned_threads.  */
-
-struct visit_actioned_threads_data
-{
-  const struct thread_resume *actions;
-  size_t num_actions;
-  visit_actioned_threads_callback_ftype *callback;
-};
-
 /* Call CALLBACK for any thread to which ACTIONS applies to.  Returns
    true if CALLBACK returns true.  Returns false if no matching thread
    is found or CALLBACK results false.
-   Note: This function is itself a callback for find_inferior.  */
+   Note: This function is itself a callback for find_thread.  */
 
-static int
-visit_actioned_threads (thread_info *thread, void *datap)
+static bool
+visit_actioned_threads (thread_info *thread,
+			const struct thread_resume *actions,
+			size_t num_actions,
+			visit_actioned_threads_callback_ftype *callback)
 {
-  struct visit_actioned_threads_data *data
-    = (struct visit_actioned_threads_data *) datap;
-  const struct thread_resume *actions = data->actions;
-  size_t num_actions = data->num_actions;
-  visit_actioned_threads_callback_ftype *callback = data->callback;
-  size_t i;
-
-  for (i = 0; i < num_actions; i++)
+  for (size_t i = 0; i < num_actions; i++)
     {
       const struct thread_resume *action = &actions[i];
 
@@ -2712,11 +2699,11 @@ visit_actioned_threads (thread_info *thread, void *datap)
 	      && ptid_get_lwp (action->thread) == -1))
 	{
 	  if ((*callback) (action, thread))
-	    return 1;
+	    return true;
 	}
     }
 
-  return 0;
+  return false;
 }
 
 /* Callback for visit_actioned_threads.  If the thread has a pending
@@ -2858,12 +2845,14 @@ resume (struct thread_resume *actions, size_t num_actions)
 	 one with a pending status to report.  If so, skip actually
 	 resuming/stopping and report the pending event
 	 immediately.  */
-      struct visit_actioned_threads_data data;
 
-      data.actions = actions;
-      data.num_actions = num_actions;
-      data.callback = handle_pending_status;
-      if (find_inferior (&all_threads, visit_actioned_threads, &data) != NULL)
+      thread_info *thread_with_status = find_thread ([&] (thread_info *thread)
+	{
+	  return visit_actioned_threads (thread, actions, num_actions,
+					 handle_pending_status);
+	});
+
+      if (thread_with_status != NULL)
 	return;
 
       enable_async_io ();


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