diff mbox

[3/4] Use flexible target descriptors for aarch64

Message ID B3614F09-2732-4B13-A45D-5EC111A8DC7E@arm.com
State New
Headers show

Commit Message

Alan Hayward Nov. 20, 2017, 3:37 p.m. UTC
> On 6 Nov 2017, at 12:57, Alan Hayward <Alan.Hayward@arm.com> wrote:

> 

>> 

>> On 6 Nov 2017, at 11:49, Yao Qi <qiyaoltc@gmail.com> wrote:

>> 

>> Alan Hayward <Alan.Hayward@arm.com> writes:

>> 

>>> In the existing code, osabi is never set for aarch64 - the osabi line is missing

>>> from the .xml files. Some other architectures set to “GNU/Linux”. I assumed

>>> there was a reason aarch64 didn’t do this. I didn’t want to change

>>> this behaviour,

>> 

>> Agreed, it should be a separated patch to address this, if needed.  See

>> PR 19895 "gdbserver target description on aarch64/arm doesn't specify osabi"

>> 

>>> so instead in my code osabi is set to “”.

>> 

>> However, setting osabi to "" in GDBserver may slightly change the

>> the XML content GDB received from GDBserver. Without your changes, the

>> XML contents received from GDBserver doesn't have "<osabi>XXX</osabi>",

>> however with your changes, the XML contents have "<osabi></osabi>".  Can

>> you confirm this?  The change like this doesn't affect any GDB's

>> behavior, because osabi in GDB side is still GDB_OSABI_UNKNOWN.

>> 

>> On the other hand, "osabi" is an optional field,

>> https://sourceware.org/gdb/current/onlinedocs/gdb/Target-Description-Format.html

>> so it is optional in "tdesc" too.  IMO, we need to remove

>> "tdesc->osabi != NULL" from the assert, and let GDBserver only generate

>> "<osabi>XXX</osabi>" when tdesc->osabi isn't NULL.  What do you think?

>> 

> 

> Given that osabi is optional, it makes sense to me that it should be removed from

> the assert.

> Setting to “” feels a bit of a hack.

> 

> 

> Alan.


Alan.

Patch committed that allows osabi to be null.
This leaves this patch as below.

{
 Also, ping on  [PATCH 4/4] Add xml selftests
 https://sourceware.org/ml/gdb-patches/2017-10/msg00762.html
 because it hasn't been reviewed yet (due to the previous issues in this patch).
}

All four patches tested together on a --enable-targets=all build and aarch64
build with board files unix, native-gdbserver and unittest.exp.


2017-11-20  Alan Hayward  <alan.hayward@arm.com>

gdb/
	* aarch64-tdep.c (_initialize_aarch64_tdep): Remove init.
	* arch/aarch64.c (aarch64_create_target_description): Create
	new target description.
	* features/Makefile: Add new files.
	* features/aarch64-core.c: New autogenerated file.
	* features/aarch64-fpu.c: New autogenerated file.
	* target-descriptions.c (maint_print_c_tdesc_cmd): Check for aarch64.

gdbserver/
	* linux-aarch64-ipa.c (initialize_low_tracepoint): Remove init.
	* linux-aarch64-low.c (initialize_low_arch): Remove init.
	* linux-aarch64-tdesc.c (aarch64_linux_read_description): Add init.

Comments

Yao Qi Nov. 22, 2017, 3:47 p.m. UTC | #1
Alan Hayward <Alan.Hayward@arm.com> writes:

> +#include <stdlib.h>
> +#include <string.h>
>  #include "aarch64.h"
>
> -extern struct target_desc *tdesc_aarch64;
> +#ifdef GDBSERVER
> +#include "common/common-defs.h"
> +#include "common/gdb_vecs.h"
> +#include "common/vec.h"
> +#include "tdesc.h"
> +#else
> +#include "defs.h"
> +#include "target-descriptions.h"
> +#endif
> +

Do we need to include headers this way?  We don't have that in
arch/i386.c and arch/amd64.c.

> diff --git a/gdb/features/aarch64-core.c b/gdb/features/aarch64-core.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..a735515ae67211d29634e7c39b375a36edef2bb1
> --- /dev/null
> +++ b/gdb/features/aarch64-core.c
> @@ -0,0 +1,72 @@
> +/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
> +  Original: aarch64-core.xml.tmp */
> +

