]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Arm: Minor style cleanups
authorAlan Hayward <alan.hayward@arm.com>
Tue, 25 Jun 2019 10:04:59 +0000 (11:04 +0100)
committerAlan Hayward <alan.hayward@arm.com>
Wed, 10 Jul 2019 10:59:34 +0000 (11:59 +0100)
*When reading a target description, do the ptrace check before picking the
 target description.

*In wmmxregset functions, declare the counter inside the for.

*Call arm_linux_init_hwbp_cap from in arm_arch_setup - it doesn't belong in
 arm_read_description.

gdb/ChangeLog:

* arm-linux-nat.c (arm_linux_nat_target::read_description): Check
ptrace earlier,

gdb/gdbserver/ChangeLog:

* linux-arm-low.c (arm_fill_wmmxregset, arm_store_wmmxregset):
Move counter inside for.
(arm_read_description): Check ptrace earlier.
(arm_arch_setup): Call arm_linux_init_hwbp_cap here.

gdb/ChangeLog
gdb/arm-linux-nat.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-arm-low.c

index 3ba5bc514293326b5757294943e0c4ddc3cef62a..6686a14c4b9867a2b4c287ca2e3ce2124776739b 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-10  Alan Hayward  <alan.hayward@arm.com>
+
+       * arm-linux-nat.c (arm_linux_nat_target::read_description): Check
+       ptrace earlier.
+
 2019-07-10  Alan Hayward  <alan.hayward@arm.com>
 
        * features/aarch64-pauth.c: Regenerate.
index a1ad6fe01edca9b832128fe3fac3e039bd5f73d4..fe8a113a27064487ff81076db07c42829ceba486 100644 (file)
@@ -555,29 +555,22 @@ arm_linux_nat_target::read_description ()
 
   if (arm_hwcap & HWCAP_VFP)
     {
-      int pid;
-      char *buf;
-      const struct target_desc * result = NULL;
+      /* Make sure that the kernel supports reading VFP registers.  Support was
+        added in 2.6.30.  */
+      int pid = inferior_ptid.lwp ();
+      errno = 0;
+      char *buf = (char *) alloca (ARM_VFP3_REGS_SIZE);
+      if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0 && errno == EIO)
+       return nullptr;
 
       /* NEON implies VFPv3-D32 or no-VFP unit.  Say that we only support
         Neon with VFPv3-D32.  */
       if (arm_hwcap & HWCAP_NEON)
-       result = tdesc_arm_with_neon;
+       return tdesc_arm_with_neon;
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
-       result = tdesc_arm_with_vfpv3;
+       return tdesc_arm_with_vfpv3;
       else
-       result = tdesc_arm_with_vfpv2;
-
-      /* Now make sure that the kernel supports reading these
-        registers.  Support was added in 2.6.30.  */
-      pid = inferior_ptid.lwp ();
-      errno = 0;
-      buf = (char *) alloca (ARM_VFP3_REGS_SIZE);
-      if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0
-         && errno == EIO)
-       result = NULL;
-
-      return result;
+       return tdesc_arm_with_vfpv2;
     }
 
   return this->beneath ()->read_description ();
index 0a48ad5b79243c7aa69f07154aec6a11b7c013d4..51aaa77ce12d77b9c853a2b45f4056cef03ddbca 100644 (file)
@@ -1,3 +1,10 @@
+2019-07-10  Alan Hayward  <alan.hayward@arm.com>
+
+       * linux-arm-low.c (arm_fill_wmmxregset, arm_store_wmmxregset):
+       Move counter inside for.
+       (arm_read_description): Check ptrace earlier.
+       (arm_arch_setup): Call arm_linux_init_hwbp_cap here.
+
 2019-07-09  Tom Tromey  <tom@tromey.com>
 
        * configure: Rebuild.
index b323b1907846c94d9ee0eecb6151f1cc1078310b..7d6c9d9dd9659ed9d43107107e627857e05b04d4 100644 (file)
@@ -175,16 +175,14 @@ arm_cannot_fetch_register (int regno)
 static void
 arm_fill_wmmxregset (struct regcache *regcache, void *buf)
 {
-  int i;
-
   if (regcache->tdesc != tdesc_arm_with_iwmmxt)
     return;
 
-  for (i = 0; i < 16; i++)
+  for (int i = 0; i < 16; i++)
     collect_register (regcache, arm_num_regs + i, (char *) buf + i * 8);
 
   /* We only have access to wcssf, wcasf, and wcgr0-wcgr3.  */
-  for (i = 0; i < 6; i++)
+  for (int i = 0; i < 6; i++)
     collect_register (regcache, arm_num_regs + i + 16,
                      (char *) buf + 16 * 8 + i * 4);
 }
@@ -192,16 +190,14 @@ arm_fill_wmmxregset (struct regcache *regcache, void *buf)
 static void
 arm_store_wmmxregset (struct regcache *regcache, const void *buf)
 {
-  int i;
-
   if (regcache->tdesc != tdesc_arm_with_iwmmxt)
     return;
 
-  for (i = 0; i < 16; i++)
+  for (int i = 0; i < 16; i++)
     supply_register (regcache, arm_num_regs + i, (char *) buf + i * 8);
 
   /* We only have access to wcssf, wcasf, and wcgr0-wcgr3.  */
-  for (i = 0; i < 6; i++)
+  for (int i = 0; i < 6; i++)
     supply_register (regcache, arm_num_regs + i + 16,
                     (char *) buf + 16 * 8 + i * 4);
 }
@@ -850,40 +846,29 @@ get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self)
 static const struct target_desc *
 arm_read_description (void)
 {
-  int pid = lwpid_of (current_thread);
   unsigned long arm_hwcap = linux_get_hwcap (4);
 
-  /* Query hardware watchpoint/breakpoint capabilities.  */
-  arm_linux_init_hwbp_cap (pid);
-
   if (arm_hwcap & HWCAP_IWMMXT)
     return tdesc_arm_with_iwmmxt;
 
   if (arm_hwcap & HWCAP_VFP)
     {
-      const struct target_desc *result;
-      char *buf;
+      /* Make sure that the kernel supports reading VFP registers.  Support was
+        added in 2.6.30.  */
+      int pid = lwpid_of (current_thread);
+      errno = 0;
+      char *buf = (char *) alloca (ARM_VFP3_REGS_SIZE);
+      if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0 && errno == EIO)
+       return tdesc_arm;
 
       /* NEON implies either no VFP, or VFPv3-D32.  We only support
         it with VFP.  */
       if (arm_hwcap & HWCAP_NEON)
-       result = tdesc_arm_with_neon;
+       return tdesc_arm_with_neon;
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
-       result = tdesc_arm_with_vfpv3;
+       return tdesc_arm_with_vfpv3;
       else
-       result = tdesc_arm_with_vfpv2;
-
-      /* Now make sure that the kernel supports reading these
-        registers.  Support was added in 2.6.30.  */
-      errno = 0;
-      buf = (char *) xmalloc (ARM_VFP3_REGS_SIZE);
-      if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0
-         && errno == EIO)
-       result = tdesc_arm;
-
-      free (buf);
-
-      return result;
+       return tdesc_arm_with_vfpv2;
     }
 
   /* The default configuration uses legacy FPA registers, probably
@@ -898,6 +883,9 @@ arm_arch_setup (void)
   int gpregs[18];
   struct iovec iov;
 
+  /* Query hardware watchpoint/breakpoint capabilities.  */
+  arm_linux_init_hwbp_cap (tid);
+
   current_process ()->tdesc = arm_read_description ();
 
   iov.iov_base = gpregs;