[PATCH v2 0/5] Arm: Use feature target descriptions

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH v2 0/5] Arm: Use feature target descriptions

Alan Hayward
Version 2. First two patches from the original set have been pushed.
1 and 4 are updated as per review comments.
Otherwise identical. Will push mid next week if there are no more comments.


This set of patches is a result of me trying to figure out exactly what
is supported for Arm. It moves Arm over to using feature target descriptions,
simplifying the confusion of xml files in the features/arm/ directory.
In addition it helps to further separate out AArch32.

There are zero functional changes made by this series. The intention is
that all Arm target descriptions are identical before and after the series.
All quirks that might seem odd (for example, the Arm with NEON creates a
vfp3 feature and then a blank neon feature) have been preserved. One of the
patches adds tests to prove the new target descriptions are identical. The
final patch then removes these tests (as they block the removal of the xml
files).

One of the patches breaks the AArch64 gdbserver build, but it is fixed in
the following patch.  Preventing this would have meant including additional
unused functionality, and then removing again.

Code has been tested with AArch32, Armv7, and X86 target-all builds. I don't
have every Arm target to test this on, but the xml tests should alleviate any
issue.

Alan Hayward (5):
  Arm: Add read_description read funcs and use in GDB
  Arm: Use feature target descriptions
  Arm: Add xml unit tests
  Arm: Use read_description funcs in gdbserver
  Arm: Remove unused feature files and tests

 gdb/Makefile.in                            |  5 ++
 gdb/aarch32-tdep.c                         | 33 +++++++++
 gdb/aarch32-tdep.h                         | 25 +++++++
 gdb/aarch64-linux-nat.c                    |  6 +-
 gdb/arch/aarch32.c                         | 43 +++++++++++
 gdb/arch/aarch32.h                         | 27 +++++++
 gdb/arch/arm.c                             | 84 ++++++++++++++++++++++
 gdb/arch/arm.h                             | 27 +++++++
 gdb/arm-fbsd-tdep.c                        | 12 ++--
 gdb/arm-linux-nat.c                        | 11 +--
 gdb/arm-linux-tdep.c                       | 11 +--
 gdb/arm-tdep.c                             | 65 +++++++++++------
 gdb/arm-tdep.h                             | 12 ++--
 gdb/configure.tgt                          |  8 ++-
 gdb/features/arm/arm-with-iwmmxt.c         | 83 ---------------------
 gdb/features/arm/arm-with-iwmmxt.xml       | 13 ----
 gdb/features/arm/arm-with-m-fpa-layout.c   | 46 ------------
 gdb/features/arm/arm-with-m-fpa-layout.xml | 46 ------------
 gdb/features/arm/arm-with-m-vfp-d16.c      | 56 ---------------
 gdb/features/arm/arm-with-m-vfp-d16.xml    | 14 ----
 gdb/features/arm/arm-with-m.c              | 37 ----------
 gdb/features/arm/arm-with-m.xml            | 12 ----
 gdb/features/arm/arm-with-neon.c           | 74 -------------------
 gdb/features/arm/arm-with-neon.xml         | 14 ----
 gdb/features/arm/arm-with-vfpv2.c          | 56 ---------------
 gdb/features/arm/arm-with-vfpv2.xml        | 13 ----
 gdb/features/arm/arm-with-vfpv3.c          | 72 -------------------
 gdb/features/arm/arm-with-vfpv3.xml        | 13 ----
 gdb/gdbserver/configure.srv                | 22 ++----
 gdb/gdbserver/linux-aarch32-low.c          |  2 -
 gdb/gdbserver/linux-aarch32-low.h          |  2 -
 gdb/gdbserver/linux-aarch32-tdesc.c        | 46 ++++++++++++
 gdb/gdbserver/linux-aarch32-tdesc.h        | 29 ++++++++
 gdb/gdbserver/linux-aarch64-low.c          |  3 +-
 gdb/gdbserver/linux-arm-low.c              | 77 ++++++++++----------
 gdb/gdbserver/linux-arm-tdesc.c            | 62 ++++++++++++++++
 gdb/gdbserver/linux-arm-tdesc.h            | 29 ++++++++
 37 files changed, 532 insertions(+), 658 deletions(-)
 create mode 100644 gdb/aarch32-tdep.c
 create mode 100644 gdb/aarch32-tdep.h
 create mode 100644 gdb/arch/aarch32.c
 create mode 100644 gdb/arch/aarch32.h
 delete mode 100644 gdb/features/arm/arm-with-iwmmxt.c
 delete mode 100644 gdb/features/arm/arm-with-iwmmxt.xml
 delete mode 100644 gdb/features/arm/arm-with-m-fpa-layout.c
 delete mode 100644 gdb/features/arm/arm-with-m-fpa-layout.xml
 delete mode 100644 gdb/features/arm/arm-with-m-vfp-d16.c
 delete mode 100644 gdb/features/arm/arm-with-m-vfp-d16.xml
 delete mode 100644 gdb/features/arm/arm-with-m.c
 delete mode 100644 gdb/features/arm/arm-with-m.xml
 delete mode 100644 gdb/features/arm/arm-with-neon.c
 delete mode 100644 gdb/features/arm/arm-with-neon.xml
 delete mode 100644 gdb/features/arm/arm-with-vfpv2.c
 delete mode 100644 gdb/features/arm/arm-with-vfpv2.xml
 delete mode 100644 gdb/features/arm/arm-with-vfpv3.c
 delete mode 100644 gdb/features/arm/arm-with-vfpv3.xml
 create mode 100644 gdb/gdbserver/linux-aarch32-tdesc.c
 create mode 100644 gdb/gdbserver/linux-aarch32-tdesc.h
 create mode 100644 gdb/gdbserver/linux-arm-tdesc.c
 create mode 100644 gdb/gdbserver/linux-arm-tdesc.h

--
2.20.1 (Apple Git-117)

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 1/5] Arm: Add read_description read funcs and use in GDB

Alan Hayward
Switch the Arm target to get target descriptions via arm_read_description
and aarch32_read_description, in the same style as other feature targets.
Add an enum to specify the different types - this will also be of use to
gdbserver in a later patch.

Under the hood return the same existing pre-feature target descriptions.

Note: This commit will break the AArch64 gdbserver build.

gdb/ChangeLog:

2019-07-11  Alan Hayward  <[hidden email]>

        * Makefile.in: Add new files.
        * aarch32-tdep.c: New file.
        * aarch32-tdep.h: New file.
        * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description):
        Call aarch32_read_description.
        * arch/aarch32.c: New file.
        * arch/aarch32.h: New file.
        * arch/arm.c (arm_create_target_description)
        (arm_create_mprofile_target_description): New function.
        * arch/arm.h (arm_fp_type, arm_m_profile_type): New enum.
        (arm_create_target_description)
        (arm_create_mprofile_target_description): New declaration.
        * arm-fbsd-tdep.c (arm_fbsd_read_description_auxv): Call
        read_description functions.
        * arm-linux-nat.c (arm_linux_nat_target::read_description):
        Likewise.
        * arm-linux-tdep.c (arm_linux_core_read_description): Likewise.
        * arm-tdep.c (tdesc_arm_list): New variable.
        (arm_register_g_packet_guesses): Call create description functions.
        (arm_read_description) (arm_read_mprofile_description): New
        function.
        * arm-tdep.h (arm_read_description)
        (arm_read_mprofile_description): Add declaration.
        * configure.tgt: Add new files.
---
 gdb/Makefile.in         |  5 ++++
 gdb/aarch32-tdep.c      | 33 +++++++++++++++++++++++
 gdb/aarch32-tdep.h      | 25 +++++++++++++++++
 gdb/aarch64-linux-nat.c |  6 ++---
 gdb/arch/aarch32.c      | 29 ++++++++++++++++++++
 gdb/arch/aarch32.h      | 27 +++++++++++++++++++
 gdb/arch/arm.c          | 59 +++++++++++++++++++++++++++++++++++++++++
 gdb/arch/arm.h          | 27 +++++++++++++++++++
 gdb/arm-fbsd-tdep.c     | 12 +++++----
 gdb/arm-linux-nat.c     | 11 ++++----
 gdb/arm-linux-tdep.c    | 11 ++++----
 gdb/arm-tdep.c          | 48 ++++++++++++++++++++++++++++++---
 gdb/arm-tdep.h          | 12 ++++-----
 gdb/configure.tgt       |  8 +++---
 14 files changed, 282 insertions(+), 31 deletions(-)
 create mode 100644 gdb/aarch32-tdep.c
 create mode 100644 gdb/aarch32-tdep.h
 create mode 100644 gdb/arch/aarch32.c
 create mode 100644 gdb/arch/aarch32.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index b6680b9afd..62a59c90ea 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -665,7 +665,9 @@ ALL_64_TARGET_OBS = \
 
 # All other target-dependent objects files (used with --enable-targets=all).
 ALL_TARGET_OBS = \
+ aarch32-tdep.o \
  arc-tdep.o \
+ arch/aarch32.o \
  arch/arm.o \
  arch/arm-get-next-pcs.o \
  arch/arm-linux.o \
@@ -1184,6 +1186,7 @@ SFILES = \
 # right, it is probably easiest just to list .h files here directly.
 
 HFILES_NO_SRCDIR = \
+ aarch32-tdep.h \
  aarch64-ravenscar-thread.h \
  aarch64-tdep.h \
  ada-lang.h \
@@ -1429,6 +1432,7 @@ HFILES_NO_SRCDIR = \
  xml-syscall.h \
  xml-tdesc.h \
  xtensa-tdep.h \
+ arch/aarch32.h \
  arch/aarch64.h \
  arch/aarch64-insn.h \
  arch/arm.h \
@@ -2133,6 +2137,7 @@ force_update:
 MAKEOVERRIDES =
 
 ALLDEPFILES = \
+ aarch32-tdep.c \
  aarch64-fbsd-nat.c \
  aarch64-fbsd-tdep.c \
  aarch64-linux-nat.c \
diff --git a/gdb/aarch32-tdep.c b/gdb/aarch32-tdep.c
new file mode 100644
index 0000000000..d004e0d7f3
--- /dev/null
+++ b/gdb/aarch32-tdep.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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/common-defs.h"
+#include "common/common-regcache.h"
+#include "arch/aarch32.h"
+
+static struct target_desc *tdesc_aarch32;
+
+/* See aarch32-tdep.h.  */
+
+const target_desc *
+aarch32_read_description ()
+{
+  if (tdesc_aarch32 == nullptr)
+    tdesc_aarch32 = aarch32_create_target_description ();
+
+  return tdesc_aarch32;
+}
diff --git a/gdb/aarch32-tdep.h b/gdb/aarch32-tdep.h
new file mode 100644
index 0000000000..7fcea0adb9
--- /dev/null
+++ b/gdb/aarch32-tdep.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 AARCH32_TDEP_H
+#define AARCH32_TDEP_H
+
+/* Get the AArch32 target description.  */
+
+const target_desc *aarch32_read_description ();
+
+#endif /* aarch32-tdep.h.  */
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 7b60a9a0c3..4db0288e68 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -27,9 +27,11 @@
 #include "target-descriptions.h"
 #include "auxv.h"
 #include "gdbcmd.h"
+#include "arch/arm.h"
 #include "aarch64-tdep.h"
 #include "aarch64-linux-tdep.h"
 #include "aarch32-linux-nat.h"
+#include "aarch32-tdep.h"
 #include "arch/arm.h"
 #include "nat/aarch64-linux.h"
 #include "nat/aarch64-linux-hw-point.h"
@@ -631,8 +633,6 @@ aarch64_linux_nat_target::post_attach (int pid)
   linux_nat_target::post_attach (pid);
 }
 
-extern struct target_desc *tdesc_arm_with_neon;
-
 /* Implement the "read_description" target_ops method.  */
 
 const struct target_desc *
@@ -649,7 +649,7 @@ aarch64_linux_nat_target::read_description ()
 
   ret = ptrace (PTRACE_GETREGSET, tid, NT_ARM_VFP, &iovec);
   if (ret == 0)
-    return tdesc_arm_with_neon;
+    return aarch32_read_description ();
 
   CORE_ADDR hwcap = linux_get_hwcap (this);
 
diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
new file mode 100644
index 0000000000..f3cb8c7855
--- /dev/null
+++ b/gdb/arch/aarch32.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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/common-defs.h"
+#include "aarch32.h"
+
+extern struct target_desc *tdesc_arm_with_neon;
+
+/* See aarch32.h.  */
+
+target_desc *
+aarch32_create_target_description ()
+{
+  return tdesc_arm_with_neon;
+}
diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h
new file mode 100644
index 0000000000..87b28c0040
--- /dev/null
+++ b/gdb/arch/aarch32.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 ARCH_AARCH32_H
+#define ARCH_AARCH32_H
+
+#include "common/tdesc.h"
+
+/* Create the AArch32 target description.  */
+
+target_desc *aarch32_create_target_description ();
+
+#endif /* aarch32.h.  */
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index 860ce02858..769d280a52 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -21,6 +21,17 @@
 #include "gdbsupport/common-regcache.h"
 #include "arm.h"
 
