public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 03/11] Remove usages of find_inferior in linux-arm-low.c
Date: Fri, 17 Nov 2017 18:34:00 -0000	[thread overview]
Message-ID: <1510943613-18598-4-git-send-email-simon.marchi@ericsson.com> (raw)
In-Reply-To: <1510943613-18598-1-git-send-email-simon.marchi@ericsson.com>

Replace two usages with the overload of for_each_thread that filters on
pid.  It allows to simplify the callback a little bit.

gdb/gdbserver/ChangeLog:

	* linux-arm-low.c (struct update_registers_data): Remove.
	(update_registers_callback): Return void, take arguments
	directly, don't check thread's pid.
	(arm_insert_point, arm_remove_point): Use for_each_thread.
---
 gdb/gdbserver/linux-arm-low.c | 55 ++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 29 deletions(-)

diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 3fddec6..f2c030d 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -460,35 +460,22 @@ arm_linux_hw_point_initialize (enum raw_bkpt_type raw_type, CORE_ADDR addr,
 /* Callback to mark a watch-/breakpoint to be updated in all threads of
    the current process.  */
 
-struct update_registers_data
-{
-  int watch;
-  int i;
-};
-
-static int
-update_registers_callback (thread_info *thread, void *arg)
+static void
+update_registers_callback (thread_info *thread, int watch, int i)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
-  struct update_registers_data *data = (struct update_registers_data *) arg;
-
-  /* Only update the threads of the current process.  */
-  if (pid_of (thread) == pid_of (current_thread))
-    {
-      /* The actual update is done later just before resuming the lwp,
-         we just mark that the registers need updating.  */
-      if (data->watch)
-	lwp->arch_private->wpts_changed[data->i] = 1;
-      else
-	lwp->arch_private->bpts_changed[data->i] = 1;
 
-      /* If the lwp isn't stopped, force it to momentarily pause, so
-         we can update its breakpoint registers.  */
-      if (!lwp->stopped)
-        linux_stop_lwp (lwp);
-    }
+  /* The actual update is done later just before resuming the lwp,
+     we just mark that the registers need updating.  */
+  if (watch)
+    lwp->arch_private->wpts_changed[i] = 1;
+  else
+    lwp->arch_private->bpts_changed[i] = 1;
 
-  return 0;
+  /* If the lwp isn't stopped, force it to momentarily pause, so
+     we can update its breakpoint registers.  */
+  if (!lwp->stopped)
+    linux_stop_lwp (lwp);
 }
 
 static int
@@ -538,9 +525,14 @@ arm_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
   for (i = 0; i < count; i++)
     if (!arm_hwbp_control_is_enabled (pts[i].control))
       {
-	struct update_registers_data data = { watch, i };
 	pts[i] = p;
-	find_inferior (&all_threads, update_registers_callback, &data);
+
+	/* Only update the threads of the current process.  */
+	for_each_thread (current_thread->id.pid (), [&] (thread_info *thread)
+	  {
+	    update_registers_callback (thread, watch, i);
+	  });
+
 	return 0;
       }
 
@@ -578,9 +570,14 @@ arm_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
   for (i = 0; i < count; i++)
     if (arm_linux_hw_breakpoint_equal (&p, pts + i))
       {
-	struct update_registers_data data = { watch, i };
 	pts[i].control = arm_hwbp_control_disable (pts[i].control);
-	find_inferior (&all_threads, update_registers_callback, &data);
+
+	/* Only update the threads of the current process.  */
+	for_each_thread (current_thread->id.pid (), [&] (thread_info *thread)
+	  {
+	    update_registers_callback (thread, watch, i);
+	  });
+
 	return 0;
       }
 
-- 
2.7.4

  parent reply	other threads:[~2017-11-17 18:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 18:33 [PATCH 00/11] Remove some usages of find_inferior Simon Marchi
2017-11-17 18:34 ` [PATCH 08/11] Remove usage of find_inferior when calling linux_set_resume_request Simon Marchi
2017-11-17 18:34 ` [PATCH 06/11] Remove usage of find_inferior in unsuspend_all_lwps Simon Marchi
2017-11-17 18:34 ` [PATCH 07/11] Remove usage of find_inferior in linux_stabilize_threads Simon Marchi
2017-11-17 18:34 ` [PATCH 04/11] Remove usage of find_inferior in reset_lwp_ptrace_options_callback Simon Marchi
2017-11-17 18:34 ` Simon Marchi [this message]
2017-11-17 18:34 ` [PATCH 11/11] Remove usage of find_inferior when calling kill_one_lwp_callback Simon Marchi
2017-11-17 18:34 ` [PATCH 09/11] Remove usage of find_thread when calling resume_status_pending_p Simon Marchi
2017-11-17 18:34 ` [PATCH 10/11] Remove usages of find_thread when calling need_step_over_p Simon Marchi
2017-11-17 18:34 ` [PATCH 01/11] Remove usage of find_inferior in win32-i386-low.c Simon Marchi
2017-11-17 18:34 ` [PATCH 02/11] Remove usage of find_inferior in win32-low.c Simon Marchi
2017-11-17 18:34 ` [PATCH 05/11] Remove usage of find_inferior in iterate_over_lwps Simon Marchi
2017-11-19 19:21 ` [PATCH 00/11] Remove some usages of find_inferior Sergio Durigan Junior
2017-11-20  3:24   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1510943613-18598-4-git-send-email-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).