Move aarch64_linux_get_debug_reg_capacity to nat/aarch64-linux-hw-point.c
authorYao Qi <yao.qi@linaro.org>
Tue, 21 Jul 2015 15:33:41 +0000 (16:33 +0100)
committerYao Qi <yao.qi@linaro.org>
Tue, 21 Jul 2015 15:33:41 +0000 (16:33 +0100)
There are also some duplication on getting HW watchpoint/breakpoint
registers info between GDB and GDBserver.  This patch moves them
to nat/aarch64-linux-hw-point.c.

Note that ENABLE_NLS is not defined in GDBserver, so it should be OK
to use _( markup.

gdb:

2015-07-21  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity):
Move it to nat/aarch64-linux-hw-point.c.
(aarch64_linux_child_post_startup_inferior): Update.
* nat/aarch64-linux-hw-point.c (aarch64_linux_get_debug_reg_capacity):
New function.
* nat/aarch64-linux-hw-point.h (aarch64_linux_get_debug_reg_capacity):
Declare it.

gdb/gdbserver:

2015-07-21  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_arch_setup): Remove code and call
aarch64_linux_get_debug_reg_capacity.

gdb/ChangeLog
gdb/aarch64-linux-nat.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-aarch64-low.c
gdb/nat/aarch64-linux-hw-point.c
gdb/nat/aarch64-linux-hw-point.h

index b71b640e4c5798d3d057ade2e3980aefaa0b2377..69a086b86f1c854bb9b929993bf8e0a5b723d53e 100644 (file)
@@ -1,3 +1,13 @@
+2015-07-21  Yao Qi  <yao.qi@linaro.org>
+
+       * aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity):
+       Move it to nat/aarch64-linux-hw-point.c.
+       (aarch64_linux_child_post_startup_inferior): Update.
+       * nat/aarch64-linux-hw-point.c (aarch64_linux_get_debug_reg_capacity):
+       New function.
+       * nat/aarch64-linux-hw-point.h (aarch64_linux_get_debug_reg_capacity):
+       Declare it.
+
 2015-07-21  Markus Metzger  <markus.t.metzger@intel.com>
 
        * common/btrace-common.c (btrace_data_append): Change case label.
index 34e8fba33b4794abaf61ec6163359cbcbf054a73..1c962b68d370da3779debb2d4ccccf7bd341754e 100644 (file)
@@ -634,61 +634,6 @@ ps_get_thread_area (const struct ps_prochandle *ph,
 }
 \f
 
-/* Get the hardware debug register capacity information from the
-   inferior represented by PTID.  */
-
-static void
-aarch64_linux_get_debug_reg_capacity (ptid_t ptid)
-{
-  int tid;
-  struct iovec iov;
-  struct user_hwdebug_state dreg_state;
-
-  tid = ptid_get_pid (ptid);
-  iov.iov_base = &dreg_state;
-  iov.iov_len = sizeof (dreg_state);
-
-  /* Get hardware watchpoint register info.  */
-  if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_WATCH, &iov) == 0
-      && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8)
-    {
-      aarch64_num_wp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info);
-      if (aarch64_num_wp_regs > AARCH64_HWP_MAX_NUM)
-       {
-         warning (_("Unexpected number of hardware watchpoint registers"
-                    " reported by ptrace, got %d, expected %d."),
-                  aarch64_num_wp_regs, AARCH64_HWP_MAX_NUM);
-         aarch64_num_wp_regs = AARCH64_HWP_MAX_NUM;
-       }
-    }
-  else
-    {
-      warning (_("Unable to determine the number of hardware watchpoints"
-                " available."));
-      aarch64_num_wp_regs = 0;
-    }
-
-  /* Get hardware breakpoint register info.  */
-  if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_BREAK, &iov) == 0
-      && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8)
-    {
-      aarch64_num_bp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info);
-      if (aarch64_num_bp_regs > AARCH64_HBP_MAX_NUM)
-       {
-         warning (_("Unexpected number of hardware breakpoint registers"
-                    " reported by ptrace, got %d, expected %d."),
-                  aarch64_num_bp_regs, AARCH64_HBP_MAX_NUM);
-         aarch64_num_bp_regs = AARCH64_HBP_MAX_NUM;
-       }
-    }
-  else
-    {
-      warning (_("Unable to determine the number of hardware breakpoints"
-                " available."));
-      aarch64_num_bp_regs = 0;
-    }
-}
-
 static void (*super_post_startup_inferior) (struct target_ops *self,
                                            ptid_t ptid);
 
@@ -699,7 +644,7 @@ aarch64_linux_child_post_startup_inferior (struct target_ops *self,
                                           ptid_t ptid)
 {
   aarch64_forget_process (ptid_get_pid (ptid));
-  aarch64_linux_get_debug_reg_capacity (ptid);
+  aarch64_linux_get_debug_reg_capacity (ptid_get_pid (ptid));
   super_post_startup_inferior (self, ptid);
 }
 
index e0e19d77258e97dff565212f2d51a7e40ce37318..927a477dadd97d2e628fea2de9fbc3fc2c352884 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-21  Yao Qi  <yao.qi@linaro.org>
+
+       * linux-aarch64-low.c (aarch64_arch_setup): Remove code and call
+       aarch64_linux_get_debug_reg_capacity.
+
 2015-07-17  Yao Qi  <yao.qi@linaro.org>
 
        * Makefile.in (aarch64-linux-hw-point.o): New rule.