+extern struct target_desc *tdesc_arm_with_vfpv2;
+extern struct target_desc *tdesc_arm_with_vfpv3;
+extern struct target_desc *tdesc_arm_with_iwmmxt;
+
+/* Temporary ifdef.  Will be removed when target descriptions are switched.  */
+#ifndef GDBSERVER
+extern struct target_desc *tdesc_arm_with_m;
+extern struct target_desc *tdesc_arm_with_m_vfp_d16;
+extern struct target_desc *tdesc_arm_with_m_fpa_layout;
+#endif
+
 /* See arm.h.  */
 
 int
@@ -372,3 +383,51 @@ shifted_reg_val (struct regcache *regcache, unsigned long inst,
 
   return res & 0xffffffff;
 }
+
+/* See arch/arm.h.  */
+
+target_desc *
+arm_create_target_description (arm_fp_type fp_type)
+{
+  switch (fp_type)
+    {
+    case ARM_FP_TYPE_NONE:
+      return nullptr;
+
+    case ARM_FP_TYPE_VFPV2:
+      return tdesc_arm_with_vfpv2;
+
+    case ARM_FP_TYPE_VFPV3:
+      return tdesc_arm_with_vfpv3;
+
+    case ARM_FP_TYPE_IWMMXT:
+      return tdesc_arm_with_iwmmxt;
+
+    default:
+      error (_("Invalid Arm FP type: %d"), fp_type);
+    }
+}
+
+/* See arch/arm.h.  */
+
+target_desc *
+arm_create_mprofile_target_description (arm_m_profile_type m_type)
+{
+  switch (m_type)
+    {
+/* Temporary ifdef.  Will be removed when target descriptions are switched.  */
+#ifndef GDBSERVER
+    case ARM_M_TYPE_M_PROFILE:
+      return tdesc_arm_with_m;
+
+    case ARM_M_TYPE_VFP_D16:
+      return tdesc_arm_with_m_fpa_layout;
+
+    case ARM_M_TYPE_WITH_FPA:
+      return tdesc_arm_with_m_vfp_d16;
+#endif
+    default:
+      error (_("Invalid Arm M type: %d"), m_type);
+    }
+}
+
diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h
index dfbbd56d28..f4cac9c15b 100644
--- a/gdb/arch/arm.h
+++ b/gdb/arch/arm.h
@@ -19,6 +19,8 @@
 #ifndef ARCH_ARM_H
 #define ARCH_ARM_H
 
+#include "common/tdesc.h"
+
 /* Register numbers of various important registers.  */
 
 enum gdb_regnum {
@@ -66,6 +68,23 @@ enum arm_breakpoint_kinds
    ARM_BP_KIND_ARM = 4,
 };
 
+/* Supported Arm FP hardware types.  */
+enum arm_fp_type {
+   ARM_FP_TYPE_NONE = 0,
+   ARM_FP_TYPE_VFPV2,
+   ARM_FP_TYPE_VFPV3,
+   ARM_FP_TYPE_IWMMXT,
+   ARM_FP_TYPE_INVALID
+};
+
+/* Supported M-profile Arm types.  */
+enum arm_m_profile_type {
+   ARM_M_TYPE_M_PROFILE,
+   ARM_M_TYPE_VFP_D16,
+   ARM_M_TYPE_WITH_FPA,
+   ARM_M_TYPE_INVALID
+};
+
 /* Instruction condition field values.  */
 #define INST_EQ 0x0
 #define INST_NE 0x1
@@ -165,4 +184,12 @@ unsigned long shifted_reg_val (struct regcache *regcache,
        unsigned long pc_val,
        unsigned long status_reg);
 
+/* Create an Arm target description with the given FP hardware type.  */
+
+target_desc *arm_create_target_description (arm_fp_type fp_type);
+
+/* Create an Arm M-profile target description with the given hardware type.  */
+
+target_desc *arm_create_mprofile_target_description (arm_m_profile_type m_type);
+
 #endif /* ARCH_ARM_H */
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index dea3abbdd3..6e1af9cda3 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -20,6 +20,8 @@
 #include "defs.h"
 
 #include "elf/common.h"
+#include "target-descriptions.h"
+#include "aarch32-tdep.h"
 #include "arm-tdep.h"
 #include "arm-fbsd-tdep.h"
 #include "auxv.h"
@@ -178,20 +180,20 @@ arm_fbsd_read_description_auxv (struct target_ops *target)
   CORE_ADDR arm_hwcap = 0;
 
   if (target_auxv_search (target, AT_FREEBSD_HWCAP, &arm_hwcap) != 1)
-    return NULL;
+    return nullptr;
 
   if (arm_hwcap & HWCAP_VFP)
     {
       if (arm_hwcap & HWCAP_NEON)
- return tdesc_arm_with_neon;
+ return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPD32))
   == (HWCAP_VFPv3 | HWCAP_VFPD32))
- return tdesc_arm_with_vfpv3;
+ return arm_read_description (ARM_FP_TYPE_VFPV3);
       else
- return tdesc_arm_with_vfpv2;
+      return arm_read_description (ARM_FP_TYPE_VFPV2);
     }
 
-  return NULL;
+  return nullptr;
 }
 
 /* Implement the "core_read_description" gdbarch method.  */
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index fe8a113a27..6a374bbc74 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -27,6 +27,7 @@
 #include "observable.h"
 #include "gdbthread.h"
 
+#include "aarch32-tdep.h"
 #include "arm-tdep.h"
 #include "arm-linux-tdep.h"
 #include "aarch32-linux-nat.h"
@@ -551,7 +552,7 @@ arm_linux_nat_target::read_description ()
     }
 
   if (arm_hwcap & HWCAP_IWMMXT)
-    return tdesc_arm_with_iwmmxt;
+    return arm_read_description (ARM_FP_TYPE_IWMMXT);
 
   if (arm_hwcap & HWCAP_VFP)
     {
@@ -566,11 +567,11 @@ arm_linux_nat_target::read_description ()
       /* NEON implies VFPv3-D32 or no-VFP unit.  Say that we only support
  Neon with VFPv3-D32.  */
       if (arm_hwcap & HWCAP_NEON)
- return tdesc_arm_with_neon;
+ return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
- return tdesc_arm_with_vfpv3;
-      else
- return tdesc_arm_with_vfpv2;
+ return arm_read_description (ARM_FP_TYPE_VFPV3);
+
+      return arm_read_description (ARM_FP_TYPE_VFPV2);
     }
 
   return this->beneath ()->read_description ();
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index d846749e0b..aec20877d9 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -33,6 +33,7 @@
 #include "auxv.h"
 #include "xml-syscall.h"
 
+#include "aarch32-tdep.h"
 #include "arch/arm.h"
 #include "arch/arm-get-next-pcs.h"
 #include "arch/arm-linux.h"
@@ -738,14 +739,14 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
       /* NEON implies VFPv3-D32 or no-VFP unit.  Say that we only support
          Neon with VFPv3-D32.  */
       if (arm_hwcap & HWCAP_NEON)
- return tdesc_arm_with_neon;
+ return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
- return tdesc_arm_with_vfpv3;
-      else
- return tdesc_arm_with_vfpv2;
+ return arm_read_description (ARM_FP_TYPE_VFPV3);
+
+      return arm_read_description (ARM_FP_TYPE_VFPV2);
     }
 
-  return NULL;
+  return nullptr;
 }
 
 
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index c1ee39714f..1b19b72ca1 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -240,6 +240,10 @@ static const char **valid_disassembly_styles;
 /* Disassembly style to use. Default to "std" register names.  */
 static const char *disassembly_style;
 
+/* All possible arm target descriptors.  */
+static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID];
+static struct target_desc *tdesc_arm_mprofile_list[ARM_M_TYPE_INVALID];
+
 /* This is used to keep the bfd arch_info in sync with the disassembly
    style.  */
 static void set_disassembly_style_sfunc (const char *, int,
@@ -8739,7 +8743,6 @@ arm_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
     return default_register_reggroup_p (gdbarch, regnum, group);
 }
 
-
 /* For backward-compatibility we allow two 'g' packet lengths with
    the remote protocol depending on whether FPA registers are
    supplied.  M-profile targets do not have FPA registers, but some
@@ -8753,21 +8756,26 @@ arm_register_g_packet_guesses (struct gdbarch *gdbarch)
 {
   if (gdbarch_tdep (gdbarch)->is_m)
     {
+      const target_desc *tdesc;
+
       /* If we know from the executable this is an M-profile target,
  cater for remote targets whose register set layout is the
  same as the FPA layout.  */
+      tdesc = arm_read_mprofile_description (ARM_M_TYPE_WITH_FPA);
       register_remote_g_packet_guess (gdbarch,
       ARM_CORE_REGS_SIZE + ARM_FP_REGS_SIZE,
-      tdesc_arm_with_m_fpa_layout);
+      tdesc);
 
       /* The regular M-profile layout.  */
+      tdesc = arm_read_mprofile_description (ARM_M_TYPE_M_PROFILE);
       register_remote_g_packet_guess (gdbarch, ARM_CORE_REGS_SIZE,
-      tdesc_arm_with_m);
+      tdesc);
 
       /* M-profile plus M4F VFP.  */
+      tdesc = arm_read_mprofile_description (ARM_M_TYPE_VFP_D16);
       register_remote_g_packet_guess (gdbarch,
       ARM_CORE_REGS_SIZE + ARM_VFP2_REGS_SIZE,
-      tdesc_arm_with_m_vfp_d16);
+      tdesc);
     }
 
   /* Otherwise we don't have a useful guess.  */
@@ -13310,3 +13318,35 @@ arm_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
 
   return ret;
 }
+
+/* See arm-tdep.h.  */
+
+const target_desc *
+arm_read_description (arm_fp_type fp_type)
+{
+  struct target_desc *tdesc = tdesc_arm_list[fp_type];
+
+  if (tdesc == nullptr)
+    {
+      tdesc = arm_create_target_description (fp_type);
+      tdesc_arm_list[fp_type] = tdesc;
+    }
+
+  return tdesc;
+}
+
+/* See arm-tdep.h.  */
+
+const target_desc *
+arm_read_mprofile_description (arm_m_profile_type m_type)
+{
+  struct target_desc *tdesc = tdesc_arm_mprofile_list[m_type];
+
+  if (tdesc == nullptr)
+    {
+      tdesc = arm_create_mprofile_target_description (m_type);
+      tdesc_arm_mprofile_list[m_type] = tdesc;
+    }
+
+  return tdesc;
+}
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 36d2d381cf..6d1a91ca35 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -281,11 +281,11 @@ extern void
        void *cb_data,
        const struct regcache *regcache);
 
-/* Target descriptions.  */
-extern struct target_desc *tdesc_arm_with_m;
-extern struct target_desc *tdesc_arm_with_iwmmxt;
-extern struct target_desc *tdesc_arm_with_vfpv2;
-extern struct target_desc *tdesc_arm_with_vfpv3;
-extern struct target_desc *tdesc_arm_with_neon;
+/* Get the correct Arm target description with given FP hardware type.  */
+const target_desc *arm_read_description (arm_fp_type fp_type);
+
+/* Get the correct Arm M-Profile target description with given hardware
+   type.  */
+const target_desc *arm_read_mprofile_description (arm_m_profile_type m_type);
 
 #endif /* arm-tdep.h */
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 27f122ad04..7c0215e89a 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -48,8 +48,9 @@ amd64_tobjs="amd64-tdep.o arch/amd64.o ${x86_tobjs}"
 
 case "${targ}" in
 aarch64*-*-*)
- cpu_obs="aarch64-tdep.o arch/aarch64-insn.o arch/aarch64.o \
- ravenscar-thread.o aarch64-ravenscar-thread.o";;
+ cpu_obs="aarch32-tdep.o aarch64-tdep.o arch/aarch32.o \
+ arch/aarch64-insn.o arch/aarch64.o  ravenscar-thread.o \
+ aarch64-ravenscar-thread.o";;
 
 alpha*-*-*)
  # Target: Alpha
@@ -62,7 +63,8 @@ arc*-*-*)
  ;;
 
 arm*-*-*)
- cpu_obs="arch/arm.o arch/arm-get-next-pcs.o arm-tdep.o";;
+ cpu_obs="aarch32-tdep.o arch/aarch32.o arch/arm.o \
+ arch/arm-get-next-pcs.o arm-tdep.o";;
 
 hppa*-*-*)
  # Target: HP PA-RISC
--
2.20.1 (Apple Git-117)

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 3/5] Arm: Add xml unit tests

Alan Hayward
In reply to this post by Alan Hayward
Use the record_xml_tdesc tests to prove the new target descriptions
are identical to the previous xml file ones.

This is tested as part of gdb.gdb/unittest.exp.

gdb/ChangeLog:

2019-07-11  Alan Hayward  <[hidden email]>

        * arm-tdep.c (_initialize_arm_tdep): Add xml regression tests.
---
 gdb/arm-tdep.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 1d655eab5c..b500f193df 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -63,6 +63,7 @@
 
 #if GDB_SELF_TEST
 #include "gdbsupport/selftest.h"
+#include "aarch32-tdep.h"
 #endif
 
 static int arm_debug;
@@ -9547,6 +9548,23 @@ vfp - VFP co-processor."),
 
 #if GDB_SELF_TEST
   selftests::register_test ("arm-record", selftests::arm_record_test);
