public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 03/13] Remove some comments in debug_reg_change_callback
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (2 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 07/13] Make aarch64_notify_debug_reg_change the same on GDB and GDBserver Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 12/13] Move aarch64_linux_prepare_to_resume to nat/aarch64-linux.c Yao Qi
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (debug_reg_change_callback): Remove comments.
---
 gdb/gdbserver/linux-aarch64-low.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 8b59eab..a8c2a24 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -276,26 +276,6 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 	      && (idx <= (is_watchpoint ? aarch64_num_wp_regs
 			  : aarch64_num_bp_regs)));
 
-  /* The following assertion is not right, as there can be changes
-     that have not been made to the hardware debug registers
-     before new changes overwrite the old ones.  This can happen,
-     for instance, when the breakpoint/watchpoint hit one of the
-     threads and the user enters continue; then what happens is:
-     1) all breakpoints/watchpoints are removed for all threads;
-     2) a single step is carried out for the thread that was hit;
-     3) all of the points are inserted again for all threads;
-     4) all threads are resumed.
-     The 2nd step will only affect the one thread in which the
-     bp/wp was hit, which means only that one thread is resumed;
-     remember that the actual updating only happen in
-     aarch64_linux_prepare_to_resume, so other threads remain
-     stopped during the removal and insertion of bp/wp.  Therefore
-     for those threads, the change of insertion of the bp/wp
-     overwrites that of the earlier removals.  (The situation may
-     be different when bp/wp is steppable, or in the non-stop
-     mode.)  */
-  /* gdb_assert (DR_N_HAS_CHANGED (dr_changed, idx) == 0);  */
-
   /* The actual update is done later just before resuming the lwp,
      we just mark that one register pair needs updating.  */
   DR_MARK_N_CHANGED (dr_changed, idx);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 05/13] Use phex debug_reg_change_callback
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (5 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 09/13] Move debug_reg_change_callback and aarch64_notify_debug_reg_change to nat/aarch64-linux-hw-point.c Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 06/13] Use debug_printf in debug_reg_change_callback Yao Qi
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

This patch is to use phex in debug_reg_change_callback to make it
identical in GDB and GDBserver.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (debug_reg_change_callback): Use phex.
---
 gdb/gdbserver/linux-aarch64-low.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index a8c2a24..0dfb729 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -262,10 +262,10 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
   if (show_debug_regs)
     {
       fprintf (stderr, "debug_reg_change_callback: \n\tOn entry:\n");
-      fprintf (stderr, "\tpid%d, dr_changed_bp=0x%llx, "
-	       "dr_changed_wp=0x%llx\n",
-	       pid, info->dr_changed_bp,
-	       info->dr_changed_wp);
+      fprintf (stderr, "\tpid%d, dr_changed_bp=0x%s, "
+	       "dr_changed_wp=0x%s\n",
+	       pid, phex (info->dr_changed_bp, 8),
+	       phex (info->dr_changed_wp, 8));
     }
 
   dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp
@@ -288,10 +288,10 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 
   if (show_debug_regs)
     {
-      fprintf (stderr, "\tOn exit:\n\tpid%d, dr_changed_bp=0x%llx, "
-	       "dr_changed_wp=0x%llx\n",
-	       pid, info->dr_changed_bp,
-	       info->dr_changed_wp);
+      fprintf (stderr, "\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
+	       "dr_changed_wp=0x%s\n",
+	       pid, phex (info->dr_changed_bp, 8),
+	       phex (info->dr_changed_wp, 8));
     }
 
   return 0;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 13/13] Move aarch64_linux_new_thread to nat/aarch64-linux.c
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (11 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 08/13] Make debug_reg_change_callback " Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-25 10:43 ` [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

This patch moves aarch64_linux_new_thread in GDB and GDBserver to
nat/aarch64-linux.c.

gdb:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_new_thread): Move it to ...
	* nat/aarch64-linux.c (aarch64_linux_new_thread): ... here.
	* nat/aarch64-linux.h (aarch64_linux_new_thread): Declare.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_linux_new_thread): Remove.
---
 gdb/aarch64-linux-nat.c           | 13 -------------
 gdb/gdbserver/linux-aarch64-low.c | 16 ----------------
 gdb/nat/aarch64-linux.c           | 16 ++++++++++++++++
 gdb/nat/aarch64-linux.h           |  2 ++
 4 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index ca696ed..49dc649 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -426,19 +426,6 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
 			  AARCH64_LINUX_SIZEOF_FPREGSET);
 }
 
-static void
-aarch64_linux_new_thread (struct lwp_info *lp)
-{
-  struct arch_lwp_info *info = XCNEW (struct arch_lwp_info);
-
-  /* Mark that all the hardware breakpoint/watchpoint register pairs
-     for this thread need to be initialized.  */
-  DR_MARK_ALL_CHANGED (info->dr_changed_bp, aarch64_num_bp_regs);
-  DR_MARK_ALL_CHANGED (info->dr_changed_wp, aarch64_num_wp_regs);
-
-  lp->arch_private = info;
-}
-
 /* linux_nat_new_fork hook.   */
 
 static void
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index d35d4e9..dbe4951 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -438,22 +438,6 @@ aarch64_linux_new_process (void)
   return info;
 }
 
-/* Implementation of linux_target_ops method "linux_new_thread".  */
-
-static void
-aarch64_linux_new_thread (struct lwp_info *lwp)
-{
-  struct arch_lwp_info *info = xcalloc (1, sizeof (*info));
-
-  /* Mark that all the hardware breakpoint/watchpoint register pairs
-     for this thread need to be initialized (with data from
-     aarch_process_info.debug_reg_state).  */
-  DR_MARK_ALL_CHANGED (info->dr_changed_bp, aarch64_num_bp_regs);
-  DR_MARK_ALL_CHANGED (info->dr_changed_wp, aarch64_num_wp_regs);
-
-  lwp->arch_private = info;
-}
-
 /* Implementation of linux_target_ops method "linux_new_fork".  */
 
 static void
diff --git a/gdb/nat/aarch64-linux.c b/gdb/nat/aarch64-linux.c
index 7b4ead7..121542a 100644
--- a/gdb/nat/aarch64-linux.c
+++ b/gdb/nat/aarch64-linux.c
@@ -62,3 +62,19 @@ aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
 	}
     }
 }
+
+/* Function to call when a new thread is detected.  */
+
+void
+aarch64_linux_new_thread (struct lwp_info *lwp)
+{
+  struct arch_lwp_info *info = xcalloc (1, sizeof (*info));
+
+  /* Mark that all the hardware breakpoint/watchpoint register pairs
+     for this thread need to be initialized (with data from
+     aarch_process_info.debug_reg_state).  */
+  DR_MARK_ALL_CHANGED (info->dr_changed_bp, aarch64_num_bp_regs);
+  DR_MARK_ALL_CHANGED (info->dr_changed_wp, aarch64_num_wp_regs);
+
+  lwp_set_arch_private_info (lwp, info);
+}
diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h
index cf4e468..5cb432c 100644
--- a/gdb/nat/aarch64-linux.h
+++ b/gdb/nat/aarch64-linux.h
@@ -21,4 +21,6 @@
 
 void aarch64_linux_prepare_to_resume (struct lwp_info *lwp);
 
+void aarch64_linux_new_thread (struct lwp_info *lwp);
+
 #endif /* AARCH64_LINUX_H */
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 01/13] [gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (8 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 04/13] Get pid rather than lwpid Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 11/13] Make aarch64_linux_prepare_to_resume the same on GDB and GDBserver Yao Qi
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

This patch makes more bits on aarch64 watchpoint between GDB and GDBserver
look similar.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_dr_update_callback_param) <pid>:
	Remove.
	(debug_reg_change_callback): Remove argument entry and add argument
	lwp.  Remove local variable thread.  Don't print thread id in the
	debugging output.  Don't check whether pid of thread equals to pid.
	(aarch64_notify_debug_reg_change): Don't set param.pid.  Call
	iterate_over_lwps instead find_inferior.