index d29672e013a89b2097cd47d3b675db4df9bef802..79eb44c8121e0a7fd2dfa900d8e1b3d5426d7b6d 100644 (file)
@@ -587,55 +587,9 @@ aarch64_linux_prepare_to_resume (struct lwp_info *lwp)
 static void
 aarch64_arch_setup (void)
 {
-  int pid;
-  struct iovec iov;
-  struct user_hwdebug_state dreg_state;
-
   current_process ()->tdesc = tdesc_aarch64;
 
-  pid = lwpid_of (current_thread);
-  iov.iov_base = &dreg_state;
-  iov.iov_len = sizeof (dreg_state);
-
-  /* Get hardware watchpoint register info.  */
-  if (ptrace (PTRACE_GETREGSET, pid, NT_ARM_HW_WATCH, &iov) == 0
-      && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8)
-    {
-      aarch64_num_wp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info);
-      if (aarch64_num_wp_regs > AARCH64_HWP_MAX_NUM)
-       {
-         warning ("Unexpected number of hardware watchpoint registers reported"
-                  " by ptrace, got %d, expected %d.",
-                  aarch64_num_wp_regs, AARCH64_HWP_MAX_NUM);
-         aarch64_num_wp_regs = AARCH64_HWP_MAX_NUM;
-       }
-    }
-  else
-    {
-      warning ("Unable to determine the number of hardware watchpoints"
-              " available.");
-      aarch64_num_wp_regs = 0;
-    }
-
-  /* Get hardware breakpoint register info.  */
-  if (ptrace (PTRACE_GETREGSET, pid, NT_ARM_HW_BREAK, &iov) == 0
-      && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8)
-    {
-      aarch64_num_bp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info);
-      if (aarch64_num_bp_regs > AARCH64_HBP_MAX_NUM)
-       {
-         warning ("Unexpected number of hardware breakpoint registers reported"
-                  " by ptrace, got %d, expected %d.",
-                  aarch64_num_bp_regs, AARCH64_HBP_MAX_NUM);
-         aarch64_num_bp_regs = AARCH64_HBP_MAX_NUM;
-       }
-    }
-  else
-    {
-      warning ("Unable to determine the number of hardware breakpoints"
-              " available.");
-      aarch64_num_bp_regs = 0;
-    }
+  aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread));
 }
 
 static struct regset_info aarch64_regsets[] =
index f58e0c5ff36f5ab17e0193e2b58f3e1634d8f655..1d9664ea1c02a31ed830e7ef93289e0f8a6a6e17 100644 (file)
@@ -504,3 +504,56 @@ aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
                  i, core_addr_to_string_nz (state->dr_addr_wp[i]),
                  state->dr_ctrl_wp[i], state->dr_ref_count_wp[i]);
 }
+
+/* Get the hardware debug register capacity information from the
+   process represented by TID.  */
+
+void
+aarch64_linux_get_debug_reg_capacity (int tid)
+{
+  struct iovec iov;
+  struct user_hwdebug_state dreg_state;
+
+  iov.iov_base = &dreg_state;
+  iov.iov_len = sizeof (dreg_state);
+
+  /* Get hardware watchpoint register info.  */
+  if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_WATCH, &iov) == 0
+      && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8)
+    {
+      aarch64_num_wp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info);
+      if (aarch64_num_wp_regs > AARCH64_HWP_MAX_NUM)
+       {
+         warning (_("Unexpected number of hardware watchpoint registers"
+                    " reported by ptrace, got %d, expected %d."),
+                  aarch64_num_wp_regs, AARCH64_HWP_MAX_NUM);
+         aarch64_num_wp_regs = AARCH64_HWP_MAX_NUM;
+       }
+    }
+  else
+    {
+      warning (_("Unable to determine the number of hardware watchpoints"
+                " available."));
+      aarch64_num_wp_regs = 0;
+    }
+
+  /* Get hardware breakpoint register info.  */
+  if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_BREAK, &iov) == 0
+      && AARCH64_DEBUG_ARCH (dreg_state.dbg_info) == AARCH64_DEBUG_ARCH_V8)
+    {
+      aarch64_num_bp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info);
+      if (aarch64_num_bp_regs > AARCH64_HBP_MAX_NUM)
+       {
+         warning (_("Unexpected number of hardware breakpoint registers"
+                    " reported by ptrace, got %d, expected %d."),
+                  aarch64_num_bp_regs, AARCH64_HBP_MAX_NUM);
+         aarch64_num_bp_regs = AARCH64_HBP_MAX_NUM;
+       }
+    }
+  else
+    {
+      warning (_("Unable to determine the number of hardware breakpoints"
+                " available."));
+      aarch64_num_bp_regs = 0;
+    }
+}
index 1d81a08bfbaa0a233a5694d2e777cc8853cc6afa..a430a8fcb8dbcfb6a96830d8ae8d516c1894e276 100644 (file)
@@ -181,4 +181,6 @@ void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
                                   const char *func, CORE_ADDR addr,
                                   int len, enum target_hw_bp_type type);
 
+void aarch64_linux_get_debug_reg_capacity (int tid);
+
 #endif /* AARCH64_LINUX_HW_POINT_H */
This page took 0.0362 seconds and 4 git commands to generate.