+
+  const target_desc *tdesc;
+
+  tdesc = arm_read_description (ARM_FP_TYPE_VFPV2);
+  selftests::record_xml_tdesc ("arm/arm-with-vfpv2.xml", tdesc);
+  tdesc = arm_read_description (ARM_FP_TYPE_VFPV3);
+  selftests::record_xml_tdesc ("arm/arm-with-vfpv3.xml",tdesc);
+  tdesc = arm_read_description (ARM_FP_TYPE_IWMMXT);
+  selftests::record_xml_tdesc ("arm/arm-with-iwmmxt.xml", tdesc);
+  tdesc = arm_read_mprofile_description (ARM_M_TYPE_M_PROFILE);
+  selftests::record_xml_tdesc ("arm/arm-with-m.xml", tdesc);
+  tdesc = arm_read_mprofile_description (ARM_M_TYPE_VFP_D16);
+  selftests::record_xml_tdesc ("arm/arm-with-m-vfp-d16.xml", tdesc);
+  tdesc = arm_read_mprofile_description (ARM_M_TYPE_WITH_FPA);
+  selftests::record_xml_tdesc ("arm/arm-with-m-fpa-layout.xml", tdesc);
+  tdesc = aarch32_read_description ();
+  selftests::record_xml_tdesc ("arm/arm-with-neon.xml", tdesc);
 #endif
 
 }
--
2.20.1 (Apple Git-117)

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 2/5] Arm: Use feature target descriptions

Alan Hayward
In reply to this post by Alan Hayward
In arm arm_create_target_description and
aarch32_create_target_description create feature based target descriptions
instead of returning the old style descriptions.

Ensure the descriptions are created in exactly the same way as the old xml
files.

Remove the old initialize calls.

Note this fixes the gdbserver build for AArch64.

gdb/ChangeLog:

2019-07-11  Alan Hayward  <[hidden email]>

        * arch/aarch32.c (aarch32_create_target_description): Create
        target descriptions using features.
        * arch/arm.c (arm_create_target_description)
        (arm_create_mprofile_target_description): Likewise.
        * arm-tdep.c (_initialize_arm_tdep): Remove tdesc init calls.
---
 gdb/arch/aarch32.c | 18 +++++++++++--
 gdb/arch/arm.c     | 67 +++++++++++++++++++++++++++++++---------------
 gdb/arm-tdep.c     | 17 ------------
 3 files changed, 62 insertions(+), 40 deletions(-)

diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
index f3cb8c7855..f15096e592 100644
--- a/gdb/arch/aarch32.c
+++ b/gdb/arch/aarch32.c
@@ -18,12 +18,26 @@
 #include "common/common-defs.h"
 #include "aarch32.h"
 
-extern struct target_desc *tdesc_arm_with_neon;
+#include "../features/arm/arm-core.c"
+#include "../features/arm/arm-vfpv3.c"
 
 /* See aarch32.h.  */
 
 target_desc *
 aarch32_create_target_description ()
 {
-  return tdesc_arm_with_neon;
+  target_desc *tdesc = allocate_target_description ();
+
+#ifndef IN_PROCESS_AGENT
+  set_tdesc_architecture (tdesc, "arm");
+#endif
+
+  long regnum = 0;
+
+  regnum = create_feature_arm_arm_core (tdesc, regnum);
+  /* Create a vfpv3 feature, then a blank NEON feature.  */
+  regnum = create_feature_arm_arm_vfpv3 (tdesc, regnum);
+  tdesc_create_feature (tdesc, "org.gnu.gdb.arm.neon");
+
+  return tdesc;
 }
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index 769d280a52..ea03dd1685 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -21,16 +21,12 @@
 #include "gdbsupport/common-regcache.h"
 #include "arm.h"
 
-extern struct target_desc *tdesc_arm_with_vfpv2;
-extern struct target_desc *tdesc_arm_with_vfpv3;
-extern struct target_desc *tdesc_arm_with_iwmmxt;
-
-/* Temporary ifdef.  Will be removed when target descriptions are switched.  */
-#ifndef GDBSERVER
-extern struct target_desc *tdesc_arm_with_m;
-extern struct target_desc *tdesc_arm_with_m_vfp_d16;
-extern struct target_desc *tdesc_arm_with_m_fpa_layout;
-#endif
+#include "../features/arm/arm-core.c"
+#include "../features/arm/arm-vfpv2.c"
+#include "../features/arm/arm-vfpv3.c"
+#include "../features/arm/xscale-iwmmxt.c"
+#include "../features/arm/arm-m-profile.c"
+#include "../features/arm/arm-m-profile-with-fpa.c"
 
 /* See arm.h.  */
 
@@ -389,23 +385,41 @@ shifted_reg_val (struct regcache *regcache, unsigned long inst,
 target_desc *
 arm_create_target_description (arm_fp_type fp_type)
 {
+  target_desc *tdesc = allocate_target_description ();
+
+#ifndef IN_PROCESS_AGENT
+  if (fp_type == ARM_FP_TYPE_IWMMXT)
+    set_tdesc_architecture (tdesc, "iwmmxt");
+  else
+    set_tdesc_architecture (tdesc, "arm");
+#endif
+
+  long regnum = 0;
+
+  regnum = create_feature_arm_arm_core (tdesc, regnum);
+
   switch (fp_type)
     {
     case ARM_FP_TYPE_NONE:
-      return nullptr;
+      break;
 
     case ARM_FP_TYPE_VFPV2:
-      return tdesc_arm_with_vfpv2;
+      regnum = create_feature_arm_arm_vfpv2 (tdesc, regnum);
+      break;
 
     case ARM_FP_TYPE_VFPV3:
-      return tdesc_arm_with_vfpv3;
+      regnum = create_feature_arm_arm_vfpv3 (tdesc, regnum);
+      break;
 
     case ARM_FP_TYPE_IWMMXT:
-      return tdesc_arm_with_iwmmxt;
+      regnum = create_feature_arm_xscale_iwmmxt (tdesc, regnum);
+      break;
 
     default:
       error (_("Invalid Arm FP type: %d"), fp_type);
     }
+
+  return tdesc;
 }
 
 /* See arch/arm.h.  */
@@ -413,21 +427,32 @@ arm_create_target_description (arm_fp_type fp_type)
 target_desc *
 arm_create_mprofile_target_description (arm_m_profile_type m_type)
 {
+  target_desc *tdesc = allocate_target_description ();
+
+#ifndef IN_PROCESS_AGENT
+  set_tdesc_architecture (tdesc, "arm");
+#endif
+
+  long regnum = 0;
+
   switch (m_type)
     {
-/* Temporary ifdef.  Will be removed when target descriptions are switched.  */
-#ifndef GDBSERVER
     case ARM_M_TYPE_M_PROFILE:
-      return tdesc_arm_with_m;
+      regnum = create_feature_arm_arm_m_profile (tdesc, regnum);
+      break;
 
     case ARM_M_TYPE_VFP_D16:
-      return tdesc_arm_with_m_fpa_layout;
+      regnum = create_feature_arm_arm_m_profile (tdesc, regnum);
+      regnum = create_feature_arm_arm_vfpv2 (tdesc, regnum);
+      break;
 
     case ARM_M_TYPE_WITH_FPA:
-      return tdesc_arm_with_m_vfp_d16;
-#endif
+      regnum = create_feature_arm_arm_m_profile_with_fpa (tdesc, regnum);
+      break;
+
     default:
       error (_("Invalid Arm M type: %d"), m_type);
     }
-}
 
+  return tdesc;
+}
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 1b19b72ca1..1d655eab5c 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -61,14 +61,6 @@
 #include "record-full.h"
 #include <algorithm>
 
-#include "features/arm/arm-with-m.c"
-#include "features/arm/arm-with-m-fpa-layout.c"
-#include "features/arm/arm-with-m-vfp-d16.c"
-#include "features/arm/arm-with-iwmmxt.c"
-#include "features/arm/arm-with-vfpv2.c"
-#include "features/arm/arm-with-vfpv3.c"
-#include "features/arm/arm-with-neon.c"
-
 #if GDB_SELF_TEST
 #include "gdbsupport/selftest.h"
 #endif
@@ -9451,15 +9443,6 @@ _initialize_arm_tdep (void)
   bfd_target_elf_flavour,
   arm_elf_osabi_sniffer);
 
-  /* Initialize the standard target descriptions.  */
-  initialize_tdesc_arm_with_m ();
-  initialize_tdesc_arm_with_m_fpa_layout ();
-  initialize_tdesc_arm_with_m_vfp_d16 ();
-  initialize_tdesc_arm_with_iwmmxt ();
-  initialize_tdesc_arm_with_vfpv2 ();
-  initialize_tdesc_arm_with_vfpv3 ();
-  initialize_tdesc_arm_with_neon ();
-
   /* Add root prefix command for all "set arm"/"show arm" commands.  */
   add_prefix_cmd ("arm", no_class, set_arm_command,
   _("Various ARM-specific commands."),
--
2.20.1 (Apple Git-117)

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 4/5] Arm: Use read_description funcs in gdbserver

Alan Hayward
In reply to this post by Alan Hayward
Switch gdbserver over to using feature target descriptions.

Add a function for determining the type of a given target description,
and use where required.

2019-07-11  Alan Hayward  <[hidden email]>

        * configure.srv: Add new files. Remove xml generated files.
        * linux-aarch32-low.c (initialize_low_arch_aarch32): Don't init
        registers.
        * linux-aarch32-low.h (tdesc_arm_with_neon): Remove.
        * linux-aarch32-tdesc.c: New file.
        * linux-aarch32-tdesc.h: New file.
        * linux-aarch64-low.c (aarch64_arch_setup): Call aarch32_linux_read_description.
        * linux-arm-low.c (init_registers_arm, tdesc_arm)
        (init_registers_arm_with_iwmmxt, tdesc_arm_with_iwmmxt)
        (init_registers_arm_with_vfpv2, tdesc_arm_with_vfpv2)
        (init_registers_arm_with_vfpv3, tdesc_arm_with_vfpv3): Remove.
        (arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset)
        (arm_store_vfpregset): Call arm_linux_get_tdesc_fp_type.
        (arm_read_description): Call arm_linux_read_description.
        (initialize_low_arch): Don't init registers.
        * linux-arm-tdesc.c: New file.
        * linux-arm-tdesc.h: New file.
---
 gdb/gdbserver/configure.srv         | 14 +++---
 gdb/gdbserver/linux-aarch32-low.c   |  2 -
 gdb/gdbserver/linux-aarch32-low.h   |  2 -
 gdb/gdbserver/linux-aarch32-tdesc.c | 46 +++++++++++++++++
 gdb/gdbserver/linux-aarch32-tdesc.h | 29 +++++++++++
 gdb/gdbserver/linux-aarch64-low.c   |  3 +-
 gdb/gdbserver/linux-arm-low.c       | 77 ++++++++++++++---------------
 gdb/gdbserver/linux-arm-tdesc.c     | 62 +++++++++++++++++++++++
 gdb/gdbserver/linux-arm-tdesc.h     | 29 +++++++++++
 9 files changed, 211 insertions(+), 53 deletions(-)
 create mode 100644 gdb/gdbserver/linux-aarch32-tdesc.c
 create mode 100644 gdb/gdbserver/linux-aarch32-tdesc.h
 create mode 100644 gdb/gdbserver/linux-arm-tdesc.c
 create mode 100644 gdb/gdbserver/linux-arm-tdesc.h

diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index c20177ef18..097dc4e9db 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -33,9 +33,10 @@ srv_linux_obj="linux-low.o linux-osdata.o linux-procfs.o linux-ptrace.o linux-wa
 # Input is taken from the "${target}" variable.
 
 case "${target}" in
-  aarch64*-*-linux*) srv_regobj="arm-with-neon.o"
- srv_tgtobj="linux-aarch64-low.o aarch64-linux-hw-point.o"
+  aarch64*-*-linux*) srv_tgtobj="linux-aarch64-low.o aarch64-linux-hw-point.o"
  srv_tgtobj="$srv_tgtobj linux-aarch32-low.o"
+ srv_tgtobj="$srv_tgtobj linux-aarch32-tdesc.o"
+ srv_tgtobj="${srv_tgtobj} arch/aarch32.o"
  srv_tgtobj="${srv_tgtobj} arch/arm.o"
  srv_tgtobj="$srv_tgtobj aarch64-linux.o"
  srv_tgtobj="$srv_tgtobj arch/aarch64-insn.o"
@@ -49,12 +50,11 @@ case "${target}" in
  ipa_obj="${ipa_obj} linux-aarch64-tdesc-ipa.o"
  ipa_obj="${ipa_obj} arch/aarch64-ipa.o"
  ;;
-  arm*-*-linux*) srv_regobj="reg-arm.o arm-with-iwmmxt.o"
- srv_regobj="${srv_regobj} arm-with-vfpv2.o"
- srv_regobj="${srv_regobj} arm-with-vfpv3.o"
- srv_regobj="${srv_regobj} arm-with-neon.o"
- srv_tgtobj="$srv_linux_obj linux-arm-low.o"
+  arm*-*-linux*) srv_tgtobj="$srv_linux_obj linux-arm-low.o"
+ srv_tgtobj="$srv_tgtobj linux-arm-tdesc.o"
  srv_tgtobj="$srv_tgtobj linux-aarch32-low.o"