---
 gdb/gdbserver/linux-aarch64-low.c | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index da472ae..d39a54f 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -236,25 +236,23 @@ aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state)
 
 struct aarch64_dr_update_callback_param
 {
-  int pid;
   int is_watchpoint;
   unsigned int idx;
 };
 
-/* Callback function which records the information about the change of
-   one hardware breakpoint/watchpoint setting for the thread ENTRY.
+/* Callback for iterate_over_lwps.  Records the
+   information about the change of one hardware breakpoint/watchpoint
+   setting for the thread LWP.
    The information is passed in via PTR.
    N.B.  The actual updating of hardware debug registers is not
    carried out until the moment the thread is resumed.  */
 
 static int
-debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr)
+debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 {
-  struct thread_info *thread = (struct thread_info *) entry;
-  struct lwp_info *lwp = get_thread_lwp (thread);
   struct aarch64_dr_update_callback_param *param_p
     = (struct aarch64_dr_update_callback_param *) ptr;
-  int pid = param_p->pid;
+  int pid = pid_of (lwp->thread);
   int idx = param_p->idx;
   int is_watchpoint = param_p->is_watchpoint;
   struct arch_lwp_info *info = lwp->arch_private;
@@ -264,9 +262,9 @@ debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr)
   if (show_debug_regs)
     {
       fprintf (stderr, "debug_reg_change_callback: \n\tOn entry:\n");
-      fprintf (stderr, "\tpid%d, tid: %ld, dr_changed_bp=0x%llx, "
+      fprintf (stderr, "\tpid%d, dr_changed_bp=0x%llx, "
 	       "dr_changed_wp=0x%llx\n",
-	       pid, lwpid_of (thread), info->dr_changed_bp,
+	       pid, info->dr_changed_bp,
 	       info->dr_changed_wp);
     }
 
@@ -274,9 +272,6 @@ debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr)
     : &info->dr_changed_bp;
   dr_changed = *dr_changed_ptr;
 
-  /* Only update the threads of this process.  */
-  if (pid_of (thread) == pid)
-    {
       gdb_assert (idx >= 0
 		  && (idx <= (is_watchpoint ? aarch64_num_wp_regs
 			      : aarch64_num_bp_regs)));
@@ -310,13 +305,12 @@ debug_reg_change_callback (struct inferior_list_entry *entry, void *ptr)
          we can update its debug registers.  */
       if (!lwp->stopped)
 	linux_stop_lwp (lwp);
-    }
 
   if (show_debug_regs)
     {
-      fprintf (stderr, "\tOn exit:\n\tpid%d, tid: %ld, dr_changed_bp=0x%llx, "
+      fprintf (stderr, "\tOn exit:\n\tpid%d, dr_changed_bp=0x%llx, "
 	       "dr_changed_wp=0x%llx\n",
-	       pid, lwpid_of (thread), info->dr_changed_bp,
+	       pid, info->dr_changed_bp,
 	       info->dr_changed_wp);
     }
 
@@ -333,14 +327,12 @@ aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
 				 int is_watchpoint, unsigned int idx)
 {
   struct aarch64_dr_update_callback_param param;
-
-  /* Only update the threads of this process.  */
-  param.pid = pid_of (current_thread);
+  ptid_t pid_ptid = pid_to_ptid (pid_of (current_thread));
 
   param.is_watchpoint = is_watchpoint;
   param.idx = idx;
 
-  find_inferior (&all_threads, debug_reg_change_callback, (void *) &param);
+  iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) &param);
 }
 
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver
@ 2015-08-18 15:53 Yao Qi
  2015-08-18 15:53 ` [PATCH 02/13] Re-indent the code Yao Qi
                   ` (13 more replies)
  0 siblings, 14 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

This patch series makes more aarch64-linux code shared between GDB and
GDBserver.  These shared code are about HW watchpoint handling and
aarch64_linux_new_thread.  The first several small patches make code
in two sides identical, and then the following patches move them into
nat/ directory.

The while series is tested aarch64-linux.

*** BLURB HERE ***