Looks this file is not generated by the recent GDB.  Can you re-generate them?
Yao Qi Nov. 22, 2017, 4 p.m. UTC | #2
Hi Alan,
When you post the new version of patches, could you post the whole
series in the same email thread?  These four patches are not in the same
thread, so I have to go through my inbox to find them one by one.
diff mbox

Patch

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 541a909edaaa1937294b1bb4375ecdd7de3d4c3c..61023dd3bb946c2bfbfbc1b88e986030107acd26 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -54,9 +54,6 @@ 

 #include "record.h"
 #include "record-full.h"
-
-#include "features/aarch64.c"
-
 #include "arch/aarch64-insn.h"

 #include "opcode/aarch64.h"
@@ -3058,8 +3055,6 @@  _initialize_aarch64_tdep (void)
   gdbarch_register (bfd_arch_aarch64, aarch64_gdbarch_init,
 		    aarch64_dump_tdep);

-  initialize_tdesc_aarch64 ();
-
   /* Debug this file's internals.  */
   add_setshow_boolean_cmd ("aarch64", class_maintenance, &aarch64_debug, _("\
 Set AArch64 debugging."), _("\
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index 95d9906f10e660fda99d73a0d2a9d184fd3a7b52..64f522dea9a5b863af8d1359c3a8f781af9526c6 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -15,16 +15,38 @@ 
    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 <stdlib.h>
+#include <string.h>
 #include "aarch64.h"

-extern struct target_desc *tdesc_aarch64;
+#ifdef GDBSERVER
+#include "common/common-defs.h"
+#include "common/gdb_vecs.h"
+#include "common/vec.h"
+#include "tdesc.h"
+#else
+#include "defs.h"
+#include "target-descriptions.h"
+#endif
+
+#include "../features/aarch64-core.c"
+#include "../features/aarch64-fpu.c"

 /* Create the aarch64 target description.  */

 target_desc *
 aarch64_create_target_description ()
 {
-  return tdesc_aarch64;
-}
+  target_desc *tdesc = allocate_target_description ();
+
+#ifndef IN_PROCESS_AGENT
+  set_tdesc_architecture (tdesc, "aarch64");
+#endif

+  long regnum = 0;
+
+  regnum = create_feature_aarch64_core (tdesc, regnum);
+  regnum = create_feature_aarch64_fpu (tdesc, regnum);
+
+  return tdesc;
+}
diff --git a/gdb/features/Makefile b/gdb/features/Makefile
index b41d56106b8adeb07cf6e6e86b02f52bb2c078b3..bb9ac2093448523b212b5c93d271bfb5674f1647 100644
--- a/gdb/features/Makefile
+++ b/gdb/features/Makefile
@@ -119,7 +119,6 @@  OUTPUTS = $(patsubst %,$(outdir)/%.dat,$(WHICH))
 # --enable-targets=all GDB.  You can override this by passing XMLTOC
 # to make on the command line.
 XMLTOC = \
-	aarch64.xml \
 	arc-v2.xml \
 	arc-arcompact.xml \
 	arm/arm-with-iwmmxt.xml \
@@ -206,7 +205,9 @@  $(outdir)/%.dat: %.xml number-regs.xsl sort-regs.xsl gdbserver-regs.xsl
 	  $(XSLTPROC) gdbserver-regs.xsl - >> $(outdir)/$*.tmp
 	sh ../../move-if-change $(outdir)/$*.tmp $(outdir)/$*.dat

-FEATURE_XMLFILES = i386/32bit-core.xml \
+FEATURE_XMLFILES = aarch64-core.xml \
+	aarch64-fpu.xml \
+	i386/32bit-core.xml \
 	i386/32bit-sse.xml \
 	i386/32bit-linux.xml \
 	i386/32bit-avx.xml \
diff --git a/gdb/features/aarch64-core.c b/gdb/features/aarch64-core.c
new file mode 100644
index 0000000000000000000000000000000000000000..a735515ae67211d29634e7c39b375a36edef2bb1
--- /dev/null
+++ b/gdb/features/aarch64-core.c
@@ -0,0 +1,72 @@ 
+/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
+  Original: aarch64-core.xml.tmp */
+
+#ifdef GDBSERVER
+#include "tdesc.h"
+#else
+#include "defs.h"
+#include "osabi.h"
+#include "target-descriptions.h"
+#endif
+
+static int
+create_feature_aarch64_core (struct target_desc *result, long regnum)
+{
+  struct tdesc_feature *feature;
+
+  feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.core", "aarch64-core.xml");
+  struct tdesc_type *field_type;
+  struct tdesc_type *type;
+  type = tdesc_create_flags (feature, "cpsr_flags", 4);
+  tdesc_add_flag (type, 0, "SP");
+  tdesc_add_flag (type, 1, "");
+  tdesc_add_bitfield (type, "EL", 2, 3);
+  tdesc_add_flag (type, 4, "nRW");
+  tdesc_add_flag (type, 5, "");
+  tdesc_add_flag (type, 6, "F");
+  tdesc_add_flag (type, 7, "I");
+  tdesc_add_flag (type, 8, "A");
+  tdesc_add_flag (type, 9, "D");
+  tdesc_add_flag (type, 20, "IL");
+  tdesc_add_flag (type, 21, "SS");
+  tdesc_add_flag (type, 28, "V");
+  tdesc_add_flag (type, 29, "C");
+  tdesc_add_flag (type, 30, "Z");
+  tdesc_add_flag (type, 31, "N");
+
+  tdesc_create_reg (feature, "x0", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x1", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x2", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x3", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x4", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x5", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x6", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x7", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x8", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x9", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x10", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x11", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x12", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x13", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x14", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x15", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x16", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x17", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x18", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x19", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x20", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x21", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x22", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x23", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x24", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x25", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x26", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x27", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x28", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x29", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "x30", regnum++, 1, NULL, 64, "int");
+  tdesc_create_reg (feature, "sp", regnum++, 1, NULL, 64, "data_ptr");
+  tdesc_create_reg (feature, "pc", regnum++, 1, NULL, 64, "code_ptr");
+  tdesc_create_reg (feature, "cpsr", regnum++, 1, NULL, 32, "cpsr_flags");
+  return regnum;
+}
diff --git a/gdb/features/aarch64-fpu.c b/gdb/features/aarch64-fpu.c
new file mode 100644
index 0000000000000000000000000000000000000000..db3dfe771531f7a4c6aa09ee51053fa0266e8c2a
--- /dev/null
+++ b/gdb/features/aarch64-fpu.c
@@ -0,0 +1,138 @@ 
+/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
+  Original: aarch64-fpu.xml.tmp */
+
+#ifdef GDBSERVER
+#include "tdesc.h"
+#else
+#include "defs.h"
+#include "osabi.h"
+#include "target-descriptions.h"
+#endif
+
+static int
+create_feature_aarch64_fpu (struct target_desc *result, long regnum)
+{
+  struct tdesc_feature *feature;
+
+  feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.fpu", "aarch64-fpu.xml");
+  struct tdesc_type *field_type;
+  field_type = tdesc_named_type (feature, "ieee_double");
+  tdesc_create_vector (feature, "v2d", field_type, 2);
+
+  field_type = tdesc_named_type (feature, "uint64");
+  tdesc_create_vector (feature, "v2u", field_type, 2);
+
+  field_type = tdesc_named_type (feature, "int64");
+  tdesc_create_vector (feature, "v2i", field_type, 2);
+
+  field_type = tdesc_named_type (feature, "ieee_single");
+  tdesc_create_vector (feature, "v4f", field_type, 4);
+
+  field_type = tdesc_named_type (feature, "uint32");
+  tdesc_create_vector (feature, "v4u", field_type, 4);
+
+  field_type = tdesc_named_type (feature, "int32");
+  tdesc_create_vector (feature, "v4i", field_type, 4);
+
+  field_type = tdesc_named_type (feature, "uint16");
+  tdesc_create_vector (feature, "v8u", field_type, 8);
+
+  field_type = tdesc_named_type (feature, "int16");
+  tdesc_create_vector (feature, "v8i", field_type, 8);
+
+  field_type = tdesc_named_type (feature, "uint8");
+  tdesc_create_vector (feature, "v16u", field_type, 16);
+
+  field_type = tdesc_named_type (feature, "int8");
+  tdesc_create_vector (feature, "v16i", field_type, 16);
+
+  field_type = tdesc_named_type (feature, "uint128");
+  tdesc_create_vector (feature, "v1u", field_type, 1);
+
+  field_type = tdesc_named_type (feature, "int128");
+  tdesc_create_vector (feature, "v1i", field_type, 1);
+
+  struct tdesc_type *type;
+  type = tdesc_create_union (feature, "vnd");
+  field_type = tdesc_named_type (feature, "v2d");
+  tdesc_add_field (type, "f", field_type);
+  field_type = tdesc_named_type (feature, "v2u");
+  tdesc_add_field (type, "u", field_type);
+  field_type = tdesc_named_type (feature, "v2i");
+  tdesc_add_field (type, "s", field_type);
+
+  type = tdesc_create_union (feature, "vns");
+  field_type = tdesc_named_type (feature, "v4f");
+  tdesc_add_field (type, "f", field_type);
+  field_type = tdesc_named_type (feature, "v4u");
+  tdesc_add_field (type, "u", field_type);
+  field_type = tdesc_named_type (feature, "v4i");
+  tdesc_add_field (type, "s", field_type);
+
+  type = tdesc_create_union (feature, "vnh");
+  field_type = tdesc_named_type (feature, "v8u");
+  tdesc_add_field (type, "u", field_type);
+  field_type = tdesc_named_type (feature, "v8i");
+  tdesc_add_field (type, "s", field_type);
+
+  type = tdesc_create_union (feature, "vnb");
+  field_type = tdesc_named_type (feature, "v16u");
+  tdesc_add_field (type, "u", field_type);
+  field_type = tdesc_named_type (feature, "v16i");
+  tdesc_add_field (type, "s", field_type);
+
+  type = tdesc_create_union (feature, "vnq");
+  field_type = tdesc_named_type (feature, "v1u");
+  tdesc_add_field (type, "u", field_type);
+  field_type = tdesc_named_type (feature, "v1i");
+  tdesc_add_field (type, "s", field_type);
+
+  type = tdesc_create_union (feature, "aarch64v");
+  field_type = tdesc_named_type (feature, "vnd");
+  tdesc_add_field (type, "d", field_type);
+  field_type = tdesc_named_type (feature, "vns");
+  tdesc_add_field (type, "s", field_type);
+  field_type = tdesc_named_type (feature, "vnh");
+  tdesc_add_field (type, "h", field_type);
+  field_type = tdesc_named_type (feature, "vnb");
+  tdesc_add_field (type, "b", field_type);
+  field_type = tdesc_named_type (feature, "vnq");
+  tdesc_add_field (type, "q", field_type);
+
+  regnum = 34;
+  tdesc_create_reg (feature, "v0", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v1", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v2", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v3", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v4", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v5", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v6", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v7", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v8", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v9", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v10", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v11", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v12", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v13", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v14", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v15", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v16", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v17", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v18", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v19", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v20", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v21", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v22", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v23", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v24", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v25", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v26", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v27", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v28", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v29", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v30", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "v31", regnum++, 1, NULL, 128, "aarch64v");
+  tdesc_create_reg (feature, "fpsr", regnum++, 1, NULL, 32, "int");
+  tdesc_create_reg (feature, "fpcr", regnum++, 1, NULL, 32, "int");
+  return regnum;
+}
diff --git a/gdb/features/aarch64.c b/gdb/features/aarch64.c
deleted file mode 100644
index 7411cacd4b80bd51a3301a650de588260b0c30ba..0000000000000000000000000000000000000000
--- a/gdb/features/aarch64.c
+++ /dev/null
@@ -1,191 +0,0 @@ 
-/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
-  Original: aarch64.xml */
-
-#include "defs.h"
-#include "osabi.h"
-#include "target-descriptions.h"
-
-struct target_desc *tdesc_aarch64;
-static void
-initialize_tdesc_aarch64 (void)
-{
-  struct target_desc *result = allocate_target_description ();
-  set_tdesc_architecture (result, bfd_scan_arch ("aarch64"));
-
-  struct tdesc_feature *feature;
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.core");
-  struct tdesc_type *field_type;
-  struct tdesc_type *type;
-  type = tdesc_create_flags (feature, "cpsr_flags", 4);
-  tdesc_add_flag (type, 0, "SP");
-  tdesc_add_flag (type, 1, "");
-  tdesc_add_bitfield (type, "EL", 2, 3);
-  tdesc_add_flag (type, 4, "nRW");
-  tdesc_add_flag (type, 5, "");
-  tdesc_add_flag (type, 6, "F");
-  tdesc_add_flag (type, 7, "I");
-  tdesc_add_flag (type, 8, "A");
-  tdesc_add_flag (type, 9, "D");
-  tdesc_add_flag (type, 20, "IL");
-  tdesc_add_flag (type, 21, "SS");
-  tdesc_add_flag (type, 28, "V");
-  tdesc_add_flag (type, 29, "C");
-  tdesc_add_flag (type, 30, "Z");
-  tdesc_add_flag (type, 31, "N");
-
-  tdesc_create_reg (feature, "x0", 0, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x1", 1, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x2", 2, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x3", 3, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x4", 4, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x5", 5, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x6", 6, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x7", 7, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x8", 8, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x9", 9, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x10", 10, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x11", 11, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x12", 12, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x13", 13, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x14", 14, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x15", 15, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x16", 16, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x17", 17, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x18", 18, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x19", 19, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x20", 20, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x21", 21, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x22", 22, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x23", 23, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x24", 24, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x25", 25, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x26", 26, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x27", 27, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x28", 28, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x29", 29, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "x30", 30, 1, NULL, 64, "int");
-  tdesc_create_reg (feature, "sp", 31, 1, NULL, 64, "data_ptr");
-  tdesc_create_reg (feature, "pc", 32, 1, NULL, 64, "code_ptr");
-  tdesc_create_reg (feature, "cpsr", 33, 1, NULL, 32, "cpsr_flags");
-
-  feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.fpu");
-  field_type = tdesc_named_type (feature, "ieee_double");
-  tdesc_create_vector (feature, "v2d", field_type, 2);
-
-  field_type = tdesc_named_type (feature, "uint64");
-  tdesc_create_vector (feature, "v2u", field_type, 2);
-
-  field_type = tdesc_named_type (feature, "int64");
-  tdesc_create_vector (feature, "v2i", field_type, 2);
-
-  field_type = tdesc_named_type (feature, "ieee_single");
-  tdesc_create_vector (feature, "v4f", field_type, 4);
-
-  field_type = tdesc_named_type (feature, "uint32");
-  tdesc_create_vector (feature, "v4u", field_type, 4);
-
-  field_type = tdesc_named_type (feature, "int32");
-  tdesc_create_vector (feature, "v4i", field_type, 4);
-
-  field_type = tdesc_named_type (feature, "uint16");
-  tdesc_create_vector (feature, "v8u", field_type, 8);
-
-  field_type = tdesc_named_type (feature, "int16");
-  tdesc_create_vector (feature, "v8i", field_type, 8);
-
-  field_type = tdesc_named_type (feature, "uint8");
-  tdesc_create_vector (feature, "v16u", field_type, 16);
-
-  field_type = tdesc_named_type (feature, "int8");
-  tdesc_create_vector (feature, "v16i", field_type, 16);
-
-  field_type = tdesc_named_type (feature, "uint128");
-  tdesc_create_vector (feature, "v1u", field_type, 1);
-
-  field_type = tdesc_named_type (feature, "int128");
-  tdesc_create_vector (feature, "v1i", field_type, 1);
-
-  type = tdesc_create_union (feature, "vnd");
-  field_type = tdesc_named_type (feature, "v2d");
-  tdesc_add_field (type, "f", field_type);
-  field_type = tdesc_named_type (feature, "v2u");
-  tdesc_add_field (type, "u", field_type);
-  field_type = tdesc_named_type (feature, "v2i");
-  tdesc_add_field (type, "s", field_type);
-
-  type = tdesc_create_union (feature, "vns");
-  field_type = tdesc_named_type (feature, "v4f");
-  tdesc_add_field (type, "f", field_type);
-  field_type = tdesc_named_type (feature, "v4u");
-  tdesc_add_field (type, "u", field_type);
-  field_type = tdesc_named_type (feature, "v4i");
-  tdesc_add_field (type, "s", field_type);
-
-  type = tdesc_create_union (feature, "vnh");
-  field_type = tdesc_named_type (feature, "v8u");
-  tdesc_add_field (type, "u", field_type);
-  field_type = tdesc_named_type (feature, "v8i");
-  tdesc_add_field (type, "s", field_type);
-
-  type = tdesc_create_union (feature, "vnb");
-  field_type = tdesc_named_type (feature, "v16u");
-  tdesc_add_field (type, "u", field_type);
-  field_type = tdesc_named_type (feature, "v16i");
-  tdesc_add_field (type, "s", field_type);
-
-  type = tdesc_create_union (feature, "vnq");
-  field_type = tdesc_named_type (feature, "v1u");
-  tdesc_add_field (type, "u", field_type);
-  field_type = tdesc_named_type (feature, "v1i");
-  tdesc_add_field (type, "s", field_type);
-
-  type = tdesc_create_union (feature, "aarch64v");
-  field_type = tdesc_named_type (feature, "vnd");
-  tdesc_add_field (type, "d", field_type);
-  field_type = tdesc_named_type (feature, "vns");
-  tdesc_add_field (type, "s", field_type);
-  field_type = tdesc_named_type (feature, "vnh");
-  tdesc_add_field (type, "h", field_type);
-  field_type = tdesc_named_type (feature, "vnb");
-  tdesc_add_field (type, "b", field_type);
-  field_type = tdesc_named_type (feature, "vnq");
-  tdesc_add_field (type, "q", field_type);
-
-  tdesc_create_reg (feature, "v0", 34, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v1", 35, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v2", 36, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v3", 37, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v4", 38, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v5", 39, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v6", 40, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v7", 41, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v8", 42, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v9", 43, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v10", 44, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v11", 45, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v12", 46, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v13", 47, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v14", 48, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v15", 49, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v16", 50, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v17", 51, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v18", 52, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v19", 53, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v20", 54, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v21", 55, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v22", 56, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v23", 57, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v24", 58, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v25", 59, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v26", 60, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v27", 61, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v28", 62, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v29", 63, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v30", 64, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "v31", 65, 1, NULL, 128, "aarch64v");
-  tdesc_create_reg (feature, "fpsr", 66, 1, NULL, 32, "int");
-  tdesc_create_reg (feature, "fpcr", 67, 1, NULL, 32, "int");
-
-  tdesc_aarch64 = result;
-}
diff --git a/gdb/gdbserver/linux-aarch64-ipa.c b/gdb/gdbserver/linux-aarch64-ipa.c
index 28dc9776a1c8d273e8bc749296a57bc62b8619d5..b240100a13eccdfa696937158dbb365dcff12730 100644
--- a/gdb/gdbserver/linux-aarch64-ipa.c
+++ b/gdb/gdbserver/linux-aarch64-ipa.c
@@ -27,9 +27,6 @@ 
 #endif
 #include "linux-aarch64-tdesc.h"

-/* Defined in auto-generated file aarch64.c.  */
-void init_registers_aarch64 (void);
-
 /* Each register saved by the jump pad is in a 16 byte cell.  */
 #define FT_CR_SIZE 16

@@ -207,5 +204,4 @@  alloc_jump_pad_buffer (size_t size)
 void
 initialize_low_tracepoint (void)
 {
-  init_registers_aarch64 ();
 }
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index dcce287974cb6afd2f530ce1257dbbf25ed25ddc..9682537728847850d824c7eac949c68ab09226ac 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -41,9 +41,6 @@ 
 #include "arch/aarch64.h"
 #include "linux-aarch64-tdesc.h"

-/* Defined in auto-generated files.  */
-void init_registers_aarch64 (void);
-
 #ifdef HAVE_SYS_REG_H
 #include <sys/reg.h>
 #endif
@@ -2998,8 +2995,6 @@  struct linux_target_ops the_low_target =
 void
 initialize_low_arch (void)
 {
-  init_registers_aarch64 ();
-
   initialize_low_arch_aarch32 ();

   initialize_regsets_info (&aarch64_regsets_info);
diff --git a/gdb/gdbserver/linux-aarch64-tdesc.c b/gdb/gdbserver/linux-aarch64-tdesc.c
index 8518ef73389ce9d7bd526de75716bd21dbef7959..b1c3dd4441dbc784747cf245f359a034af88eb8c 100644
--- a/gdb/gdbserver/linux-aarch64-tdesc.c
+++ b/gdb/gdbserver/linux-aarch64-tdesc.c
@@ -31,7 +31,16 @@  aarch64_linux_read_description ()
   target_desc **tdesc = &aarch64_tdesc;

   if (*tdesc == NULL)
-    *tdesc = aarch64_create_target_description ();
+    {
+      *tdesc = aarch64_create_target_description ();
+
+      init_target_desc (*tdesc);
+
+#ifndef IN_PROCESS_AGENT
+      static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL };
+      (*tdesc)->expedite_regs = expedite_regs_aarch64;
+#endif
+    }

   return *tdesc;
 }
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 3a5999c50de3ae97f84f648bb3ea08c845c7e88d..2a0940f211942d56072762f520f39dc5d2911c0d 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -2327,7 +2327,8 @@  maint_print_c_tdesc_cmd (const char *args, int from_tty)
      counterparts.  */
   if (startswith (filename_after_features.c_str (), "i386/32bit-")
       || startswith (filename_after_features.c_str (), "i386/64bit-")
-      || startswith (filename_after_features.c_str (), "i386/x32-core.xml"))
+      || startswith (filename_after_features.c_str (), "i386/x32-core.xml")
+      || startswith (filename_after_features.c_str (), "aarch64"))
     {
       print_c_feature v (filename_after_features);