+ srv_tgtobj="$srv_tgtobj linux-aarch32-tdesc.o"
+ srv_tgtobj="${srv_tgtobj} arch/aarch32.o"
  srv_tgtobj="${srv_tgtobj} arch/arm.o"
  srv_tgtobj="${srv_tgtobj} arch/arm-linux.o"
  srv_tgtobj="${srv_tgtobj} arch/arm-get-next-pcs.o"
diff --git a/gdb/gdbserver/linux-aarch32-low.c b/gdb/gdbserver/linux-aarch32-low.c
index a932373518..f1f2ae02a4 100644
--- a/gdb/gdbserver/linux-aarch32-low.c
+++ b/gdb/gdbserver/linux-aarch32-low.c
@@ -299,7 +299,5 @@ arm_breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
 void
 initialize_low_arch_aarch32 (void)
 {
-  init_registers_arm_with_neon ();
-
   initialize_regsets_info (&aarch32_regsets_info);
 }
diff --git a/gdb/gdbserver/linux-aarch32-low.h b/gdb/gdbserver/linux-aarch32-low.h
index 44e626c719..3078fca35e 100644
--- a/gdb/gdbserver/linux-aarch32-low.h
+++ b/gdb/gdbserver/linux-aarch32-low.h
@@ -36,6 +36,4 @@ void initialize_low_arch_aarch32 (void);
 void init_registers_arm_with_neon (void);
 int arm_is_thumb_mode (void);
 
-extern const struct target_desc *tdesc_arm_with_neon;
-
 #endif /* GDBSERVER_LINUX_AARCH32_LOW_H */
diff --git a/gdb/gdbserver/linux-aarch32-tdesc.c b/gdb/gdbserver/linux-aarch32-tdesc.c
new file mode 100644
index 0000000000..3c26df1f96
--- /dev/null
+++ b/gdb/gdbserver/linux-aarch32-tdesc.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 "server.h"
+#include "tdesc.h"
+#include "arch/aarch32.h"
+#include <inttypes.h>
+
+static struct target_desc *tdesc_aarch32;
+
+/* See linux-aarch32-tdesc.h.  */
+
+const target_desc *
+aarch32_linux_read_description ()
+{
+  if (tdesc_aarch32 == nullptr)
+    {
+      tdesc_aarch32 = aarch32_create_target_description ();
+
+      static const char *expedite_regs[] = { "r11", "sp", "pc", 0 };
+      init_target_desc (tdesc_aarch32, expedite_regs);
+    }
+  return tdesc_aarch32;
+}
+
+/* See linux-aarch32-tdesc.h.  */
+
+bool
+is_aarch32_linux_description (const target_desc *tdesc)
+{
+  return tdesc != nullptr && tdesc == tdesc_aarch32;
+}
diff --git a/gdb/gdbserver/linux-aarch32-tdesc.h b/gdb/gdbserver/linux-aarch32-tdesc.h
new file mode 100644
index 0000000000..8887cbfdf4
--- /dev/null
+++ b/gdb/gdbserver/linux-aarch32-tdesc.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 GDBSERVER_LINUX_AARCH32_TDESC_H
+#define GDBSERVER_LINUX_AARCH32_TDESC_H
+
+/* Return the AArch32 target description.  */
+
+const target_desc * aarch32_linux_read_description ();
+
+/* Return true if TDESC is the AArch32 target description.  */
+
+bool is_aarch32_linux_description (const target_desc *tdesc);
+
+#endif /* linux-aarch32-tdesc.h.  */
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 5aea5de372..ab2f40ea98 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -39,6 +39,7 @@
 
 #include "gdb_proc_service.h"
 #include "arch/aarch64.h"
+#include "linux-aarch32-tdesc.h"
 #include "linux-aarch64-tdesc.h"
 #include "nat/aarch64-sve-linux-ptrace.h"
 #include "tdesc.h"
@@ -527,7 +528,7 @@ aarch64_arch_setup (void)
       current_process ()->tdesc = aarch64_linux_read_description (vq, pauth_p);
     }
   else
-    current_process ()->tdesc = tdesc_arm_with_neon;
+    current_process ()->tdesc = aarch32_linux_read_description ();
 
   aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread));
 }
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 7d6c9d9dd9..0e30af3562 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -22,6 +22,8 @@
 #include "arch/arm-linux.h"
 #include "arch/arm-get-next-pcs.h"
 #include "linux-aarch32-low.h"
+#include "linux-aarch32-tdesc.h"
+#include "linux-arm-tdesc.h"
 
 #include <sys/uio.h>
 /* Don't include elf.h if linux/elf.h got included by gdb_proc_service.h.
@@ -33,19 +35,6 @@
 #include <signal.h>
 #include <sys/syscall.h>
 
-/* Defined in auto-generated files.  */
-void init_registers_arm (void);
-extern const struct target_desc *tdesc_arm;
-
-void init_registers_arm_with_iwmmxt (void);
-extern const struct target_desc *tdesc_arm_with_iwmmxt;
-
-void init_registers_arm_with_vfpv2 (void);
-extern const struct target_desc *tdesc_arm_with_vfpv2;
-
-void init_registers_arm_with_vfpv3 (void);
-extern const struct target_desc *tdesc_arm_with_vfpv3;
-
 #ifndef PTRACE_GET_THREAD_AREA
 #define PTRACE_GET_THREAD_AREA 22
 #endif
@@ -175,7 +164,7 @@ arm_cannot_fetch_register (int regno)
 static void
 arm_fill_wmmxregset (struct regcache *regcache, void *buf)
 {
-  if (regcache->tdesc != tdesc_arm_with_iwmmxt)
+  if (arm_linux_get_tdesc_fp_type (regcache->tdesc) != ARM_FP_TYPE_IWMMXT)
     return;
 
   for (int i = 0; i < 16; i++)
@@ -190,7 +179,7 @@ arm_fill_wmmxregset (struct regcache *regcache, void *buf)
 static void
 arm_store_wmmxregset (struct regcache *regcache, const void *buf)
 {
-  if (regcache->tdesc != tdesc_arm_with_iwmmxt)
+  if (arm_linux_get_tdesc_fp_type (regcache->tdesc) != ARM_FP_TYPE_IWMMXT)
     return;
 
   for (int i = 0; i < 16; i++)
@@ -207,13 +196,19 @@ arm_fill_vfpregset (struct regcache *regcache, void *buf)
 {
   int num;
 
-  if (regcache->tdesc == tdesc_arm_with_neon
-      || regcache->tdesc == tdesc_arm_with_vfpv3)
+  if (is_aarch32_linux_description (regcache->tdesc))
     num = 32;
-  else if (regcache->tdesc == tdesc_arm_with_vfpv2)
-    num = 16;
   else
-    return;
+    {
+      arm_fp_type fp_type = arm_linux_get_tdesc_fp_type (regcache->tdesc);
+
+      if (fp_type == ARM_FP_TYPE_VFPV3)
+ num = 32;
+      else if (fp_type == ARM_FP_TYPE_VFPV2)
+ num = 16;
+      else
+ return;
+    }
 
   arm_fill_vfpregset_num (regcache, buf, num);
 }
@@ -230,13 +225,19 @@ arm_store_vfpregset (struct regcache *regcache, const void *buf)
 {
   int num;
 
-  if (regcache->tdesc == tdesc_arm_with_neon
-      || regcache->tdesc == tdesc_arm_with_vfpv3)
+  if (is_aarch32_linux_description (regcache->tdesc))
     num = 32;
-  else if (regcache->tdesc == tdesc_arm_with_vfpv2)
-    num = 16;
   else
-    return;
+    {
+      arm_fp_type fp_type = arm_linux_get_tdesc_fp_type (regcache->tdesc);
+
+      if (fp_type == ARM_FP_TYPE_VFPV3)
+ num = 32;
+      else if (fp_type == ARM_FP_TYPE_VFPV2)
+ num = 16;
+      else
+ return;
+    }
 
   arm_store_vfpregset_num (regcache, buf, num);
 }
@@ -849,7 +850,7 @@ arm_read_description (void)
   unsigned long arm_hwcap = linux_get_hwcap (4);
 
   if (arm_hwcap & HWCAP_IWMMXT)
-    return tdesc_arm_with_iwmmxt;
+    return arm_linux_read_description (ARM_FP_TYPE_IWMMXT);
 
   if (arm_hwcap & HWCAP_VFP)
     {
@@ -859,21 +860,21 @@ arm_read_description (void)
       errno = 0;
       char *buf = (char *) alloca (ARM_VFP3_REGS_SIZE);
       if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0 && errno == EIO)
- return tdesc_arm;
+ return arm_linux_read_description (ARM_FP_TYPE_NONE);
 
       /* NEON implies either no VFP, or VFPv3-D32.  We only support
  it with VFP.  */
       if (arm_hwcap & HWCAP_NEON)
- return tdesc_arm_with_neon;
+ return aarch32_linux_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
- return tdesc_arm_with_vfpv3;
+ return arm_linux_read_description (ARM_FP_TYPE_VFPV3);
       else
- return tdesc_arm_with_vfpv2;
+ return arm_linux_read_description (ARM_FP_TYPE_VFPV2);
     }
 
   /* The default configuration uses legacy FPA registers, probably
      simulated.  */
-  return tdesc_arm;
+  return arm_linux_read_description (ARM_FP_TYPE_NONE);
 }
 
 static void
@@ -997,10 +998,11 @@ arm_regs_info (void)
   const struct target_desc *tdesc = current_process ()->tdesc;
 
   if (have_ptrace_getregset == 1
-      && (tdesc == tdesc_arm_with_neon || tdesc == tdesc_arm_with_vfpv3))
+      && (is_aarch32_linux_description (tdesc)
+  || arm_linux_get_tdesc_fp_type (tdesc) == ARM_FP_TYPE_VFPV3))
     return &regs_info_aarch32;