Yao Qi (13):
  [gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change
  Re-indent the code
  Remove some comments in debug_reg_change_callback
  Get pid rather than lwpid
  Use phex debug_reg_change_callback
  Use debug_printf in debug_reg_change_callback
  Make aarch64_notify_debug_reg_change the same on GDB and GDBserver
  Make debug_reg_change_callback the same on GDB and GDBserver
  Move debug_reg_change_callback and aarch64_notify_debug_reg_change to
    nat/aarch64-linux-hw-point.c
  Add pid argument in aarch64_get_debug_reg_state
  Make aarch64_linux_prepare_to_resume the same on GDB and GDBserver
  Move aarch64_linux_prepare_to_resume to nat/aarch64-linux.c
  Move aarch64_linux_new_thread to nat/aarch64-linux.c

 gdb/Makefile.in                   |   6 +-
 gdb/aarch64-linux-nat.c           | 144 +----------------------------
 gdb/config/aarch64/linux.mh       |   3 +-
 gdb/gdbserver/Makefile.in         |   3 +
 gdb/gdbserver/configure.srv       |   1 +
 gdb/gdbserver/linux-aarch64-low.c | 188 +++-----------------------------------
 gdb/nat/aarch64-linux-hw-point.c  |  88 ++++++++++++++++++
 gdb/nat/aarch64-linux-hw-point.h  |   5 +-
 gdb/nat/aarch64-linux.c           |  80 ++++++++++++++++
 gdb/nat/aarch64-linux.h           |  26 ++++++
 10 files changed, 222 insertions(+), 322 deletions(-)
 create mode 100644 gdb/nat/aarch64-linux.c
 create mode 100644 gdb/nat/aarch64-linux.h

-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 08/13] Make debug_reg_change_callback the same on GDB and GDBserver
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (10 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 11/13] Make aarch64_linux_prepare_to_resume the same on GDB and GDBserver Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 13/13] Move aarch64_linux_new_thread to nat/aarch64-linux.c Yao Qi
  2015-08-25 10:43 ` [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

This patch makes function debug_reg_change_callback in GDB and GDBserver
look the same, so that the following patch can move them to
nat/aarch64-linux-hw-point.c.

gdb:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (debug_reg_change_callback): Use
	ptid_of_lwp to get ptid of lwp.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (debug_reg_change_callback): Use
	ptid_of_lwp to get ptid of lwp.
---
 gdb/aarch64-linux-nat.c           | 2 +-
 gdb/gdbserver/linux-aarch64-low.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index aacc189..6594489 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -165,7 +165,7 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 {
   struct aarch64_dr_update_callback_param *param_p
     = (struct aarch64_dr_update_callback_param *) ptr;
-  int pid = ptid_get_pid (lwp->ptid);
+  int pid = ptid_get_pid (ptid_of_lwp (lwp));
   int idx = param_p->idx;
   int is_watchpoint = param_p->is_watchpoint;
   struct arch_lwp_info *info = lwp->arch_private;
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index bfff7e4..4c482a9 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -252,7 +252,7 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 {
   struct aarch64_dr_update_callback_param *param_p
     = (struct aarch64_dr_update_callback_param *) ptr;
-  int pid = pid_of (lwp->thread);
+  int pid = ptid_get_pid (ptid_of_lwp (lwp));
   int idx = param_p->idx;
   int is_watchpoint = param_p->is_watchpoint;
   struct arch_lwp_info *info = lwp->arch_private;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 11/13] Make aarch64_linux_prepare_to_resume the same on GDB and GDBserver
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (9 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 01/13] [gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 08/13] Make debug_reg_change_callback " Yao Qi
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

gdb:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_prepare_to_resume): Use
	lwp_arch_private_info and ptid_of_lwp.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_linux_prepare_to_resume): Use
	lwp_arch_private_info and ptid_of_lwp.
---
 gdb/aarch64-linux-nat.c           |  7 ++++---
 gdb/gdbserver/linux-aarch64-low.c | 10 ++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 1b3ed57..e3baae5 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -431,7 +431,7 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
 static void
 aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
 {
-  struct arch_lwp_info *info = lwp->arch_private;
+  struct arch_lwp_info *info = lwp_arch_private_info (lwp);
 
   /* NULL means this is the main thread still going through the shell,
      or, no watchpoint has been set yet.  In that case, there's
@@ -442,9 +442,10 @@ aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
   if (DR_HAS_CHANGED (info->dr_changed_bp)
       || DR_HAS_CHANGED (info->dr_changed_wp))
     {
-      int tid = ptid_get_lwp (lwp->ptid);
+      ptid_t ptid = ptid_of_lwp (lwp);
+      int tid = ptid_get_lwp (ptid);
       struct aarch64_debug_reg_state *state
-	= aarch64_get_debug_reg_state (ptid_get_pid (lwp->ptid));
+	= aarch64_get_debug_reg_state (ptid_get_pid (ptid));
 
       if (show_debug_regs)
 	fprintf_unfiltered (gdb_stdlog, "prepare_to_resume thread %d\n", tid);
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 421dcb9..4b1d7d5 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -489,20 +489,18 @@ aarch64_linux_new_fork (struct process_info *parent,
 static void
 aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
 {
-  struct thread_info *thread = get_lwp_thread (lwp);
-  ptid_t ptid = ptid_of (thread);
-  struct arch_lwp_info *info = lwp->arch_private;
+  struct arch_lwp_info *info = lwp_arch_private_info (lwp);
 
   if (DR_HAS_CHANGED (info->dr_changed_bp)
       || DR_HAS_CHANGED (info->dr_changed_wp))
     {
+      ptid_t ptid = ptid_of_lwp (lwp);
       int tid = ptid_get_lwp (ptid);
-      struct process_info *proc = find_process_pid (ptid_get_pid (ptid));
       struct aarch64_debug_reg_state *state
-	= &proc->priv->arch_private->debug_reg_state;
+	= aarch64_get_debug_reg_state (ptid_get_pid (ptid));
 
       if (show_debug_regs)
-	fprintf (stderr, "prepare_to_resume thread %ld\n", lwpid_of (thread));
+	fprintf (stderr, "prepare_to_resume thread %d\n", tid);
 
       /* Watchpoints.  */
       if (DR_HAS_CHANGED (info->dr_changed_wp))
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 09/13] Move debug_reg_change_callback and aarch64_notify_debug_reg_change to nat/aarch64-linux-hw-point.c
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (4 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 12/13] Move aarch64_linux_prepare_to_resume to nat/aarch64-linux.c Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 05/13] Use phex debug_reg_change_callback Yao Qi
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

gdb:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (struct arch64_dr_update_callback_param):
	Move it to nat/aarch64-linux-hw-point.c.
	(debug_reg_change_callback): Likewise.
	(aarch64_notify_debug_reg_change): :Likewise.
	* nat/aarch64-linux-hw-point.c: Include nat/linux-nat.h.
	(aarch64_dr_update_callback_param): New.
	(debug_reg_change_callback): New function.
	(aarch64_notify_debug_reg_change): Likewise.
	* nat/aarch64-linux-hw-point.h (aarch64_notify_debug_reg_change):
	Remove the declaration.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (struct arch64_dr_update_callback_param):
	Remove.
	(debug_reg_change_callback): Remove.
	(aarch64_notify_debug_reg_change): Remove.
---
 gdb/aarch64-linux-nat.c           | 85 -------------------------------------
 gdb/gdbserver/linux-aarch64-low.c | 82 ------------------------------------
 gdb/nat/aarch64-linux-hw-point.c  | 88 +++++++++++++++++++++++++++++++++++++++
 gdb/nat/aarch64-linux-hw-point.h  |  3 --
 4 files changed, 88 insertions(+), 170 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 6594489..1b3ed57 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -147,91 +147,6 @@ aarch64_get_debug_reg_state (pid_t pid)
   return &aarch64_process_info_get (pid)->state;
 }
 
-struct aarch64_dr_update_callback_param
-{
-  int is_watchpoint;
-  unsigned int idx;
-};
-
-/* Callback for iterate_over_lwps.  Records the
-   information about the change of one hardware breakpoint/watchpoint
-   setting for the thread LWP.
-   The information is passed in via PTR.
-   N.B.  The actual updating of hardware debug registers is not
-   carried out until the moment the thread is resumed.  */
-
-static int
-debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
-{
-  struct aarch64_dr_update_callback_param *param_p
-    = (struct aarch64_dr_update_callback_param *) ptr;
-  int pid = ptid_get_pid (ptid_of_lwp (lwp));
-  int idx = param_p->idx;
-  int is_watchpoint = param_p->is_watchpoint;
-  struct arch_lwp_info *info = lwp->arch_private;
-  dr_changed_t *dr_changed_ptr;
-  dr_changed_t dr_changed;
-
-  if (info == NULL)
-    info = lwp->arch_private = XCNEW (struct arch_lwp_info);
-
-  if (show_debug_regs)
-    {
-      debug_printf ("debug_reg_change_callback: \n\tOn entry:\n");
-      debug_printf ("\tpid%d, dr_changed_bp=0x%s, "
-		    "dr_changed_wp=0x%s\n", pid,
-		    phex (info->dr_changed_bp, 8),
-		    phex (info->dr_changed_wp, 8));
-    }
-
-  dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp
-    : &info->dr_changed_bp;
-  dr_changed = *dr_changed_ptr;
-
-  gdb_assert (idx >= 0
-	      && (idx <= (is_watchpoint ? aarch64_num_wp_regs
-			  : aarch64_num_bp_regs)));
-
-  /* The actual update is done later just before resuming the lwp,
-     we just mark that one register pair needs updating.  */
-  DR_MARK_N_CHANGED (dr_changed, idx);
-  *dr_changed_ptr = dr_changed;
-
-  /* If the lwp isn't stopped, force it to momentarily pause, so
-     we can update its debug registers.  */
-  if (!lwp->stopped)
-    linux_stop_lwp (lwp);
-
-  if (show_debug_regs)
-    {
-      debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
-		    "dr_changed_wp=0x%s\n", pid,
-		    phex (info->dr_changed_bp, 8),
-		    phex (info->dr_changed_wp, 8));
-    }
-
-  /* Continue the iteration.  */
-  return 0;
-}
-
-/* Notify each thread that their IDXth breakpoint/watchpoint register
-   pair needs to be updated.  The message will be recorded in each
-   thread's arch-specific data area, the actual updating will be done
-   when the thread is resumed.  */
-
-void
-aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
-				 int is_watchpoint, unsigned int idx)
-{
-  struct aarch64_dr_update_callback_param param;
-  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
-
-  param.is_watchpoint = is_watchpoint;
-  param.idx = idx;
-
-  iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) &param);
-}
-
 /* Fill GDB's register array with the general-purpose register values
    from the current thread.  */
 
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 4c482a9..3968aee 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -234,88 +234,6 @@ aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state)
     }
 }
 
-struct aarch64_dr_update_callback_param
-{
-  int is_watchpoint;
-  unsigned int idx;
-};
-
-/* Callback for iterate_over_lwps.  Records the
-   information about the change of one hardware breakpoint/watchpoint
-   setting for the thread LWP.
-   The information is passed in via PTR.
-   N.B.  The actual updating of hardware debug registers is not
-   carried out until the moment the thread is resumed.  */
-
-static int
-debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
-{
-  struct aarch64_dr_update_callback_param *param_p
-    = (struct aarch64_dr_update_callback_param *) ptr;
-  int pid = ptid_get_pid (ptid_of_lwp (lwp));
-  int idx = param_p->idx;
-  int is_watchpoint = param_p->is_watchpoint;
-  struct arch_lwp_info *info = lwp->arch_private;
-  dr_changed_t *dr_changed_ptr;
-  dr_changed_t dr_changed;
-
-  if (show_debug_regs)
-    {
-      debug_printf ("debug_reg_change_callback: \n\tOn entry:\n");
-      debug_printf ("\tpid%d, dr_changed_bp=0x%s, "
-		    "dr_changed_wp=0x%s\n", pid,
-		    phex (info->dr_changed_bp, 8),
-		    phex (info->dr_changed_wp, 8));
-    }
-
-  dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp
-    : &info->dr_changed_bp;
-  dr_changed = *dr_changed_ptr;
-
-  gdb_assert (idx >= 0
-	      && (idx <= (is_watchpoint ? aarch64_num_wp_regs
-			  : aarch64_num_bp_regs)));
-
-  /* The actual update is done later just before resuming the lwp,
-     we just mark that one register pair needs updating.  */
-  DR_MARK_N_CHANGED (dr_changed, idx);
-  *dr_changed_ptr = dr_changed;
-
-  /* If the lwp isn't stopped, force it to momentarily pause, so
-     we can update its debug registers.  */
-  if (!lwp->stopped)
-    linux_stop_lwp (lwp);
-
-  if (show_debug_regs)
-    {
-      debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
-		    "dr_changed_wp=0x%s\n", pid,
-		    phex (info->dr_changed_bp, 8),
-		    phex (info->dr_changed_wp, 8));
-    }
-
-  return 0;
-}
-
-/* Notify each thread that their IDXth breakpoint/watchpoint register
-   pair needs to be updated.  The message will be recorded in each
-   thread's arch-specific data area, the actual updating will be done
-   when the thread is resumed.  */
-
-void
-aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
-				 int is_watchpoint, unsigned int idx)
-{
-  struct aarch64_dr_update_callback_param param;
-  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
-
-  param.is_watchpoint = is_watchpoint;
-  param.idx = idx;
-
-  iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) &param);
-}
-
-
 /* Return the pointer to the debug register state structure in the
    current process' arch-specific data area.  */
 
diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
index 1d9664e..ba235e5 100644
--- a/gdb/nat/aarch64-linux-hw-point.c
+++ b/gdb/nat/aarch64-linux-hw-point.c
@@ -18,6 +18,7 @@
 
 #include "common-defs.h"
 #include "break-common.h"
+#include "nat/linux-nat.h"
 #include "aarch64-linux-hw-point.h"
 
 #include <sys/uio.h>
@@ -220,6 +221,93 @@ aarch64_align_watchpoint (CORE_ADDR addr, int len, CORE_ADDR *aligned_addr_p,
     *next_len_p = len;
 }
 
+struct aarch64_dr_update_callback_param
+{
+  int is_watchpoint;
+  unsigned int idx;
+};
+
+/* Callback for iterate_over_lwps.  Records the
+   information about the change of one hardware breakpoint/watchpoint
+   setting for the thread LWP.
+   The information is passed in via PTR.
+   N.B.  The actual updating of hardware debug registers is not
+   carried out until the moment the thread is resumed.  */
+
+static int
+debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
+{
+  struct aarch64_dr_update_callback_param *param_p
+    = (struct aarch64_dr_update_callback_param *) ptr;
+  int pid = ptid_get_pid (ptid_of_lwp (lwp));
+  int idx = param_p->idx;
+  int is_watchpoint = param_p->is_watchpoint;
+  struct arch_lwp_info *info = lwp_arch_private_info (lwp);
+  dr_changed_t *dr_changed_ptr;
+  dr_changed_t dr_changed;
+
+  if (info == NULL)
+    {
+      info = XCNEW (struct arch_lwp_info);
+      lwp_set_arch_private_info (lwp, info);
+    }
+
+  if (show_debug_regs)
+    {
+      debug_printf ("debug_reg_change_callback: \n\tOn entry:\n");
+      debug_printf ("\tpid%d, dr_changed_bp=0x%s, "
+		    "dr_changed_wp=0x%s\n", pid,
+		    phex (info->dr_changed_bp, 8),
+		    phex (info->dr_changed_wp, 8));
+    }
+
+  dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp
+    : &info->dr_changed_bp;
+  dr_changed = *dr_changed_ptr;
+
+  gdb_assert (idx >= 0
+	      && (idx <= (is_watchpoint ? aarch64_num_wp_regs
+			  : aarch64_num_bp_regs)));
+
+  /* The actual update is done later just before resuming the lwp,
+     we just mark that one register pair needs updating.  */
+  DR_MARK_N_CHANGED (dr_changed, idx);
+  *dr_changed_ptr = dr_changed;
+
+  /* If the lwp isn't stopped, force it to momentarily pause, so
+     we can update its debug registers.  */
+  if (!lwp_is_stopped (lwp))
+    linux_stop_lwp (lwp);
+
+  if (show_debug_regs)
+    {
+      debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
+		    "dr_changed_wp=0x%s\n", pid,
+		    phex (info->dr_changed_bp, 8),
+		    phex (info->dr_changed_wp, 8));
+    }
+
+  return 0;
+}
+
+/* Notify each thread that their IDXth breakpoint/watchpoint register
+   pair needs to be updated.  The message will be recorded in each
+   thread's arch-specific data area, the actual updating will be done
+   when the thread is resumed.  */
+
+static void
+aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
+				 int is_watchpoint, unsigned int idx)
+{
+  struct aarch64_dr_update_callback_param param;
+  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
+
+  param.is_watchpoint = is_watchpoint;
+  param.idx = idx;
+
+  iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) &param);
+}
+
 /* Record the insertion of one breakpoint/watchpoint, as represented
    by ADDR and CTRL, in the process' arch-specific data area *STATE.  */
 
diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h
index a430a8f..17cc420 100644
--- a/gdb/nat/aarch64-linux-hw-point.h
+++ b/gdb/nat/aarch64-linux-hw-point.h
@@ -171,9 +171,6 @@ int aarch64_handle_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr,
 			       int len, int is_insert,
 			       struct aarch64_debug_reg_state *state);
 
-void aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
-				      int is_watchpoint, unsigned int idx);
-
 void aarch64_linux_set_debug_regs (const struct aarch64_debug_reg_state *state,
 				   int tid, int watchpoint);
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 07/13] Make aarch64_notify_debug_reg_change the same on GDB and GDBserver
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
  2015-08-18 15:53 ` [PATCH 02/13] Re-indent the code Yao Qi
  2015-08-18 15:53 ` [PATCH 10/13] Add pid argument in aarch64_get_debug_reg_state Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 03/13] Remove some comments in debug_reg_change_callback Yao Qi
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

gdb:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_notify_debug_reg_change):
	Call current_lwp_ptid.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_notify_debug_reg_change):
	Call current_lwp_ptid.
---
 gdb/aarch64-linux-nat.c           | 2 +-
 gdb/gdbserver/linux-aarch64-low.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 4ccbe9e..aacc189 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -224,7 +224,7 @@ aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
 				 int is_watchpoint, unsigned int idx)
 {
   struct aarch64_dr_update_callback_param param;
-  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
 
   param.is_watchpoint = is_watchpoint;
   param.idx = idx;
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 0ca2b0b..bfff7e4 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -307,7 +307,7 @@ aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
 				 int is_watchpoint, unsigned int idx)
 {
   struct aarch64_dr_update_callback_param param;
-  ptid_t pid_ptid = pid_to_ptid (pid_of (current_thread));
+  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
 
   param.is_watchpoint = is_watchpoint;
   param.idx = idx;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 12/13] Move aarch64_linux_prepare_to_resume to nat/aarch64-linux.c
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (3 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 03/13] Remove some comments in debug_reg_change_callback Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 09/13] Move debug_reg_change_callback and aarch64_notify_debug_reg_change to nat/aarch64-linux-hw-point.c Yao Qi
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

gdb:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (aarch64-liunx.o): New rule.
	(HFILES_NO_SRCDIR): Add aarch64-linux.h.
	* config/aarch64/linux.mh (NAT_FILE): Add aarch64-linux.o.
	* aarch64-linux-nat.c: Include nat/aarch64-linux.h.
	* aarch64-linux-nat.c (aarch64_get_debug_reg_state): Make it
	extern.
	(aarch64_linux_prepare_to_resume): Move it nat/aarch64-linux.c.
	* nat/aarch64-linux-hw-point.h (aarch64_debug_reg_state): Declare
	* nat/aarch64-linux.c: New file.
	* nat/aarch64-linux.h: New file.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (aarch64-linux.o): New rule.
	* configure.srv (aarch64*-*-linux*): Append aarch64-linux.o to
	srv_tgtobj.
	* linux-aarch64-low.c: Include nat/aarch64-linux.h.
	(aarch64_init_debug_reg_state): Make it extern.
	(aarch64_linux_prepare_to_resume): Remove.
---
 gdb/Makefile.in                   |  6 +++-
 gdb/aarch64-linux-nat.c           | 44 ++-------------------------
 gdb/config/aarch64/linux.mh       |  3 +-
 gdb/gdbserver/Makefile.in         |  3 ++
 gdb/gdbserver/configure.srv       |  1 +
 gdb/gdbserver/linux-aarch64-low.c | 39 ++----------------------
 gdb/nat/aarch64-linux-hw-point.h  |  2 ++
 gdb/nat/aarch64-linux.c           | 64 +++++++++++++++++++++++++++++++++++++++
 gdb/nat/aarch64-linux.h           | 24 +++++++++++++++
 9 files changed, 105 insertions(+), 81 deletions(-)
 create mode 100644 gdb/nat/aarch64-linux.c
 create mode 100644 gdb/nat/aarch64-linux.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 13b9041..7634d2e 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -938,7 +938,7 @@ tui/tui-winsource.h tui/tui-regs.h tui/tui-io.h tui/tui-layout.h \
 tui/tui-source.h sol2-tdep.h gregset.h sh-tdep.h sh64-tdep.h \
 expression.h score-tdep.h gdb_select.h ser-tcp.h \
 extension.h extension-priv.h nat/aarch64-linux-hw-point.h \
-build-id.h buildsym.h valprint.h \
+build-id.h buildsym.h valprint.h nat/aarch64-linux.h \
 typeprint.h mi/mi-getopt.h mi/mi-parse.h mi/mi-console.h \
 mi/mi-out.h mi/mi-main.h mi/mi-common.h mi/mi-cmds.h linux-nat.h \
 complaints.h gdb_proc_service.h gdb_regex.h xtensa-tdep.h inf-loop.h \
@@ -2333,6 +2333,10 @@ aarch64-linux-hw-point.o: ${srcdir}/nat/aarch64-linux-hw-point.c
 	$(COMPILE) $(srcdir)/nat/aarch64-linux-hw-point.c
 	$(POSTCOMPILE)
 
+aarch64-linux.o: ${srcdir}/nat/aarch64-linux.c
+	$(COMPILE) $(srcdir)/nat/aarch64-linux.c
+	$(POSTCOMPILE)
+
 #
 # gdb/tui/ dependencies
 #
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index e3baae5..ca696ed 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -30,6 +30,7 @@
 #include "aarch64-tdep.h"
 #include "aarch64-linux-tdep.h"
 #include "aarch32-linux-nat.h"
+#include "nat/aarch64-linux.h"
 #include "nat/aarch64-linux-hw-point.h"
 
 #include "elf/external.h"
@@ -141,7 +142,7 @@ aarch64_forget_process (pid_t pid)
 
 /* Get debug registers state for process PID.  */
 
-static struct aarch64_debug_reg_state *
+struct aarch64_debug_reg_state *
 aarch64_get_debug_reg_state (pid_t pid)
 {
   return &aarch64_process_info_get (pid)->state;
@@ -425,47 +426,6 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
 			  AARCH64_LINUX_SIZEOF_FPREGSET);
 }
 
-/* Called when resuming a thread.
-   The hardware debug registers are updated when there is any change.  */
-
-static void
-aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
-{
-  struct arch_lwp_info *info = lwp_arch_private_info (lwp);
-
-  /* NULL means this is the main thread still going through the shell,
-     or, no watchpoint has been set yet.  In that case, there's
-     nothing to do.  */
-  if (info == NULL)
-    return;
-
-  if (DR_HAS_CHANGED (info->dr_changed_bp)
-      || DR_HAS_CHANGED (info->dr_changed_wp))
-    {
-      ptid_t ptid = ptid_of_lwp (lwp);
-      int tid = ptid_get_lwp (ptid);
-      struct aarch64_debug_reg_state *state
-	= aarch64_get_debug_reg_state (ptid_get_pid (ptid));
-
-      if (show_debug_regs)
-	fprintf_unfiltered (gdb_stdlog, "prepare_to_resume thread %d\n", tid);
-
-      /* Watchpoints.  */
-      if (DR_HAS_CHANGED (info->dr_changed_wp))
-	{
-	  aarch64_linux_set_debug_regs (state, tid, 1);
-	  DR_CLEAR_CHANGED (info->dr_changed_wp);
-	}
-
-      /* Breakpoints.  */
-      if (DR_HAS_CHANGED (info->dr_changed_bp))
-	{
-	  aarch64_linux_set_debug_regs (state, tid, 0);
-	  DR_CLEAR_CHANGED (info->dr_changed_bp);
-	}
-    }
-}
-
 static void
 aarch64_linux_new_thread (struct lwp_info *lp)
 {
diff --git a/gdb/config/aarch64/linux.mh b/gdb/config/aarch64/linux.mh
index 231aea1..ea56ff6 100644
--- a/gdb/config/aarch64/linux.mh
+++ b/gdb/config/aarch64/linux.mh
@@ -22,7 +22,8 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o aarch64-linux-nat.o aarch32-linux-nat.o \
 	proc-service.o linux-thread-db.o linux-nat.o linux-fork.o \
 	linux-procfs.o linux-ptrace.o linux-osdata.o linux-waitpid.o \
-	linux-personality.o linux-namespaces.o aarch64-linux-hw-point.o
+	linux-personality.o linux-namespaces.o aarch64-linux-hw-point.o \
+	aarch64-linux.o
 NAT_CDEPS = $(srcdir)/proc-service.list
 
 LOADLIBES= -ldl $(RDYNAMIC)
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 5e04e530..b715a32 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -609,6 +609,9 @@ linux-personality.o: ../nat/linux-personality.c
 aarch64-linux-hw-point.o: ../nat/aarch64-linux-hw-point.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
+aarch64-linux.o: ../nat/aarch64-linux.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
 btrace-common.o: ../common/btrace-common.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index 0b18d1d..ec950f7 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -52,6 +52,7 @@ case "${target}" in
 			srv_regobj="${srv_regobj} arm-with-neon.o"
 			srv_tgtobj="linux-aarch64-low.o aarch64-linux-hw-point.o"
 			srv_tgtobj="$srv_tgtobj linux-aarch32-low.o"
+			srv_tgtobj="$srv_tgtobj aarch64-linux.o"
 			srv_tgtobj="${srv_tgtobj} $srv_linux_obj"
 			srv_xmlfiles="aarch64.xml"
 			srv_xmlfiles="${srv_xmlfiles} aarch64-core.xml"
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 4b1d7d5..d35d4e9 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -21,6 +21,7 @@
 
 #include "server.h"
 #include "linux-low.h"
+#include "nat/aarch64-linux.h"
 #include "nat/aarch64-linux-hw-point.h"
 #include "linux-aarch32-low.h"
 #include "elf/common.h"
@@ -237,7 +238,7 @@ aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state)
 /* Return the pointer to the debug register state structure in the
    current process' arch-specific data area.  */
 
-static struct aarch64_debug_reg_state *
+struct aarch64_debug_reg_state *
 aarch64_get_debug_reg_state (pid_t pid)
 {
   struct process_info *proc = find_process_pid (pid);
@@ -482,42 +483,6 @@ aarch64_linux_new_fork (struct process_info *parent,
   *child->priv->arch_private = *parent->priv->arch_private;
 }
 
-/* Implementation of linux_target_ops method "linux_prepare_to_resume".
-
-   If the debug regs have changed, update the thread's copies.  */
-
-static void
-aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
-{
-  struct arch_lwp_info *info = lwp_arch_private_info (lwp);
-
-  if (DR_HAS_CHANGED (info->dr_changed_bp)
-      || DR_HAS_CHANGED (info->dr_changed_wp))
-    {
-      ptid_t ptid = ptid_of_lwp (lwp);
-      int tid = ptid_get_lwp (ptid);
-      struct aarch64_debug_reg_state *state
-	= aarch64_get_debug_reg_state (ptid_get_pid (ptid));
-
-      if (show_debug_regs)
-	fprintf (stderr, "prepare_to_resume thread %d\n", tid);
-
-      /* Watchpoints.  */
-      if (DR_HAS_CHANGED (info->dr_changed_wp))
-	{
-	  aarch64_linux_set_debug_regs (state, tid, 1);
-	  DR_CLEAR_CHANGED (info->dr_changed_wp);
-	}
-
-      /* Breakpoints.  */
-      if (DR_HAS_CHANGED (info->dr_changed_bp))
-	{
-	  aarch64_linux_set_debug_regs (state, tid, 0);
-	  DR_CLEAR_CHANGED (info->dr_changed_bp);
-	}
-    }
-}
-
 /* Return the right target description according to the ELF file of
    current thread.  */
 
diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h
index 17cc420..a27a201 100644
--- a/gdb/nat/aarch64-linux-hw-point.h
+++ b/gdb/nat/aarch64-linux-hw-point.h
@@ -180,4 +180,6 @@ void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
 
 void aarch64_linux_get_debug_reg_capacity (int tid);
 
+struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid);
+
 #endif /* AARCH64_LINUX_HW_POINT_H */
diff --git a/gdb/nat/aarch64-linux.c b/gdb/nat/aarch64-linux.c
new file mode 100644
index 0000000..7b4ead7
--- /dev/null
+++ b/gdb/nat/aarch64-linux.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 2009-2015 Free Software Foundation, Inc.
+   Contributed by ARM Ltd.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "common-defs.h"
+#include "break-common.h"
+#include "nat/linux-nat.h"
+#include "nat/aarch64-linux-hw-point.h"
+#include "nat/aarch64-linux.h"
+
+/* Called when resuming a thread LWP.
+   The hardware debug registers are updated when there is any change.  */
+
+void
+aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
+{
+  struct arch_lwp_info *info = lwp_arch_private_info (lwp);
+
+  /* NULL means this is the main thread still going through the shell,
+     or, no watchpoint has been set yet.  In that case, there's
+     nothing to do.  */
+  if (info == NULL)
+    return;
+
+  if (DR_HAS_CHANGED (info->dr_changed_bp)
+      || DR_HAS_CHANGED (info->dr_changed_wp))
+    {
+      ptid_t ptid = ptid_of_lwp (lwp);
+      int tid = ptid_get_lwp (ptid);
+      struct aarch64_debug_reg_state *state
+	= aarch64_get_debug_reg_state (ptid_get_pid (ptid));
+
+      if (show_debug_regs)
+	debug_printf ("prepare_to_resume thread %d\n", tid);
+
+      /* Watchpoints.  */
+      if (DR_HAS_CHANGED (info->dr_changed_wp))
+	{
+	  aarch64_linux_set_debug_regs (state, tid, 1);
+	  DR_CLEAR_CHANGED (info->dr_changed_wp);
+	}
+
+      /* Breakpoints.  */
+      if (DR_HAS_CHANGED (info->dr_changed_bp))
+	{
+	  aarch64_linux_set_debug_regs (state, tid, 0);
+	  DR_CLEAR_CHANGED (info->dr_changed_bp);
+	}
+    }
+}
diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h
new file mode 100644
index 0000000..cf4e468
--- /dev/null
+++ b/gdb/nat/aarch64-linux.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 2009-2015 Free Software Foundation, Inc.
+   Contributed by ARM Ltd.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef AARCH64_LINUX_H
+#define AARCH64_LINUX_H 1
+
+void aarch64_linux_prepare_to_resume (struct lwp_info *lwp);
+
+#endif /* AARCH64_LINUX_H */
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 06/13] Use debug_printf in debug_reg_change_callback
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (6 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 05/13] Use phex debug_reg_change_callback Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 04/13] Get pid rather than lwpid Yao Qi
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

gdb:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (debug_reg_change_callback): Use
	debug_printf.

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (debug_reg_change_callback): Use
	debug_printf.
---
 gdb/aarch64-linux-nat.c           | 21 +++++++++------------
 gdb/gdbserver/linux-aarch64-low.c | 18 +++++++++---------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index d530019..4ccbe9e 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -177,13 +177,11 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 
   if (show_debug_regs)
     {
-      fprintf_unfiltered (gdb_stdlog,
-			  "debug_reg_change_callback: \n\tOn entry:\n");
-      fprintf_unfiltered (gdb_stdlog,
-			  "\tpid%d, dr_changed_bp=0x%s, "
-			  "dr_changed_wp=0x%s\n",
-			  pid, phex (info->dr_changed_bp, 8),
-			  phex (info->dr_changed_wp, 8));
+      debug_printf ("debug_reg_change_callback: \n\tOn entry:\n");
+      debug_printf ("\tpid%d, dr_changed_bp=0x%s, "
+		    "dr_changed_wp=0x%s\n", pid,
+		    phex (info->dr_changed_bp, 8),
+		    phex (info->dr_changed_wp, 8));
     }
 
   dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp
@@ -206,11 +204,10 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 
   if (show_debug_regs)
     {
-      fprintf_unfiltered (gdb_stdlog,
-			  "\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
-			  "dr_changed_wp=0x%s\n",
-			  pid, phex (info->dr_changed_bp, 8),
-			  phex (info->dr_changed_wp, 8));
+      debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
+		    "dr_changed_wp=0x%s\n", pid,
+		    phex (info->dr_changed_bp, 8),
+		    phex (info->dr_changed_wp, 8));
     }
 
   /* Continue the iteration.  */
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 0dfb729..0ca2b0b 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -261,11 +261,11 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 
   if (show_debug_regs)
     {
-      fprintf (stderr, "debug_reg_change_callback: \n\tOn entry:\n");
-      fprintf (stderr, "\tpid%d, dr_changed_bp=0x%s, "
-	       "dr_changed_wp=0x%s\n",
-	       pid, phex (info->dr_changed_bp, 8),
-	       phex (info->dr_changed_wp, 8));
+      debug_printf ("debug_reg_change_callback: \n\tOn entry:\n");
+      debug_printf ("\tpid%d, dr_changed_bp=0x%s, "
+		    "dr_changed_wp=0x%s\n", pid,
+		    phex (info->dr_changed_bp, 8),
+		    phex (info->dr_changed_wp, 8));
     }
 
   dr_changed_ptr = is_watchpoint ? &info->dr_changed_wp
@@ -288,10 +288,10 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 
   if (show_debug_regs)
     {
-      fprintf (stderr, "\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
-	       "dr_changed_wp=0x%s\n",
-	       pid, phex (info->dr_changed_bp, 8),
-	       phex (info->dr_changed_wp, 8));
+      debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
+		    "dr_changed_wp=0x%s\n", pid,
+		    phex (info->dr_changed_bp, 8),
+		    phex (info->dr_changed_wp, 8));
     }
 
   return 0;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 02/13] Re-indent the code
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 10/13] Add pid argument in aarch64_get_debug_reg_state Yao Qi
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

gdb/gdbserver:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (debug_reg_change_callback): Re-indent
	the code.
---
 gdb/gdbserver/linux-aarch64-low.c | 66 +++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index d39a54f..8b59eab 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -272,39 +272,39 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
     : &info->dr_changed_bp;
   dr_changed = *dr_changed_ptr;
 
-      gdb_assert (idx >= 0
-		  && (idx <= (is_watchpoint ? aarch64_num_wp_regs
-			      : aarch64_num_bp_regs)));
-
-      /* The following assertion is not right, as there can be changes
-	 that have not been made to the hardware debug registers
-	 before new changes overwrite the old ones.  This can happen,
-	 for instance, when the breakpoint/watchpoint hit one of the
-	 threads and the user enters continue; then what happens is:
-	 1) all breakpoints/watchpoints are removed for all threads;
-	 2) a single step is carried out for the thread that was hit;
-	 3) all of the points are inserted again for all threads;
-	 4) all threads are resumed.
-	 The 2nd step will only affect the one thread in which the
-	 bp/wp was hit, which means only that one thread is resumed;
-	 remember that the actual updating only happen in
-	 aarch64_linux_prepare_to_resume, so other threads remain
-	 stopped during the removal and insertion of bp/wp.  Therefore
-	 for those threads, the change of insertion of the bp/wp
-	 overwrites that of the earlier removals.  (The situation may
-	 be different when bp/wp is steppable, or in the non-stop
-	 mode.)  */
-      /* gdb_assert (DR_N_HAS_CHANGED (dr_changed, idx) == 0);  */
-
-      /* The actual update is done later just before resuming the lwp,
-         we just mark that one register pair needs updating.  */
-      DR_MARK_N_CHANGED (dr_changed, idx);
-      *dr_changed_ptr = dr_changed;
-
-      /* If the lwp isn't stopped, force it to momentarily pause, so
-         we can update its debug registers.  */
-      if (!lwp->stopped)
-	linux_stop_lwp (lwp);
+  gdb_assert (idx >= 0
+	      && (idx <= (is_watchpoint ? aarch64_num_wp_regs
+			  : aarch64_num_bp_regs)));
+
+  /* The following assertion is not right, as there can be changes
+     that have not been made to the hardware debug registers
+     before new changes overwrite the old ones.  This can happen,
+     for instance, when the breakpoint/watchpoint hit one of the
+     threads and the user enters continue; then what happens is:
+     1) all breakpoints/watchpoints are removed for all threads;
+     2) a single step is carried out for the thread that was hit;
+     3) all of the points are inserted again for all threads;
+     4) all threads are resumed.
+     The 2nd step will only affect the one thread in which the
+     bp/wp was hit, which means only that one thread is resumed;
+     remember that the actual updating only happen in
+     aarch64_linux_prepare_to_resume, so other threads remain
+     stopped during the removal and insertion of bp/wp.  Therefore
+     for those threads, the change of insertion of the bp/wp
+     overwrites that of the earlier removals.  (The situation may
+     be different when bp/wp is steppable, or in the non-stop
+     mode.)  */
+  /* gdb_assert (DR_N_HAS_CHANGED (dr_changed, idx) == 0);  */
+
+  /* The actual update is done later just before resuming the lwp,
+     we just mark that one register pair needs updating.  */
+  DR_MARK_N_CHANGED (dr_changed, idx);
+  *dr_changed_ptr = dr_changed;
+
+  /* If the lwp isn't stopped, force it to momentarily pause, so
+     we can update its debug registers.  */
+  if (!lwp->stopped)
+    linux_stop_lwp (lwp);
 
   if (show_debug_regs)
     {
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 10/13] Add pid argument in aarch64_get_debug_reg_state
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
  2015-08-18 15:53 ` [PATCH 02/13] Re-indent the code Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-18 15:53 ` [PATCH 07/13] Make aarch64_notify_debug_reg_change the same on GDB and GDBserver Yao Qi
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

This patch addes argument pid in aarch64_get_debug_reg_state, so that
its interface is the same on both GDB and GDBserver.

gdb/gdbserver:

2015-018-18  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_get_debug_reg_state): Add argument pid.
	Find proc_info by find_process_pid.  All callers updated.
---
 gdb/gdbserver/linux-aarch64-low.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 3968aee..421dcb9 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -238,11 +238,10 @@ aarch64_init_debug_reg_state (struct aarch64_debug_reg_state *state)
    current process' arch-specific data area.  */
 
 static struct aarch64_debug_reg_state *
-aarch64_get_debug_reg_state ()
+aarch64_get_debug_reg_state (pid_t pid)
 {
-  struct process_info *proc;
+  struct process_info *proc = find_process_pid (pid);
 
-  proc = current_process ();
   return &proc->priv->arch_private->debug_reg_state;
 }
 
@@ -291,7 +290,8 @@ aarch64_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
 {
   int ret;
   enum target_hw_bp_type targ_type;
-  struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
+  struct aarch64_debug_reg_state *state
+    = aarch64_get_debug_reg_state (pid_of (current_thread));
 
   if (show_debug_regs)
     fprintf (stderr, "insert_point on entry (addr=0x%08lx, len=%d)\n",
@@ -310,8 +310,8 @@ aarch64_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
 				 state);
 
   if (show_debug_regs)
-    aarch64_show_debug_reg_state (aarch64_get_debug_reg_state (),
-				  "insert_point", addr, len, targ_type);
+    aarch64_show_debug_reg_state (state, "insert_point", addr, len,
+				  targ_type);
 
   return ret;
 }
@@ -327,7 +327,8 @@ aarch64_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
 {
   int ret;
   enum target_hw_bp_type targ_type;
-  struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
+  struct aarch64_debug_reg_state *state
+    = aarch64_get_debug_reg_state (pid_of (current_thread));
 
   if (show_debug_regs)
     fprintf (stderr, "remove_point on entry (addr=0x%08lx, len=%d)\n",
@@ -347,8 +348,8 @@ aarch64_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
 				 state);
 
   if (show_debug_regs)
-    aarch64_show_debug_reg_state (aarch64_get_debug_reg_state (),
-				  "remove_point", addr, len, targ_type);
+    aarch64_show_debug_reg_state (state, "remove_point", addr, len,
+				  targ_type);
 
   return ret;
 }
@@ -374,7 +375,7 @@ aarch64_stopped_data_address (void)
     return (CORE_ADDR) 0;
 
   /* Check if the address matches any watched address.  */
-  state = aarch64_get_debug_reg_state ();
+  state = aarch64_get_debug_reg_state (pid_of (current_thread));
   for (i = aarch64_num_wp_regs - 1; i >= 0; --i)
     {
       const unsigned int len = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 04/13] Get pid rather than lwpid
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (7 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 06/13] Use debug_printf in debug_reg_change_callback Yao Qi
@ 2015-08-18 15:53 ` Yao Qi
  2015-08-25 10:47   ` Pedro Alves
  2015-08-18 15:53 ` [PATCH 01/13] [gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change Yao Qi
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 18+ messages in thread
From: Yao Qi @ 2015-08-18 15:53 UTC (permalink / raw)
  To: gdb-patches

We print PID rather than LWPID in the debug output, so we need call
ptid_get_pid in debug_reg_change_callback.

gdb:

2015-08-18  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (debug_reg_change_callback): Call
	ptid_get_pid rather than ptid_get_lwp.
---
 gdb/aarch64-linux-nat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index e41f750..d530019 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -165,7 +165,7 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 {
   struct aarch64_dr_update_callback_param *param_p
     = (struct aarch64_dr_update_callback_param *) ptr;
-  int pid = ptid_get_lwp (lwp->ptid);
+  int pid = ptid_get_pid (lwp->ptid);
   int idx = param_p->idx;
   int is_watchpoint = param_p->is_watchpoint;
   struct arch_lwp_info *info = lwp->arch_private;
-- 
1.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver
  2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
                   ` (12 preceding siblings ...)
  2015-08-18 15:53 ` [PATCH 13/13] Move aarch64_linux_new_thread to nat/aarch64-linux.c Yao Qi
@ 2015-08-25 10:43 ` Yao Qi
  13 siblings, 0 replies; 18+ messages in thread
From: Yao Qi @ 2015-08-25 10:43 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

Yao Qi <qiyaoltc@gmail.com> writes:

> This patch series makes more aarch64-linux code shared between GDB and
> GDBserver.  These shared code are about HW watchpoint handling and
> aarch64_linux_new_thread.  The first several small patches make code
> in two sides identical, and then the following patches move them into
> nat/ directory.
>
> The while series is tested aarch64-linux.

I've pushed them in.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 04/13] Get pid rather than lwpid
  2015-08-18 15:53 ` [PATCH 04/13] Get pid rather than lwpid Yao Qi
@ 2015-08-25 10:47   ` Pedro Alves
  2015-08-25 13:12     ` Yao Qi
  0 siblings, 1 reply; 18+ messages in thread
From: Pedro Alves @ 2015-08-25 10:47 UTC (permalink / raw)
  To: Yao Qi, gdb-patches

On 08/18/2015 04:53 PM, Yao Qi wrote:
> We print PID rather than LWPID in the debug output, so we need call
> ptid_get_pid in debug_reg_change_callback.

This doesn't really make sense to me.  We're changing debug registers
of an LWP, so we should print the LWP's pid, not the thread group
leader's pid.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 04/13] Get pid rather than lwpid
  2015-08-25 10:47   ` Pedro Alves
@ 2015-08-25 13:12     ` Yao Qi
  2015-08-25 13:33       ` Pedro Alves
  0 siblings, 1 reply; 18+ messages in thread
From: Yao Qi @ 2015-08-25 13:12 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Yao Qi, gdb-patches

Pedro Alves <palves@redhat.com> writes:

> This doesn't really make sense to me.  We're changing debug registers
> of an LWP, so we should print the LWP's pid, not the thread group
> leader's pid.

Since the local variable is named 'pid' and the string literal in the
debugging output is 'pid' too, I thought pid should be printed.  This
patch renames the variable and prints lwpid rather than pid.

-- 
Yao (齐尧)
From f0dc39d1a71f6c05c1f09fe8c83e01e3187beec9 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao.qi@linaro.org>
Date: Tue, 25 Aug 2015 14:08:45 +0100
Subject: [PATCH] Print tid in debug output of debug_reg_change_callback

In debug_reg_change_callback, we change debug registers of each LWP.
It makes more sense to print LWP's pid rather than group leader's pid.

gdb:

2015-08-25  Yao Qi  <yao.qi@linaro.org>

	* nat/aarch64-linux-hw-point.c (debug_reg_change_callback):
	Rename local variable pid to tid, and get lwpid of lwp.  Update
	debug output.

diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
index e4a2f8e..c3fe7dd 100644
--- a/gdb/nat/aarch64-linux-hw-point.c
+++ b/gdb/nat/aarch64-linux-hw-point.c
@@ -248,7 +248,7 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 {
   struct aarch64_dr_update_callback_param *param_p
     = (struct aarch64_dr_update_callback_param *) ptr;
-  int pid = ptid_get_pid (ptid_of_lwp (lwp));
+  int tid = ptid_get_lwp (ptid_of_lwp (lwp));
   int idx = param_p->idx;
   int is_watchpoint = param_p->is_watchpoint;
   struct arch_lwp_info *info = lwp_arch_private_info (lwp);
@@ -264,8 +264,8 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
   if (show_debug_regs)
     {
       debug_printf ("debug_reg_change_callback: \n\tOn entry:\n");
-      debug_printf ("\tpid%d, dr_changed_bp=0x%s, "
-		    "dr_changed_wp=0x%s\n", pid,
+      debug_printf ("\ttid%d, dr_changed_bp=0x%s, "
+		    "dr_changed_wp=0x%s\n", tid,
 		    phex (info->dr_changed_bp, 8),
 		    phex (info->dr_changed_wp, 8));
     }
@@ -290,8 +290,8 @@ debug_reg_change_callback (struct lwp_info *lwp, void *ptr)
 
   if (show_debug_regs)
     {
-      debug_printf ("\tOn exit:\n\tpid%d, dr_changed_bp=0x%s, "
-		    "dr_changed_wp=0x%s\n", pid,
+      debug_printf ("\tOn exit:\n\ttid%d, dr_changed_bp=0x%s, "
+		    "dr_changed_wp=0x%s\n", tid,
 		    phex (info->dr_changed_bp, 8),
 		    phex (info->dr_changed_wp, 8));
     }

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 04/13] Get pid rather than lwpid
  2015-08-25 13:12     ` Yao Qi
@ 2015-08-25 13:33       ` Pedro Alves
  0 siblings, 0 replies; 18+ messages in thread
From: Pedro Alves @ 2015-08-25 13:33 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 08/25/2015 02:11 PM, Yao Qi wrote:
> From f0dc39d1a71f6c05c1f09fe8c83e01e3187beec9 Mon Sep 17 00:00:00 2001
> From: Yao Qi <yao.qi@linaro.org>
> Date: Tue, 25 Aug 2015 14:08:45 +0100
> Subject: [PATCH] Print tid in debug output of debug_reg_change_callback
> 
> In debug_reg_change_callback, we change debug registers of each LWP.
> It makes more sense to print LWP's pid rather than group leader's pid.
> 
> gdb:
> 
> 2015-08-25  Yao Qi  <yao.qi@linaro.org>
> 
> 	* nat/aarch64-linux-hw-point.c (debug_reg_change_callback):
> 	Rename local variable pid to tid, and get lwpid of lwp.  Update
> 	debug output.
> 

Looks good to me.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-08-25 13:33 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-18 15:53 [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi
2015-08-18 15:53 ` [PATCH 02/13] Re-indent the code Yao Qi
2015-08-18 15:53 ` [PATCH 10/13] Add pid argument in aarch64_get_debug_reg_state Yao Qi
2015-08-18 15:53 ` [PATCH 07/13] Make aarch64_notify_debug_reg_change the same on GDB and GDBserver Yao Qi
2015-08-18 15:53 ` [PATCH 03/13] Remove some comments in debug_reg_change_callback Yao Qi
2015-08-18 15:53 ` [PATCH 12/13] Move aarch64_linux_prepare_to_resume to nat/aarch64-linux.c Yao Qi
2015-08-18 15:53 ` [PATCH 09/13] Move debug_reg_change_callback and aarch64_notify_debug_reg_change to nat/aarch64-linux-hw-point.c Yao Qi
2015-08-18 15:53 ` [PATCH 05/13] Use phex debug_reg_change_callback Yao Qi
2015-08-18 15:53 ` [PATCH 06/13] Use debug_printf in debug_reg_change_callback Yao Qi
2015-08-18 15:53 ` [PATCH 04/13] Get pid rather than lwpid Yao Qi
2015-08-25 10:47   ` Pedro Alves
2015-08-25 13:12     ` Yao Qi
2015-08-25 13:33       ` Pedro Alves
2015-08-18 15:53 ` [PATCH 01/13] [gdbserver] Use iterate_over_lwps in aarch64_notify_debug_reg_change Yao Qi
2015-08-18 15:53 ` [PATCH 11/13] Make aarch64_linux_prepare_to_resume the same on GDB and GDBserver Yao Qi
2015-08-18 15:53 ` [PATCH 08/13] Make debug_reg_change_callback " Yao Qi
2015-08-18 15:53 ` [PATCH 13/13] Move aarch64_linux_new_thread to nat/aarch64-linux.c Yao Qi
2015-08-25 10:43 ` [PATCH 00/13] [aarch64] Share more code between GDB and GDBserver Yao Qi

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).