-  else
-    return &regs_info_arm;
+
+  return &regs_info_arm;
 }
 
 struct linux_target_ops the_low_target = {
@@ -1045,13 +1047,6 @@ struct linux_target_ops the_low_target = {
 void
 initialize_low_arch (void)
 {
-  /* Initialize the Linux target descriptions.  */
-  init_registers_arm ();
-  init_registers_arm_with_iwmmxt ();
-  init_registers_arm_with_vfpv2 ();
-  init_registers_arm_with_vfpv3 ();
-
   initialize_low_arch_aarch32 ();
-
   initialize_regsets_info (&arm_regsets_info);
 }
diff --git a/gdb/gdbserver/linux-arm-tdesc.c b/gdb/gdbserver/linux-arm-tdesc.c
new file mode 100644
index 0000000000..cdc4dab87a
--- /dev/null
+++ b/gdb/gdbserver/linux-arm-tdesc.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 "server.h"
+#include "tdesc.h"
+#include "arch/arm.h"
+#include <inttypes.h>
+
+/* All possible Arm target descriptors.  */
+static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID];
+
+/* See linux-arm-tdesc.h.  */
+
+const target_desc *
+arm_linux_read_description (arm_fp_type fp_type)
+{
+  struct target_desc *tdesc = tdesc_arm_list[fp_type];
+
+  if (tdesc == nullptr)
+    {
+      tdesc = arm_create_target_description (fp_type);
+
+      static const char *expedite_regs[] = { "r11", "sp", "pc", 0 };
+      init_target_desc (tdesc, expedite_regs);
+
+      tdesc_arm_list[fp_type] = tdesc;
+    }
+
+  return tdesc;
+}
+
+/* See linux-arm-tdesc.h.  */
+
+arm_fp_type
+arm_linux_get_tdesc_fp_type (const target_desc *tdesc)
+{
+  gdb_assert (tdesc != nullptr);
+
+  /* Many of the tdesc_arm_list entries may not have been initialised yet.  This
+     is ok, because tdesc must be one of the initialised ones.  */
+  for (int i = ARM_FP_TYPE_NONE; i < ARM_FP_TYPE_INVALID; i++)
+    {
+      if (tdesc == tdesc_arm_list[i])
+ return (arm_fp_type) i;
+    }
+
+  return ARM_FP_TYPE_INVALID;
+}
diff --git a/gdb/gdbserver/linux-arm-tdesc.h b/gdb/gdbserver/linux-arm-tdesc.h
new file mode 100644
index 0000000000..51efb9fb48
--- /dev/null
+++ b/gdb/gdbserver/linux-arm-tdesc.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 GDBSERVER_LINUX_ARM_TDESC_H
+#define GDBSERVER_LINUX_ARM_TDESC_H
+
+/* Return the Arm target description with fp registers FP_TYPE.  */
+
+const target_desc * arm_linux_read_description (arm_fp_type fp_type);
+
+/* For a target description TDESC, return its fp type.  */
+
+arm_fp_type arm_linux_get_tdesc_fp_type (const target_desc *tdesc);
+
+#endif /* linux-arm-tdesc.h.  */
--
2.20.1 (Apple Git-117)

Reply | Threaded
Open this post in threaded view
|

[PATCH v2 5/5] Arm: Remove unused feature files and tests

Alan Hayward
In reply to this post by Alan Hayward
Remove the xml tests. Now that it has been proven the new descriptions
are identical, there is no need to keep testing that.  Also, it would
prevent the old xml files from being removed.

Remove the old xml files from gdbserver and delete them.

gdb/ChangeLog:

2019-07-11  Alan Hayward  <[hidden email]>

        * arm-tdep.c (_initialize_arm_tdep): Remove xml tests.
        * features/arm/arm-with-iwmmxt.c: Remove.
        * features/arm/arm-with-iwmmxt.xml: Remove.
        * features/arm/arm-with-m-fpa-layout.c: Remove.
        * features/arm/arm-with-m-fpa-layout.xml: Remove.
        * features/arm/arm-with-m-vfp-d16.c: Remove.
        * features/arm/arm-with-m-vfp-d16.xml: Remove.
        * features/arm/arm-with-m.c: Remove.
        * features/arm/arm-with-m.xml: Remove.
        * features/arm/arm-with-neon.c: Remove.
        * features/arm/arm-with-neon.xml: Remove.
        * features/arm/arm-with-vfpv2.c: Remove.
        * features/arm/arm-with-vfpv2.xml: Remove.
        * features/arm/arm-with-vfpv3.c: Remove.
        * features/arm/arm-with-vfpv3.xml: Remove.

gdb/gdbserver/ChangeLog:

2019-07-11  Alan Hayward  <[hidden email]>

        * configure.srv: Remove Arm xml files.
---
 gdb/arm-tdep.c                             | 18 -----
 gdb/features/arm/arm-with-iwmmxt.c         | 83 ----------------------
 gdb/features/arm/arm-with-iwmmxt.xml       | 13 ----
 gdb/features/arm/arm-with-m-fpa-layout.c   | 46 ------------
 gdb/features/arm/arm-with-m-fpa-layout.xml | 46 ------------
 gdb/features/arm/arm-with-m-vfp-d16.c      | 56 ---------------
 gdb/features/arm/arm-with-m-vfp-d16.xml    | 14 ----
 gdb/features/arm/arm-with-m.c              | 37 ----------
 gdb/features/arm/arm-with-m.xml            | 12 ----
 gdb/features/arm/arm-with-neon.c           | 74 -------------------
 gdb/features/arm/arm-with-neon.xml         | 14 ----
 gdb/features/arm/arm-with-vfpv2.c          | 56 ---------------
 gdb/features/arm/arm-with-vfpv2.xml        | 13 ----
 gdb/features/arm/arm-with-vfpv3.c          | 72 -------------------
 gdb/features/arm/arm-with-vfpv3.xml        | 13 ----
 gdb/gdbserver/configure.srv                |  8 ---
 16 files changed, 575 deletions(-)
 delete mode 100644 gdb/features/arm/arm-with-iwmmxt.c
 delete mode 100644 gdb/features/arm/arm-with-iwmmxt.xml
 delete mode 100644 gdb/features/arm/arm-with-m-fpa-layout.c
 delete mode 100644 gdb/features/arm/arm-with-m-fpa-layout.xml
 delete mode 100644 gdb/features/arm/arm-with-m-vfp-d16.c
 delete mode 100644 gdb/features/arm/arm-with-m-vfp-d16.xml
 delete mode 100644 gdb/features/arm/arm-with-m.c
 delete mode 100644 gdb/features/arm/arm-with-m.xml
 delete mode 100644 gdb/features/arm/arm-with-neon.c
 delete mode 100644 gdb/features/arm/arm-with-neon.xml
 delete mode 100644 gdb/features/arm/arm-with-vfpv2.c
 delete mode 100644 gdb/features/arm/arm-with-vfpv2.xml
 delete mode 100644 gdb/features/arm/arm-with-vfpv3.c
 delete mode 100644 gdb/features/arm/arm-with-vfpv3.xml

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index b500f193df..1d655eab5c 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -63,7 +63,6 @@
 
 #if GDB_SELF_TEST
 #include "gdbsupport/selftest.h"
-#include "aarch32-tdep.h"
 #endif
 
 static int arm_debug;
@@ -9548,23 +9547,6 @@ vfp - VFP co-processor."),
 
 #if GDB_SELF_TEST
   selftests::register_test ("arm-record", selftests::arm_record_test);
-
-  const target_desc *tdesc;
-
-  tdesc = arm_read_description (ARM_FP_TYPE_VFPV2);
-  selftests::record_xml_tdesc ("arm/arm-with-vfpv2.xml", tdesc);
-  tdesc = arm_read_description (ARM_FP_TYPE_VFPV3);
-  selftests::record_xml_tdesc ("arm/arm-with-vfpv3.xml",tdesc);
-  tdesc = arm_read_description (ARM_FP_TYPE_IWMMXT);
-  selftests::record_xml_tdesc ("arm/arm-with-iwmmxt.xml", tdesc);
-  tdesc = arm_read_mprofile_description (ARM_M_TYPE_M_PROFILE);
-  selftests::record_xml_tdesc ("arm/arm-with-m.xml", tdesc);
-  tdesc = arm_read_mprofile_description (ARM_M_TYPE_VFP_D16);
-  selftests::record_xml_tdesc ("arm/arm-with-m-vfp-d16.xml", tdesc);
-  tdesc = arm_read_mprofile_description (ARM_M_TYPE_WITH_FPA);
-  selftests::record_xml_tdesc ("arm/arm-with-m-fpa-layout.xml", tdesc);
-  tdesc = aarch32_read_description ();
-  selftests::record_xml_tdesc ("arm/arm-with-neon.xml", tdesc);
 #endif
 
 }
diff --git a/gdb/features/arm/arm-with-iwmmxt.c b/gdb/features/arm/arm-with-iwmmxt.c
deleted file mode 100644
index 8729285a0e..0000000000
--- a/gdb/features/arm/arm-with-iwmmxt.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: arm-with-iwmmxt.xml */
-
-#include "defs.h"
-#include "osabi.h"
-#include "target-descriptions.h"
-
-struct target_desc *tdesc_arm_with_iwmmxt;
-static void
-initialize_tdesc_arm_with_iwmmxt (void)
-{
-  struct target_desc *result = allocate_target_description ();
-  set_tdesc_architecture (result, bfd_scan_arch ("iwmmxt"));
-
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.core");
-  tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr");
-  tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr");
-  tdesc_create_reg (feature, "cpsr", 25, 1, NULL, 32, "int");
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.xscale.iwmmxt");
-  tdesc_type *element_type;
-  element_type = tdesc_named_type (feature, "uint8");
-  tdesc_create_vector (feature, "iwmmxt_v8u8", element_type, 8);
-
-  element_type = tdesc_named_type (feature, "uint16");
-  tdesc_create_vector (feature, "iwmmxt_v4u16", element_type, 4);
-
-  element_type = tdesc_named_type (feature, "uint32");
-  tdesc_create_vector (feature, "iwmmxt_v2u32", element_type, 2);
-
-  tdesc_type_with_fields *type_with_fields;
-  type_with_fields = tdesc_create_union (feature, "iwmmxt_vec64i");
-  tdesc_type *field_type;
-  field_type = tdesc_named_type (feature, "iwmmxt_v8u8");
-  tdesc_add_field (type_with_fields, "u8", field_type);
-  field_type = tdesc_named_type (feature, "iwmmxt_v4u16");
-  tdesc_add_field (type_with_fields, "u16", field_type);
-  field_type = tdesc_named_type (feature, "iwmmxt_v2u32");
-  tdesc_add_field (type_with_fields, "u32", field_type);
-  field_type = tdesc_named_type (feature, "uint64");
-  tdesc_add_field (type_with_fields, "u64", field_type);
-
-  tdesc_create_reg (feature, "wR0", 26, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR1", 27, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR2", 28, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR3", 29, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR4", 30, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR5", 31, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR6", 32, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR7", 33, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR8", 34, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR9", 35, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR10", 36, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR11", 37, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR12", 38, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR13", 39, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR14", 40, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wR15", 41, 1, NULL, 64, "iwmmxt_vec64i");
-  tdesc_create_reg (feature, "wCSSF", 42, 1, "vector", 32, "int");
-  tdesc_create_reg (feature, "wCASF", 43, 1, "vector", 32, "int");
-  tdesc_create_reg (feature, "wCGR0", 44, 1, "vector", 32, "int");
-  tdesc_create_reg (feature, "wCGR1", 45, 1, "vector", 32, "int");
-  tdesc_create_reg (feature, "wCGR2", 46, 1, "vector", 32, "int");
-  tdesc_create_reg (feature, "wCGR3", 47, 1, "vector", 32, "int");
-
-  tdesc_arm_with_iwmmxt = result;
-}
diff --git a/gdb/features/arm/arm-with-iwmmxt.xml b/gdb/features/arm/arm-with-iwmmxt.xml
deleted file mode 100644
index 9455cb5f93..0000000000
--- a/gdb/features/arm/arm-with-iwmmxt.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2007-2019 Free Software Foundation, Inc.
-
-     Copying and distribution of this file, with or without modification,
-     are permitted in any medium without royalty provided the copyright
-     notice and this notice are preserved.  -->
-
-<!DOCTYPE target SYSTEM "gdb-target.dtd">
-<target>
-  <architecture>iwmmxt</architecture>
-  <xi:include href="arm-core.xml"/>
-  <xi:include href="xscale-iwmmxt.xml"/>
-</target>
diff --git a/gdb/features/arm/arm-with-m-fpa-layout.c b/gdb/features/arm/arm-with-m-fpa-layout.c
deleted file mode 100644
index 99bebc311c..0000000000
--- a/gdb/features/arm/arm-with-m-fpa-layout.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: arm-with-m-fpa-layout.xml */
-
-#include "defs.h"
-#include "osabi.h"
-#include "target-descriptions.h"
-
-struct target_desc *tdesc_arm_with_m_fpa_layout;
-static void
-initialize_tdesc_arm_with_m_fpa_layout (void)
-{
-  struct target_desc *result = allocate_target_description ();
-  set_tdesc_architecture (result, bfd_scan_arch ("arm"));
-
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.m-profile");
-  tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr");
-  tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr");
-  tdesc_create_reg (feature, "", 16, 1, NULL, 96, "arm_fpa_ext");
-  tdesc_create_reg (feature, "", 17, 1, NULL, 96, "arm_fpa_ext");
-  tdesc_create_reg (feature, "", 18, 1, NULL, 96, "arm_fpa_ext");
-  tdesc_create_reg (feature, "", 19, 1, NULL, 96, "arm_fpa_ext");
-  tdesc_create_reg (feature, "", 20, 1, NULL, 96, "arm_fpa_ext");
-  tdesc_create_reg (feature, "", 21, 1, NULL, 96, "arm_fpa_ext");
-  tdesc_create_reg (feature, "", 22, 1, NULL, 96, "arm_fpa_ext");
-  tdesc_create_reg (feature, "", 23, 1, NULL, 96, "arm_fpa_ext");
-  tdesc_create_reg (feature, "", 24, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "xpsr", 25, 1, NULL, 32, "int");
-
-  tdesc_arm_with_m_fpa_layout = result;
-}
diff --git a/gdb/features/arm/arm-with-m-fpa-layout.xml b/gdb/features/arm/arm-with-m-fpa-layout.xml
deleted file mode 100644
index 445fbb11ed..0000000000
--- a/gdb/features/arm/arm-with-m-fpa-layout.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2007-2019 Free Software Foundation, Inc.
-
-     Copying and distribution of this file, with or without modification,
-     are permitted in any medium without royalty provided the copyright
-     notice and this notice are preserved.  -->
-
-<!-- A target description for an M-profile device, for stubs that
-     transfer registers using the historical fpa layout.  -->
-
-<!DOCTYPE target SYSTEM "gdb-target.dtd">
-<target>
-<architecture>arm</architecture>
-<feature name="org.gnu.gdb.arm.m-profile">
-  <reg name="r0" bitsize="32"/>
-  <reg name="r1" bitsize="32"/>
-  <reg name="r2" bitsize="32"/>
-  <reg name="r3" bitsize="32"/>
-  <reg name="r4" bitsize="32"/>
-  <reg name="r5" bitsize="32"/>
-  <reg name="r6" bitsize="32"/>
-  <reg name="r7" bitsize="32"/>
-  <reg name="r8" bitsize="32"/>
-  <reg name="r9" bitsize="32"/>
-  <reg name="r10" bitsize="32"/>
-  <reg name="r11" bitsize="32"/>
-  <reg name="r12" bitsize="32"/>
-  <reg name="sp" bitsize="32" type="data_ptr"/>
-  <reg name="lr" bitsize="32"/>
-  <reg name="pc" bitsize="32" type="code_ptr"/>
-
-  <!-- Slack for unused FPA registers (f0-f7 + fps).
-       See arm-fpa.xml.  -->
-  <reg name="" bitsize="96" type="arm_fpa_ext" regnum="16"/>
-  <reg name="" bitsize="96" type="arm_fpa_ext"/>
-  <reg name="" bitsize="96" type="arm_fpa_ext"/>
-  <reg name="" bitsize="96" type="arm_fpa_ext"/>
-  <reg name="" bitsize="96" type="arm_fpa_ext"/>
-  <reg name="" bitsize="96" type="arm_fpa_ext"/>
-  <reg name="" bitsize="96" type="arm_fpa_ext"/>
-  <reg name="" bitsize="96" type="arm_fpa_ext"/>
-  <reg name="" bitsize="32"/>
-
-  <reg name="xpsr" bitsize="32" regnum="25"/>
-</feature>
-</target>
diff --git a/gdb/features/arm/arm-with-m-vfp-d16.c b/gdb/features/arm/arm-with-m-vfp-d16.c
deleted file mode 100644
index ab9167316a..0000000000
--- a/gdb/features/arm/arm-with-m-vfp-d16.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: arm-with-m-vfp-d16.xml */
-
-#include "defs.h"
-#include "osabi.h"
-#include "target-descriptions.h"
-
-struct target_desc *tdesc_arm_with_m_vfp_d16;
-static void
-initialize_tdesc_arm_with_m_vfp_d16 (void)
-{
-  struct target_desc *result = allocate_target_description ();
-  set_tdesc_architecture (result, bfd_scan_arch ("arm"));
-
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.m-profile");
-  tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr");
-  tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr");
-  tdesc_create_reg (feature, "xpsr", 25, 1, NULL, 32, "int");
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.vfp");
-  tdesc_create_reg (feature, "d0", 26, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d1", 27, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d2", 28, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d3", 29, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d4", 30, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d5", 31, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d6", 32, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d7", 33, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d8", 34, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d9", 35, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d10", 36, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d11", 37, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d12", 38, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d13", 39, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d14", 40, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d15", 41, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "fpscr", 42, 1, "float", 32, "int");
-
-  tdesc_arm_with_m_vfp_d16 = result;
-}
diff --git a/gdb/features/arm/arm-with-m-vfp-d16.xml b/gdb/features/arm/arm-with-m-vfp-d16.xml
deleted file mode 100644
index b9933a8e65..0000000000
--- a/gdb/features/arm/arm-with-m-vfp-d16.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2010-2019 Free Software Foundation, Inc.
-
-     Copying and distribution of this file, with or without modification,
-     are permitted in any medium without royalty provided the copyright
-     notice and this notice are preserved.  -->
-
-<!DOCTYPE target SYSTEM "gdb-target.dtd">
-<target>
-  <architecture>arm</architecture>
-  <xi:include href="arm-m-profile.xml"/>
-  <!-- Layout of vfpv4-sp-d16 is identical to vfpv2 -->
-  <xi:include href="arm-vfpv2.xml"/>
-</target>
diff --git a/gdb/features/arm/arm-with-m.c b/gdb/features/arm/arm-with-m.c
deleted file mode 100644
index 619fd72430..0000000000
--- a/gdb/features/arm/arm-with-m.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: arm-with-m.xml */
-
-#include "defs.h"
-#include "osabi.h"
-#include "target-descriptions.h"
-
-struct target_desc *tdesc_arm_with_m;
-static void
-initialize_tdesc_arm_with_m (void)
-{
-  struct target_desc *result = allocate_target_description ();
-  set_tdesc_architecture (result, bfd_scan_arch ("arm"));
-
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.m-profile");
-  tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr");
-  tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr");
-  tdesc_create_reg (feature, "xpsr", 25, 1, NULL, 32, "int");
-
-  tdesc_arm_with_m = result;
-}
diff --git a/gdb/features/arm/arm-with-m.xml b/gdb/features/arm/arm-with-m.xml
deleted file mode 100644
index 7ed68fa0d1..0000000000
--- a/gdb/features/arm/arm-with-m.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2010-2019 Free Software Foundation, Inc.
-
-     Copying and distribution of this file, with or without modification,
-     are permitted in any medium without royalty provided the copyright
-     notice and this notice are preserved.  -->
-
-<!DOCTYPE target SYSTEM "gdb-target.dtd">
-<target>
-  <architecture>arm</architecture>
-  <xi:include href="arm-m-profile.xml"/>
-</target>
diff --git a/gdb/features/arm/arm-with-neon.c b/gdb/features/arm/arm-with-neon.c
deleted file mode 100644
index 682ad758c0..0000000000
--- a/gdb/features/arm/arm-with-neon.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: arm-with-neon.xml */
-
-#include "defs.h"
-#include "osabi.h"
-#include "target-descriptions.h"
-
-struct target_desc *tdesc_arm_with_neon;
-static void
-initialize_tdesc_arm_with_neon (void)
-{
-  struct target_desc *result = allocate_target_description ();
-  set_tdesc_architecture (result, bfd_scan_arch ("arm"));
-
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.core");
-  tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr");
-  tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr");
-  tdesc_create_reg (feature, "cpsr", 25, 1, NULL, 32, "int");
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.vfp");
-  tdesc_create_reg (feature, "d0", 26, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d1", 27, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d2", 28, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d3", 29, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d4", 30, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d5", 31, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d6", 32, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d7", 33, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d8", 34, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d9", 35, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d10", 36, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d11", 37, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d12", 38, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d13", 39, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d14", 40, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d15", 41, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d16", 42, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d17", 43, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d18", 44, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d19", 45, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d20", 46, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d21", 47, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d22", 48, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d23", 49, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d24", 50, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d25", 51, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d26", 52, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d27", 53, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d28", 54, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d29", 55, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d30", 56, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d31", 57, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "fpscr", 58, 1, "float", 32, "int");
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.neon");
-
-  tdesc_arm_with_neon = result;
-}
diff --git a/gdb/features/arm/arm-with-neon.xml b/gdb/features/arm/arm-with-neon.xml
deleted file mode 100644
index 8a9ade101a..0000000000
--- a/gdb/features/arm/arm-with-neon.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2009-2019 Free Software Foundation, Inc.
-
-     Copying and distribution of this file, with or without modification,
-     are permitted in any medium without royalty provided the copyright
-     notice and this notice are preserved.  -->
-
-<!DOCTYPE target SYSTEM "gdb-target.dtd">
-<target>
-  <architecture>arm</architecture>
-  <xi:include href="arm-core.xml"/>
-  <xi:include href="arm-vfpv3.xml"/>
-  <feature name="org.gnu.gdb.arm.neon"/>
-</target>
diff --git a/gdb/features/arm/arm-with-vfpv2.c b/gdb/features/arm/arm-with-vfpv2.c
deleted file mode 100644
index 368256ccef..0000000000
--- a/gdb/features/arm/arm-with-vfpv2.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: arm-with-vfpv2.xml */
-
-#include "defs.h"
-#include "osabi.h"
-#include "target-descriptions.h"
-
-struct target_desc *tdesc_arm_with_vfpv2;
-static void
-initialize_tdesc_arm_with_vfpv2 (void)
-{
-  struct target_desc *result = allocate_target_description ();
-  set_tdesc_architecture (result, bfd_scan_arch ("arm"));
-
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.core");
-  tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr");
-  tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr");
-  tdesc_create_reg (feature, "cpsr", 25, 1, NULL, 32, "int");
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.vfp");
-  tdesc_create_reg (feature, "d0", 26, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d1", 27, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d2", 28, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d3", 29, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d4", 30, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d5", 31, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d6", 32, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d7", 33, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d8", 34, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d9", 35, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d10", 36, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d11", 37, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d12", 38, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d13", 39, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d14", 40, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d15", 41, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "fpscr", 42, 1, "float", 32, "int");
-
-  tdesc_arm_with_vfpv2 = result;
-}
diff --git a/gdb/features/arm/arm-with-vfpv2.xml b/gdb/features/arm/arm-with-vfpv2.xml
deleted file mode 100644
index 881ac6385b..0000000000
--- a/gdb/features/arm/arm-with-vfpv2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2009-2019 Free Software Foundation, Inc.
-
-     Copying and distribution of this file, with or without modification,
-     are permitted in any medium without royalty provided the copyright
-     notice and this notice are preserved.  -->
-
-<!DOCTYPE target SYSTEM "gdb-target.dtd">
-<target>
-  <architecture>arm</architecture>
-  <xi:include href="arm-core.xml"/>
-  <xi:include href="arm-vfpv2.xml"/>
-</target>
diff --git a/gdb/features/arm/arm-with-vfpv3.c b/gdb/features/arm/arm-with-vfpv3.c
deleted file mode 100644
index ade7c95f46..0000000000
--- a/gdb/features/arm/arm-with-vfpv3.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: arm-with-vfpv3.xml */
-
-#include "defs.h"
-#include "osabi.h"
-#include "target-descriptions.h"
-
-struct target_desc *tdesc_arm_with_vfpv3;
-static void
-initialize_tdesc_arm_with_vfpv3 (void)
-{
-  struct target_desc *result = allocate_target_description ();
-  set_tdesc_architecture (result, bfd_scan_arch ("arm"));
-
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.core");
-  tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32");
-  tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr");
-  tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr");
-  tdesc_create_reg (feature, "cpsr", 25, 1, NULL, 32, "int");
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.vfp");
-  tdesc_create_reg (feature, "d0", 26, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d1", 27, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d2", 28, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d3", 29, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d4", 30, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d5", 31, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d6", 32, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d7", 33, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d8", 34, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d9", 35, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d10", 36, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d11", 37, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d12", 38, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d13", 39, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d14", 40, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d15", 41, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d16", 42, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d17", 43, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d18", 44, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d19", 45, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d20", 46, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d21", 47, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d22", 48, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d23", 49, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d24", 50, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d25", 51, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d26", 52, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d27", 53, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d28", 54, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d29", 55, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d30", 56, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "d31", 57, 1, NULL, 64, "ieee_double");
-  tdesc_create_reg (feature, "fpscr", 58, 1, "float", 32, "int");
-
-  tdesc_arm_with_vfpv3 = result;
-}
diff --git a/gdb/features/arm/arm-with-vfpv3.xml b/gdb/features/arm/arm-with-vfpv3.xml
deleted file mode 100644
index 45b9cda688..0000000000
--- a/gdb/features/arm/arm-with-vfpv3.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2009-2019 Free Software Foundation, Inc.
-
-     Copying and distribution of this file, with or without modification,
-     are permitted in any medium without royalty provided the copyright
-     notice and this notice are preserved.  -->
-
-<!DOCTYPE target SYSTEM "gdb-target.dtd">
-<target>
-  <architecture>arm</architecture>
-  <xi:include href="arm-core.xml"/>
-  <xi:include href="arm-vfpv3.xml"/>
-</target>
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index 097dc4e9db..66d3d426ac 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -58,14 +58,6 @@ case "${target}" in
  srv_tgtobj="${srv_tgtobj} arch/arm.o"
  srv_tgtobj="${srv_tgtobj} arch/arm-linux.o"
  srv_tgtobj="${srv_tgtobj} arch/arm-get-next-pcs.o"
- srv_xmlfiles="arm/arm-with-iwmmxt.xml"
- srv_xmlfiles="${srv_xmlfiles} arm/arm-with-vfpv2.xml"
- srv_xmlfiles="${srv_xmlfiles} arm/arm-with-vfpv3.xml"
- srv_xmlfiles="${srv_xmlfiles} arm/arm-with-neon.xml"
- srv_xmlfiles="${srv_xmlfiles} arm/arm-core.xml"
- srv_xmlfiles="${srv_xmlfiles} arm/xscale-iwmmxt.xml"
- srv_xmlfiles="${srv_xmlfiles} arm/arm-vfpv2.xml"
- srv_xmlfiles="${srv_xmlfiles} arm/arm-vfpv3.xml"
  srv_linux_usrregs=yes
  srv_linux_regsets=yes
  srv_linux_thread_db=yes
--
2.20.1 (Apple Git-117)

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 1/5] Arm: Add read_description read funcs and use in GDB

Simon Marchi-4
In reply to this post by Alan Hayward
Hi Alan,

Just this nit:

> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
> index 7b60a9a0c3..4db0288e68 100644
> --- a/gdb/aarch64-linux-nat.c
> +++ b/gdb/aarch64-linux-nat.c
> @@ -27,9 +27,11 @@
>  #include "target-descriptions.h"
>  #include "auxv.h"
>  #include "gdbcmd.h"
> +#include "arch/arm.h"
>  #include "aarch64-tdep.h"
>  #include "aarch64-linux-tdep.h"
>  #include "aarch32-linux-nat.h"
> +#include "aarch32-tdep.h"
>  #include "arch/arm.h"
>  #include "nat/aarch64-linux.h"
>  #include "nat/aarch64-linux-hw-point.h"

The "arch/arm.h" include is duplicated here.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 1/5] Arm: Add read_description read funcs and use in GDB

Simon Marchi-4
In reply to this post by Alan Hayward
Oh, also please test rebuilding each patch against latest master, you will find the
places that need to be changed from "common" to "gdbsupport", such as here:

> diff --git a/gdb/aarch32-tdep.c b/gdb/aarch32-tdep.c
> new file mode 100644
> index 0000000000..d004e0d7f3
> --- /dev/null
> +++ b/gdb/aarch32-tdep.c
> @@ -0,0 +1,33 @@
> +/* Copyright (C) 2019 Free Software Foundation, Inc.
> +
> +   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/common-defs.h"
> +#include "common/common-regcache.h"
> +#include "arch/aarch32.h"

Simon
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 1/5] Arm: Add read_description read funcs and use in GDB

Simon Marchi-4
In reply to this post by Alan Hayward
On 2019-07-11 9:46 a.m., Alan Hayward wrote:
> Switch the Arm target to get target descriptions via arm_read_description
> and aarch32_read_description, in the same style as other feature targets.
> Add an enum to specify the different types - this will also be of use to
> gdbserver in a later patch.
>
> Under the hood return the same existing pre-feature target descriptions.
>
> Note: This commit will break the AArch64 gdbserver build.

Sorry for spamming you, one last thing :)

I forgot to ask you, what is it in this patch that is breaking the AArch64
gdbserver build in this?  And what would it take for you not to break it?

We generally try to keep things building at each commit, so I'd just like
a bit more justifications about why it's worth breaking it here, rather than
doing the necessary work to keep it building.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 4/5] Arm: Use read_description funcs in gdbserver

Simon Marchi-4
In reply to this post by Alan Hayward
> diff --git a/gdb/gdbserver/linux-aarch32-tdesc.c b/gdb/gdbserver/linux-aarch32-tdesc.c
> new file mode 100644
> index 0000000000..3c26df1f96
> --- /dev/null
> +++ b/gdb/gdbserver/linux-aarch32-tdesc.c
> @@ -0,0 +1,46 @@
> +/* Copyright (C) 2019 Free Software Foundation, Inc.
> +
> +   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 "server.h"
> +#include "tdesc.h"
> +#include "arch/aarch32.h"
> +#include <inttypes.h>
> +
> +static struct target_desc *tdesc_aarch32;
> +
> +/* See linux-aarch32-tdesc.h.  */
> +
> +const target_desc *
> +aarch32_linux_read_description ()
> +{
> +  if (tdesc_aarch32 == nullptr)
> +    {
> +      tdesc_aarch32 = aarch32_create_target_description ();
> +
> +      static const char *expedite_regs[] = { "r11", "sp", "pc", 0 };
> +      init_target_desc (tdesc_aarch32, expedite_regs);
> +    }
> +  return tdesc_aarch32;
> +}
> +
> +/* See linux-aarch32-tdesc.h.  */
> +
> +bool
> +is_aarch32_linux_description (const target_desc *tdesc)
> +{
> +  return tdesc != nullptr && tdesc == tdesc_aarch32;
> +}

If you don't expect tdesc to ever be nullptr, use gdb_assert.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 1/5] Arm: Add read_description read funcs and use in GDB

Alan Hayward
In reply to this post by Simon Marchi-4


> On 11 Jul 2019, at 14:57, Simon Marchi <[hidden email]> wrote:
>
> Oh, also please test rebuilding each patch against latest master, you will find the
> places that need to be changed from "common" to "gdbsupport", such as here:
>
>>

I had rebased, but looks like I had something left over causing the build to work.
Fixed.



> On 11 Jul 2019, at 15:19, Simon Marchi <[hidden email]> wrote:
>
> On 2019-07-11 9:46 a.m., Alan Hayward wrote:
>> Switch the Arm target to get target descriptions via arm_read_description
>> and aarch32_read_description, in the same style as other feature targets.
>> Add an enum to specify the different types - this will also be of use to
>> gdbserver in a later patch.
>>
>> Under the hood return the same existing pre-feature target descriptions.
>>
>> Note: This commit will break the AArch64 gdbserver build.
>
> Sorry for spamming you, one last thing :)
>
> I forgot to ask you, what is it in this patch that is breaking the AArch64
> gdbserver build in this?  And what would it take for you not to break it?
>
> We generally try to keep things building at each commit, so I'd just like
> a bit more justifications about why it's worth breaking it here, rather than
> doing the necessary work to keep it building.
>

Annoyingly (for me) it’s just a single ifdef needed in arch/arm.c. I originally
had patch 4 directly after patch 1, which would have then required adding the
Arm files that get generated at build time into the aarch64 build.
Anyway, fixed.

Updated patch below:


diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index b6680b9afd..62a59c90ea 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -665,7 +665,9 @@ ALL_64_TARGET_OBS = \

 # All other target-dependent objects files (used with --enable-targets=all).
 ALL_TARGET_OBS = \
+       aarch32-tdep.o \
        arc-tdep.o \
+       arch/aarch32.o \
        arch/arm.o \
        arch/arm-get-next-pcs.o \
        arch/arm-linux.o \
@@ -1184,6 +1186,7 @@ SFILES = \
 # right, it is probably easiest just to list .h files here directly.

 HFILES_NO_SRCDIR = \
+       aarch32-tdep.h \
        aarch64-ravenscar-thread.h \
        aarch64-tdep.h \
        ada-lang.h \
@@ -1429,6 +1432,7 @@ HFILES_NO_SRCDIR = \
        xml-syscall.h \
        xml-tdesc.h \
        xtensa-tdep.h \
+       arch/aarch32.h \
        arch/aarch64.h \
        arch/aarch64-insn.h \
        arch/arm.h \
@@ -2133,6 +2137,7 @@ force_update:
 MAKEOVERRIDES =

 ALLDEPFILES = \
+       aarch32-tdep.c \
        aarch64-fbsd-nat.c \
        aarch64-fbsd-tdep.c \
        aarch64-linux-nat.c \
diff --git a/gdb/aarch32-tdep.c b/gdb/aarch32-tdep.c
new file mode 100644
index 0000000000..12d464171c
--- /dev/null
+++ b/gdb/aarch32-tdep.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 "gdbsupport/common-defs.h"
+#include "gdbsupport/common-regcache.h"
+#include "arch/aarch32.h"
+
+static struct target_desc *tdesc_aarch32;
+
+/* See aarch32-tdep.h.  */
+
+const target_desc *
+aarch32_read_description ()
+{
+  if (tdesc_aarch32 == nullptr)
+    tdesc_aarch32 = aarch32_create_target_description ();
+
+  return tdesc_aarch32;
+}
diff --git a/gdb/aarch32-tdep.h b/gdb/aarch32-tdep.h
new file mode 100644
index 0000000000..7fcea0adb9
--- /dev/null
+++ b/gdb/aarch32-tdep.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 AARCH32_TDEP_H
+#define AARCH32_TDEP_H
+
+/* Get the AArch32 target description.  */
+
+const target_desc *aarch32_read_description ();
+
+#endif /* aarch32-tdep.h.  */
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 7b60a9a0c3..2c1f4d9f98 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 "aarch32-tdep.h"
 #include "arch/arm.h"
 #include "nat/aarch64-linux.h"
 #include "nat/aarch64-linux-hw-point.h"
@@ -631,8 +632,6 @@ aarch64_linux_nat_target::post_attach (int pid)
   linux_nat_target::post_attach (pid);
 }

-extern struct target_desc *tdesc_arm_with_neon;
-
 /* Implement the "read_description" target_ops method.  */

 const struct target_desc *
@@ -649,7 +648,7 @@ aarch64_linux_nat_target::read_description ()

   ret = ptrace (PTRACE_GETREGSET, tid, NT_ARM_VFP, &iovec);
   if (ret == 0)
-    return tdesc_arm_with_neon;
+    return aarch32_read_description ();

   CORE_ADDR hwcap = linux_get_hwcap (this);

diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
new file mode 100644
index 0000000000..14d6987d3f
--- /dev/null
+++ b/gdb/arch/aarch32.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 "gdbsupport/common-defs.h"
+#include "aarch32.h"
+
+extern struct target_desc *tdesc_arm_with_neon;
+
+/* See aarch32.h.  */
+
+target_desc *
+aarch32_create_target_description ()
+{
+  return tdesc_arm_with_neon;
+}
diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h
new file mode 100644
index 0000000000..d2c0047216
--- /dev/null
+++ b/gdb/arch/aarch32.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+
+   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 ARCH_AARCH32_H
+#define ARCH_AARCH32_H
+
+#include "gdbsupport/tdesc.h"
+
+/* Create the AArch32 target description.  */
+
+target_desc *aarch32_create_target_description ();
+
+#endif /* aarch32.h.  */
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index 860ce02858..7a0f36e4c4 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -21,6 +21,17 @@
 #include "gdbsupport/common-regcache.h"
 #include "arm.h"

+extern struct target_desc *tdesc_arm_with_vfpv2;
+extern struct target_desc *tdesc_arm_with_vfpv3;
+extern struct target_desc *tdesc_arm_with_iwmmxt;
+
+/* Temporary ifdef.  Will be removed when target descriptions are switched.  */
+#ifndef GDBSERVER
+extern struct target_desc *tdesc_arm_with_m;
+extern struct target_desc *tdesc_arm_with_m_vfp_d16;
+extern struct target_desc *tdesc_arm_with_m_fpa_layout;
+#endif
+
 /* See arm.h.  */

 int
@@ -372,3 +383,52 @@ shifted_reg_val (struct regcache *regcache, unsigned long inst,

   return res & 0xffffffff;
 }
+
+/* See arch/arm.h.  */
+
+target_desc *
+arm_create_target_description (arm_fp_type fp_type)
+{
+  switch (fp_type)
+    {
+    case ARM_FP_TYPE_NONE:
+      return nullptr;
+/* Temporary ifdef.  Will be removed when target descriptions are switched.  */
+#ifndef GDBSERVER
+    case ARM_FP_TYPE_VFPV2:
+      return tdesc_arm_with_vfpv2;
+
+    case ARM_FP_TYPE_VFPV3:
+      return tdesc_arm_with_vfpv3;
+
+    case ARM_FP_TYPE_IWMMXT:
+      return tdesc_arm_with_iwmmxt;
+#endif
+    default:
+      error (_("Invalid Arm FP type: %d"), fp_type);
+    }
+}
+
+/* See arch/arm.h.  */
+
+target_desc *
+arm_create_mprofile_target_description (arm_m_profile_type m_type)
+{
+  switch (m_type)
+    {
+/* Temporary ifdef.  Will be removed when target descriptions are switched.  */
+#ifndef GDBSERVER
+    case ARM_M_TYPE_M_PROFILE:
+      return tdesc_arm_with_m;
+
+    case ARM_M_TYPE_VFP_D16:
+      return tdesc_arm_with_m_fpa_layout;
+
+    case ARM_M_TYPE_WITH_FPA:
+      return tdesc_arm_with_m_vfp_d16;
+#endif
+    default:
+      error (_("Invalid Arm M type: %d"), m_type);
+    }
+}
+
diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h
index dfbbd56d28..58511c7c6b 100644
--- a/gdb/arch/arm.h
+++ b/gdb/arch/arm.h
@@ -19,6 +19,8 @@
 #ifndef ARCH_ARM_H
 #define ARCH_ARM_H

+#include "gdbsupport/tdesc.h"
+
 /* Register numbers of various important registers.  */

 enum gdb_regnum {
@@ -66,6 +68,23 @@ enum arm_breakpoint_kinds
    ARM_BP_KIND_ARM = 4,
 };

+/* Supported Arm FP hardware types.  */
+enum arm_fp_type {
+   ARM_FP_TYPE_NONE = 0,
+   ARM_FP_TYPE_VFPV2,
+   ARM_FP_TYPE_VFPV3,
+   ARM_FP_TYPE_IWMMXT,
+   ARM_FP_TYPE_INVALID
+};
+
+/* Supported M-profile Arm types.  */
+enum arm_m_profile_type {
+   ARM_M_TYPE_M_PROFILE,
+   ARM_M_TYPE_VFP_D16,
+   ARM_M_TYPE_WITH_FPA,
+   ARM_M_TYPE_INVALID
+};
+
 /* Instruction condition field values.  */
 #define INST_EQ                0x0
 #define INST_NE                0x1
@@ -165,4 +184,12 @@ unsigned long shifted_reg_val (struct regcache *regcache,
                               unsigned long pc_val,
                               unsigned long status_reg);

+/* Create an Arm target description with the given FP hardware type.  */
+
+target_desc *arm_create_target_description (arm_fp_type fp_type);
+
+/* Create an Arm M-profile target description with the given hardware type.  */
+
+target_desc *arm_create_mprofile_target_description (arm_m_profile_type m_type);
+
 #endif /* ARCH_ARM_H */
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index dea3abbdd3..6e1af9cda3 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -20,6 +20,8 @@
 #include "defs.h"

 #include "elf/common.h"
+#include "target-descriptions.h"
+#include "aarch32-tdep.h"
 #include "arm-tdep.h"
 #include "arm-fbsd-tdep.h"
 #include "auxv.h"
@@ -178,20 +180,20 @@ arm_fbsd_read_description_auxv (struct target_ops *target)
   CORE_ADDR arm_hwcap = 0;

   if (target_auxv_search (target, AT_FREEBSD_HWCAP, &arm_hwcap) != 1)
-    return NULL;
+    return nullptr;

   if (arm_hwcap & HWCAP_VFP)
     {
       if (arm_hwcap & HWCAP_NEON)
-       return tdesc_arm_with_neon;
+       return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPD32))
          == (HWCAP_VFPv3 | HWCAP_VFPD32))
-       return tdesc_arm_with_vfpv3;
+       return arm_read_description (ARM_FP_TYPE_VFPV3);
       else
-       return tdesc_arm_with_vfpv2;
+      return arm_read_description (ARM_FP_TYPE_VFPV2);
     }

-  return NULL;
+  return nullptr;
 }

 /* Implement the "core_read_description" gdbarch method.  */
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index fe8a113a27..6a374bbc74 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -27,6 +27,7 @@
 #include "observable.h"
 #include "gdbthread.h"

+#include "aarch32-tdep.h"
 #include "arm-tdep.h"
 #include "arm-linux-tdep.h"
 #include "aarch32-linux-nat.h"
@@ -551,7 +552,7 @@ arm_linux_nat_target::read_description ()
     }

   if (arm_hwcap & HWCAP_IWMMXT)
-    return tdesc_arm_with_iwmmxt;
+    return arm_read_description (ARM_FP_TYPE_IWMMXT);

   if (arm_hwcap & HWCAP_VFP)
     {
@@ -566,11 +567,11 @@ arm_linux_nat_target::read_description ()
       /* NEON implies VFPv3-D32 or no-VFP unit.  Say that we only support
         Neon with VFPv3-D32.  */
       if (arm_hwcap & HWCAP_NEON)
-       return tdesc_arm_with_neon;
+       return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
-       return tdesc_arm_with_vfpv3;
-      else
-       return tdesc_arm_with_vfpv2;
+       return arm_read_description (ARM_FP_TYPE_VFPV3);
+
+      return arm_read_description (ARM_FP_TYPE_VFPV2);
     }

   return this->beneath ()->read_description ();
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index d846749e0b..aec20877d9 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -33,6 +33,7 @@
 #include "auxv.h"
 #include "xml-syscall.h"

+#include "aarch32-tdep.h"
 #include "arch/arm.h"
 #include "arch/arm-get-next-pcs.h"
 #include "arch/arm-linux.h"
@@ -738,14 +739,14 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
       /* NEON implies VFPv3-D32 or no-VFP unit.  Say that we only support
          Neon with VFPv3-D32.  */
       if (arm_hwcap & HWCAP_NEON)
-       return tdesc_arm_with_neon;
+       return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
-       return tdesc_arm_with_vfpv3;
-      else
-       return tdesc_arm_with_vfpv2;
+       return arm_read_description (ARM_FP_TYPE_VFPV3);
+
+      return arm_read_description (ARM_FP_TYPE_VFPV2);
     }

-  return NULL;
+  return nullptr;
 }


diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index c1ee39714f..1b19b72ca1 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -240,6 +240,10 @@ static const char **valid_disassembly_styles;
 /* Disassembly style to use. Default to "std" register names.  */
 static const char *disassembly_style;

+/* All possible arm target descriptors.  */
+static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID];
+static struct target_desc *tdesc_arm_mprofile_list[ARM_M_TYPE_INVALID];
+
 /* This is used to keep the bfd arch_info in sync with the disassembly
    style.  */
 static void set_disassembly_style_sfunc (const char *, int,
@@ -8739,7 +8743,6 @@ arm_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
     return default_register_reggroup_p (gdbarch, regnum, group);
 }

-^L
 /* For backward-compatibility we allow two 'g' packet lengths with
    the remote protocol depending on whether FPA registers are
    supplied.  M-profile targets do not have FPA registers, but some
@@ -8753,21 +8756,26 @@ arm_register_g_packet_guesses (struct gdbarch *gdbarch)
 {
   if (gdbarch_tdep (gdbarch)->is_m)
     {
+      const target_desc *tdesc;
+
       /* If we know from the executable this is an M-profile target,
         cater for remote targets whose register set layout is the
         same as the FPA layout.  */
+      tdesc = arm_read_mprofile_description (ARM_M_TYPE_WITH_FPA);
       register_remote_g_packet_guess (gdbarch,
                                      ARM_CORE_REGS_SIZE + ARM_FP_REGS_SIZE,
-                                     tdesc_arm_with_m_fpa_layout);
+                                     tdesc);

       /* The regular M-profile layout.  */
+      tdesc = arm_read_mprofile_description (ARM_M_TYPE_M_PROFILE);
       register_remote_g_packet_guess (gdbarch, ARM_CORE_REGS_SIZE,
-                                     tdesc_arm_with_m);
+                                     tdesc);

       /* M-profile plus M4F VFP.  */
+      tdesc = arm_read_mprofile_description (ARM_M_TYPE_VFP_D16);
       register_remote_g_packet_guess (gdbarch,
                                      ARM_CORE_REGS_SIZE + ARM_VFP2_REGS_SIZE,
-                                     tdesc_arm_with_m_vfp_d16);
+                                     tdesc);
     }

   /* Otherwise we don't have a useful guess.  */
@@ -13310,3 +13318,35 @@ arm_process_record (struct gdbarch *gdbarch, struct regcache *regcache,

   return ret;
 }
+
+/* See arm-tdep.h.  */
+
+const target_desc *
+arm_read_description (arm_fp_type fp_type)
+{
+  struct target_desc *tdesc = tdesc_arm_list[fp_type];
+
+  if (tdesc == nullptr)
+    {
+      tdesc = arm_create_target_description (fp_type);
+      tdesc_arm_list[fp_type] = tdesc;
+    }
+
+  return tdesc;
+}
+
+/* See arm-tdep.h.  */
+
+const target_desc *
+arm_read_mprofile_description (arm_m_profile_type m_type)
+{
+  struct target_desc *tdesc = tdesc_arm_mprofile_list[m_type];
+
+  if (tdesc == nullptr)
+    {
+      tdesc = arm_create_mprofile_target_description (m_type);
+      tdesc_arm_mprofile_list[m_type] = tdesc;
+    }
+
+  return tdesc;
+}
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 36d2d381cf..6d1a91ca35 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -281,11 +281,11 @@ extern void
                                       void *cb_data,
                                       const struct regcache *regcache);

-/* Target descriptions.  */
-extern struct target_desc *tdesc_arm_with_m;
-extern struct target_desc *tdesc_arm_with_iwmmxt;
-extern struct target_desc *tdesc_arm_with_vfpv2;
-extern struct target_desc *tdesc_arm_with_vfpv3;
-extern struct target_desc *tdesc_arm_with_neon;
+/* Get the correct Arm target description with given FP hardware type.  */
+const target_desc *arm_read_description (arm_fp_type fp_type);
+
+/* Get the correct Arm M-Profile target description with given hardware
+   type.  */
+const target_desc *arm_read_mprofile_description (arm_m_profile_type m_type);

 #endif /* arm-tdep.h */
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 27f122ad04..7c0215e89a 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -48,8 +48,9 @@ amd64_tobjs="amd64-tdep.o arch/amd64.o ${x86_tobjs}"

 case "${targ}" in
 aarch64*-*-*)
-       cpu_obs="aarch64-tdep.o arch/aarch64-insn.o arch/aarch64.o \
-                ravenscar-thread.o aarch64-ravenscar-thread.o";;
+       cpu_obs="aarch32-tdep.o aarch64-tdep.o arch/aarch32.o \
+                arch/aarch64-insn.o arch/aarch64.o  ravenscar-thread.o \
+                aarch64-ravenscar-thread.o";;

 alpha*-*-*)
        # Target: Alpha
@@ -62,7 +63,8 @@ arc*-*-*)
        ;;

 arm*-*-*)
-       cpu_obs="arch/arm.o arch/arm-get-next-pcs.o arm-tdep.o";;
+       cpu_obs="aarch32-tdep.o arch/aarch32.o arch/arm.o \
+                arch/arm-get-next-pcs.o arm-tdep.o";;

 hppa*-*-*)
        # Target: HP PA-RISC

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2 0/5] Arm: Use feature target descriptions

Alan Hayward
In reply to this post by Alan Hayward
I pushed this series
(including the updated version of 1/5 and fixed the nit in 4/5).


Alan.

> On 11 Jul 2019, at 14:45, Alan Hayward <[hidden email]> wrote:
>
> Version 2. First two patches from the original set have been pushed.
> 1 and 4 are updated as per review comments.
> Otherwise identical. Will push mid next week if there are no more comments.
>
>
> This set of patches is a result of me trying to figure out exactly what
> is supported for Arm. It moves Arm over to using feature target descriptions,
> simplifying the confusion of xml files in the features/arm/ directory.
> In addition it helps to further separate out AArch32.
>
> There are zero functional changes made by this series. The intention is
> that all Arm target descriptions are identical before and after the series.
> All quirks that might seem odd (for example, the Arm with NEON creates a
> vfp3 feature and then a blank neon feature) have been preserved. One of the
> patches adds tests to prove the new target descriptions are identical. The
> final patch then removes these tests (as they block the removal of the xml
> files).
>
> One of the patches breaks the AArch64 gdbserver build, but it is fixed in
> the following patch.  Preventing this would have meant including additional
> unused functionality, and then removing again.
>
> Code has been tested with AArch32, Armv7, and X86 target-all builds. I don't
> have every Arm target to test this on, but the xml tests should alleviate any
> issue.
>
> Alan Hayward (5):
>  Arm: Add read_description read funcs and use in GDB
>  Arm: Use feature target descriptions
>  Arm: Add xml unit tests
>  Arm: Use read_description funcs in gdbserver
>  Arm: Remove unused feature files and tests
>
> gdb/Makefile.in                            |  5 ++
> gdb/aarch32-tdep.c                         | 33 +++++++++
> gdb/aarch32-tdep.h                         | 25 +++++++
> gdb/aarch64-linux-nat.c                    |  6 +-
> gdb/arch/aarch32.c                         | 43 +++++++++++
> gdb/arch/aarch32.h                         | 27 +++++++
> gdb/arch/arm.c                             | 84 ++++++++++++++++++++++
> gdb/arch/arm.h                             | 27 +++++++
> gdb/arm-fbsd-tdep.c                        | 12 ++--
> gdb/arm-linux-nat.c                        | 11 +--
> gdb/arm-linux-tdep.c                       | 11 +--
> gdb/arm-tdep.c                             | 65 +++++++++++------
> gdb/arm-tdep.h                             | 12 ++--
> gdb/configure.tgt                          |  8 ++-
> gdb/features/arm/arm-with-iwmmxt.c         | 83 ---------------------
> gdb/features/arm/arm-with-iwmmxt.xml       | 13 ----
> gdb/features/arm/arm-with-m-fpa-layout.c   | 46 ------------
> gdb/features/arm/arm-with-m-fpa-layout.xml | 46 ------------
> gdb/features/arm/arm-with-m-vfp-d16.c      | 56 ---------------
> gdb/features/arm/arm-with-m-vfp-d16.xml    | 14 ----
> gdb/features/arm/arm-with-m.c              | 37 ----------
> gdb/features/arm/arm-with-m.xml            | 12 ----
> gdb/features/arm/arm-with-neon.c           | 74 -------------------
> gdb/features/arm/arm-with-neon.xml         | 14 ----
> gdb/features/arm/arm-with-vfpv2.c          | 56 ---------------
> gdb/features/arm/arm-with-vfpv2.xml        | 13 ----
> gdb/features/arm/arm-with-vfpv3.c          | 72 -------------------
> gdb/features/arm/arm-with-vfpv3.xml        | 13 ----
> gdb/gdbserver/configure.srv                | 22 ++----
> gdb/gdbserver/linux-aarch32-low.c          |  2 -
> gdb/gdbserver/linux-aarch32-low.h          |  2 -
> gdb/gdbserver/linux-aarch32-tdesc.c        | 46 ++++++++++++
> gdb/gdbserver/linux-aarch32-tdesc.h        | 29 ++++++++
> gdb/gdbserver/linux-aarch64-low.c          |  3 +-
> gdb/gdbserver/linux-arm-low.c              | 77 ++++++++++----------
> gdb/gdbserver/linux-arm-tdesc.c            | 62 ++++++++++++++++
> gdb/gdbserver/linux-arm-tdesc.h            | 29 ++++++++
> 37 files changed, 532 insertions(+), 658 deletions(-)
> create mode 100644 gdb/aarch32-tdep.c
> create mode 100644 gdb/aarch32-tdep.h
> create mode 100644 gdb/arch/aarch32.c
> create mode 100644 gdb/arch/aarch32.h
> delete mode 100644 gdb/features/arm/arm-with-iwmmxt.c
> delete mode 100644 gdb/features/arm/arm-with-iwmmxt.xml
> delete mode 100644 gdb/features/arm/arm-with-m-fpa-layout.c
> delete mode 100644 gdb/features/arm/arm-with-m-fpa-layout.xml
> delete mode 100644 gdb/features/arm/arm-with-m-vfp-d16.c
> delete mode 100644 gdb/features/arm/arm-with-m-vfp-d16.xml
> delete mode 100644 gdb/features/arm/arm-with-m.c
> delete mode 100644 gdb/features/arm/arm-with-m.xml
> delete mode 100644 gdb/features/arm/arm-with-neon.c
> delete mode 100644 gdb/features/arm/arm-with-neon.xml
> delete mode 100644 gdb/features/arm/arm-with-vfpv2.c
> delete mode 100644 gdb/features/arm/arm-with-vfpv2.xml
> delete mode 100644 gdb/features/arm/arm-with-vfpv3.c
> delete mode 100644 gdb/features/arm/arm-with-vfpv3.xml
> create mode 100644 gdb/gdbserver/linux-aarch32-tdesc.c
> create mode 100644 gdb/gdbserver/linux-aarch32-tdesc.h
> create mode 100644 gdb/gdbserver/linux-arm-tdesc.c
> create mode 100644 gdb/gdbserver/linux-arm-tdesc.h
>
> --
> 2.20.1 (Apple Git-117)
>