public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/6] : Commonise various target-descriptions.c functions
  2018-01-16  9:52 [PATCH 0/6] : Remove XML files from gdbserver Alan Hayward
@ 2018-01-16  9:51 ` Alan Hayward
  2018-01-16 14:18   ` Alan Hayward
  2018-01-19 23:05   ` Yao Qi
  2018-01-16  9:52 ` [PATCH 2/6]: gdbserver use common tdesc functions Alan Hayward
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 17+ messages in thread
From: Alan Hayward @ 2018-01-16  9:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd

This patch simply moves functionality from target-descriptions.c
to the common files arch/tdesc.c and arch/tdesc.h.
No functionality is changed.
This will allow usage by gdbserver.
The "#ifndef GDBSERVER" around the functions in arch/tdesc.h will be removed
in the next patch.

Alan.


2018-01-16  Alan Hayward  <alan.hayward@arm.com>

	* Makefile.in: Add new common tdesc file.
	* arch/tdesc.c: New file.
	* arch/tdesc.h (struct tdesc_reg): Moved from target-descriptions.c
	(enum tdesc_type_kind): Likewise.
	(struct tdesc_type): Likewise.
	(struct tdesc_type_builtin): Likewise.
	(struct tdesc_type_vector): Likewise.
	(struct tdesc_type_field): Likewise.
	(struct tdesc_type_with_fields): Likewise.
	(struct tdesc_feature): Likewise.
	(struct tdesc_arch_reg): Likewise.
	* target-descriptions.c (struct target_desc): Move to arch/tdesc.c/h
	(type *tdesc_type_builtin::make_gdb_type): Likewise.
	(type *tdesc_type_vector::make_gdb_type): Likewise.
	(type *tdesc_type_with_fields::make_gdb_type_struct): Likewise.
	(type *tdesc_type_with_fields::make_gdb_type_union): Likewise.
	(type *tdesc_type_with_fields::make_gdb_type_flags): Likewise.
	(type *tdesc_type_with_fields::make_gdb_type_enum): Likewise.
	(type *tdesc_type_with_fields::make_gdb_type): Likewise.
	(tdesc_predefined_type): Likewise.
	(tdesc_named_type): Likewise.
	(tdesc_create_reg): Likewise.
	(tdesc_create_vector): Likewise.
	(tdesc_create_struct): Likewise.
	(tdesc_set_struct_size): Likewise.
	(tdesc_create_union): Likewise.
	(tdesc_create_flags): Likewise.
	(tdesc_create_enum): Likewise.
	(tdesc_add_field): Likewise.
	(tdesc_add_typed_bitfield): Likewise.
	(tdesc_add_bitfield): Likewise.
	(tdesc_add_flag): Likewise.
	(tdesc_add_enum_value): Likewise.


diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 0a4a06b242e0423218648fe77d53fc192456cd2f..386ab5c117ebf34e1ae927b5fe78fd4618012945 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -669,6 +669,7 @@ ALL_TARGET_OBS = \
 	arch/arm-get-next-pcs.o \
 	arch/arm-linux.o \
 	arch/i386.o \
+	arch/tdesc.o \
 	arm-bsd-tdep.o \
 	arm-fbsd-tdep.o \
 	arm-linux-tdep.o \
diff --git a/gdb/arch/tdesc.h b/gdb/arch/tdesc.h
index cc11651dcaa7abe81598b69f509ef34ff0d94dbf..22da5efa48f8cf5e94c33c9eed4739127467c356 100644
--- a/gdb/arch/tdesc.h
+++ b/gdb/arch/tdesc.h
@@ -18,6 +18,12 @@
 #ifndef ARCH_TDESC_H
 #define ARCH_TDESC_H 1

+#ifdef GDBSERVER
+#include "server.h"
+#else
+#include "defs.h"
+#endif
+
 struct tdesc_feature;
 struct tdesc_type;
 struct tdesc_type_builtin;
@@ -25,6 +31,271 @@ struct tdesc_type_vector;
 struct tdesc_type_with_fields;
 struct tdesc_reg;
 struct target_desc;
+struct type;
+
+#ifndef GDBSERVER
+
+/* The interface to visit different elements of target description.  */
+
+class tdesc_element_visitor
+{
+public:
+  virtual void visit_pre (const target_desc *e) = 0;
+  virtual void visit_post (const target_desc *e) = 0;
+
+  virtual void visit_pre (const tdesc_feature *e) = 0;
+  virtual void visit_post (const tdesc_feature *e) = 0;
+
+  virtual void visit (const tdesc_type_builtin *e) = 0;
+  virtual void visit (const tdesc_type_vector *e) = 0;
+  virtual void visit (const tdesc_type_with_fields *e) = 0;
+
+  virtual void visit (const tdesc_reg *e) = 0;
+};
+
+class tdesc_element
+{
+public:
+  virtual void accept (tdesc_element_visitor &v) const = 0;
+};
+
+/* An individual register from a target description.  */
+
+struct tdesc_reg : tdesc_element
+{
+  tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
+	     int regnum, int save_restore_, const char *group_,
+	     int bitsize_, const char *type_);
+
+  virtual ~tdesc_reg () = default;
+
+  DISABLE_COPY_AND_ASSIGN (tdesc_reg);
+
+  /* The name of this register.  In standard features, it may be
+     recognized by the architecture support code, or it may be purely
+     for the user.  */
+  std::string name;
+
+  /* The register number used by this target to refer to this
+     register.  This is used for remote p/P packets and to determine
+     the ordering of registers in the remote g/G packets.  */
+  long target_regnum;
+
+  /* If this flag is set, GDB should save and restore this register
+     around calls to an inferior function.  */
+  int save_restore;
+
+  /* The name of the register group containing this register, or empty
+     if the group should be automatically determined from the
+     register's type.  If this is "general", "float", or "vector", the
+     corresponding "info" command should display this register's
+     value.  It can be an arbitrary string, but should be limited to
+     alphanumeric characters and internal hyphens.  Currently other
+     strings are ignored (treated as empty).  */
+  std::string group;
+
+  /* The size of the register, in bits.  */
+  int bitsize;
+
+  /* The type of the register.  This string corresponds to either
+     a named type from the target description or a predefined
+     type from GDB.  */
+  std::string type;
+
+  /* The target-described type corresponding to TYPE, if found.  */
+  struct tdesc_type *tdesc_type;
+
+  void accept (tdesc_element_visitor &v) const override;
+
+  bool operator== (const tdesc_reg &other) const;
+
+  bool operator!= (const tdesc_reg &other) const
+  {
+    return !(*this == other);
+  }
+};
+
+typedef std::unique_ptr<tdesc_reg> tdesc_reg_up;
+
+enum tdesc_type_kind
+{
+  /* Predefined types.  */
+  TDESC_TYPE_BOOL,
+  TDESC_TYPE_INT8,
+  TDESC_TYPE_INT16,
+  TDESC_TYPE_INT32,
+  TDESC_TYPE_INT64,
+  TDESC_TYPE_INT128,
+  TDESC_TYPE_UINT8,
+  TDESC_TYPE_UINT16,
+  TDESC_TYPE_UINT32,
+  TDESC_TYPE_UINT64,
+  TDESC_TYPE_UINT128,
+  TDESC_TYPE_CODE_PTR,
+  TDESC_TYPE_DATA_PTR,
+  TDESC_TYPE_IEEE_SINGLE,
+  TDESC_TYPE_IEEE_DOUBLE,
+  TDESC_TYPE_ARM_FPA_EXT,
+  TDESC_TYPE_I387_EXT,
+
+  /* Types defined by a target feature.  */
+  TDESC_TYPE_VECTOR,
+  TDESC_TYPE_STRUCT,
+  TDESC_TYPE_UNION,
+  TDESC_TYPE_FLAGS,
+  TDESC_TYPE_ENUM
+};
+
+struct tdesc_type : tdesc_element
+{
+  tdesc_type (const std::string &name_, enum tdesc_type_kind kind_)
+    : name (name_), kind (kind_)
+  {}
+
+  virtual ~tdesc_type () = default;
+
+  DISABLE_COPY_AND_ASSIGN (tdesc_type);
+
+  /* The name of this type.   */
+  std::string name;
+
+  /* Identify the kind of this type.  */
+  enum tdesc_type_kind kind;
+
+  bool operator== (const tdesc_type &other) const
+  {
+    return name == other.name && kind == other.kind;
+  }
+
+  bool operator!= (const tdesc_type &other) const
+  {
+    return !(*this == other);
+  }
+
+  /* Construct, if necessary, and return the GDB type implementing this
+     target type for architecture GDBARCH.  */
+
+  virtual type *make_gdb_type (struct gdbarch *gdbarch) const = 0;
+};
+
+struct tdesc_type_builtin : tdesc_type
+{
+  tdesc_type_builtin (const std::string &name, enum tdesc_type_kind kind)
+  : tdesc_type (name, kind)
+  {}
+
+  void accept (tdesc_element_visitor &v) const override;
+
+  type *make_gdb_type (struct gdbarch *gdbarch) const override;
+};
+
+/* tdesc_type for vector types.  */
+
+struct tdesc_type_vector : tdesc_type
+{
+  tdesc_type_vector (const std::string &name, tdesc_type *element_type_, int count_)
+  : tdesc_type (name, TDESC_TYPE_VECTOR),
+    element_type (element_type_), count (count_)
+  {}
+
+  void accept (tdesc_element_visitor &v) const override;
+
+  type *make_gdb_type (struct gdbarch *gdbarch) const override;
+
+  struct tdesc_type *element_type;
+  int count;
+};
+
+/* A named type from a target description.  */
+
+struct tdesc_type_field
+{
+  tdesc_type_field (const std::string &name_, tdesc_type *type_,
+		    int start_, int end_)
+  : name (name_), type (type_), start (start_), end (end_)
+  {}
+
+  std::string name;
+  struct tdesc_type *type;
+  /* For non-enum-values, either both are -1 (non-bitfield), or both are
+     not -1 (bitfield).  For enum values, start is the value (which could be
+     -1), end is -1.  */
+  int start, end;
+};
+
+/* tdesc_type for struct, union, flags, and enum types.  */
+
+struct tdesc_type_with_fields : tdesc_type
+{
+  tdesc_type_with_fields (const std::string &name, tdesc_type_kind kind,
+			  int size_ = 0)
+  : tdesc_type (name, kind), size (size_)
+  {}
+
+  void accept (tdesc_element_visitor &v) const override;
+
+  type *make_gdb_type_struct (struct gdbarch *gdbarch) const;
+  type *make_gdb_type_union (struct gdbarch *gdbarch) const;
+  type *make_gdb_type_flags (struct gdbarch *gdbarch) const;
+  type *make_gdb_type_enum (struct gdbarch *gdbarch) const;
+  type *make_gdb_type (struct gdbarch *gdbarch) const override;
+
+  std::vector<tdesc_type_field> fields;
+  int size;
+};
+
+typedef std::unique_ptr<tdesc_type> tdesc_type_up;
+
+/* A feature from a target description.  Each feature is a collection
+   of other elements, e.g. registers and types.  */
+
+struct tdesc_feature : tdesc_element
+{
+  tdesc_feature (const std::string &name_)
+    : name (name_)
+  {}
+
+  virtual ~tdesc_feature () = default;
+
+  DISABLE_COPY_AND_ASSIGN (tdesc_feature);
+
+  /* The name of this feature.  It may be recognized by the architecture
+     support code.  */
+  std::string name;
+
+  /* The registers associated with this feature.  */
+  std::vector<tdesc_reg_up> registers;
+
+  /* The types associated with this feature.  */
+  std::vector<tdesc_type_up> types;
+
+  void accept (tdesc_element_visitor &v) const override;
+
+  bool operator== (const tdesc_feature &other) const;
+
+  bool operator!= (const tdesc_feature &other) const
+  {
+    return !(*this == other);
+  }
+};
+
+typedef std::unique_ptr<tdesc_feature> tdesc_feature_up;
+
+/* Per-architecture data associated with a target description.  The
+   target description may be shared by multiple architectures, but
+   this data is private to one gdbarch.  */
+
+struct tdesc_arch_reg
+{
+  tdesc_arch_reg (tdesc_reg *reg_, struct type *type_)
+  : reg (reg_), type (type_)
+  {}
+
+  struct tdesc_reg *reg;
+  struct type *type;
+};
+
+#endif

 /* Allocate a new target_desc.  */
 target_desc *allocate_target_description (void);
diff --git a/gdb/arch/tdesc.c b/gdb/arch/tdesc.c
new file mode 100644
index 0000000000000000000000000000000000000000..e6005a75a7264bba4cd177e4ec1efd90809e25c8
--- /dev/null
+++ b/gdb/arch/tdesc.c
@@ -0,0 +1,325 @@
+/* Target description support for GDB.
+
+   Copyright (C) 2017 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/>.  */
+
+#ifdef GDBSERVER
+#include "server.h"
+
+typedef const char * (gdbarch_register_name_ftype) (struct gdbarch *gdbarch, int regnr);
+typedef struct type * (gdbarch_register_type_ftype) (struct gdbarch *gdbarch, int reg_nr);
+
+#else
+#include "defs.h"
+#endif
+
+#include "tdesc.h"
+
+tdesc_reg::tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
+		      int regnum, int save_restore_, const char *group_,
+		      int bitsize_, const char *type_)
+  : name (name_), target_regnum (regnum),
+    save_restore (save_restore_),
+    group (group_ != NULL ? group_ : ""),
+    bitsize (bitsize_),
+    type (type_ != NULL ? type_ : "<unknown>")
+{
+  /* If the register's type is target-defined, look it up now.  We may not
+     have easy access to the containing feature when we want it later.  */
+  tdesc_type = tdesc_named_type (feature, type.c_str ());
+}
+
+void tdesc_reg::accept (tdesc_element_visitor &v) const
+{
+  v.visit (this);
+}
+
+bool tdesc_reg::operator== (const tdesc_reg &other) const
+{
+  return (name == other.name
+	  && target_regnum == other.target_regnum
+	  && save_restore == other.save_restore
+	  && bitsize == other.bitsize
+	  && group == other.group
+	  && type == other.type);
+}
+
+/* Predefined types.  */
+static tdesc_type_builtin tdesc_predefined_types[] =
+{
+  { "bool", TDESC_TYPE_BOOL },
+  { "int8", TDESC_TYPE_INT8 },
+  { "int16", TDESC_TYPE_INT16 },
+  { "int32", TDESC_TYPE_INT32 },
+  { "int64", TDESC_TYPE_INT64 },
+  { "int128", TDESC_TYPE_INT128 },
+  { "uint8", TDESC_TYPE_UINT8 },
+  { "uint16", TDESC_TYPE_UINT16 },
+  { "uint32", TDESC_TYPE_UINT32 },
+  { "uint64", TDESC_TYPE_UINT64 },
+  { "uint128", TDESC_TYPE_UINT128 },
+  { "code_ptr", TDESC_TYPE_CODE_PTR },
+  { "data_ptr", TDESC_TYPE_DATA_PTR },
+  { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
+  { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
+  { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
+  { "i387_ext", TDESC_TYPE_I387_EXT }
+};
+
+void tdesc_type_builtin::accept (tdesc_element_visitor &v) const
+{
+  v.visit (this);
+}
+
+void tdesc_type_vector::accept (tdesc_element_visitor &v) const
+{
+  v.visit (this);
+}
+
+void tdesc_type_with_fields::accept (tdesc_element_visitor &v) const
+{
+  v.visit (this);
+}
+
+void tdesc_feature::accept (tdesc_element_visitor &v) const
+{
+  v.visit_pre (this);
+
+  for (const tdesc_type_up &type : types)
+    type->accept (v);
+
+  for (const tdesc_reg_up &reg : registers)
+    reg->accept (v);
+
+  v.visit_post (this);
+}
+
+bool tdesc_feature::operator== (const tdesc_feature &other) const
+{
+  if (name != other.name)
+    return false;
+
+  if (registers.size () != other.registers.size ())
+    return false;
+
+  for (int ix = 0; ix < registers.size (); ix++)
+    {
+      const tdesc_reg_up &reg1 = registers[ix];
+      const tdesc_reg_up &reg2 = other.registers[ix];
+
+      if (reg1 != reg2 && *reg1 != *reg2)
+	return false;
+      }
+
+  if (types.size () != other.types.size ())
+    return false;
+
+  for (int ix = 0; ix < types.size (); ix++)
+    {
+      const tdesc_type_up &type1 = types[ix];
+      const tdesc_type_up &type2 = other.types[ix];
+
+      if (type1 != type2 && *type1 != *type2)
+	return false;
+    }
+
+  return true;
+}
+
+/* Lookup a predefined type.  */
+
+static struct tdesc_type *
+tdesc_predefined_type (enum tdesc_type_kind kind)
+{
+  for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
+    if (tdesc_predefined_types[ix].kind == kind)
+      return &tdesc_predefined_types[ix];
+
+  gdb_assert_not_reached ("bad predefined tdesc type");
+}
+
+/* See arch/tdesc.h.  */
+
+struct tdesc_type *
+tdesc_named_type (const struct tdesc_feature *feature, const char *id)
+{
+  /* First try target-defined types.  */
+  for (const tdesc_type_up &type : feature->types)
+    if (type->name == id)
+      return type.get ();
+
+  /* Next try the predefined types.  */
+  for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
+    if (tdesc_predefined_types[ix].name == id)
+      return &tdesc_predefined_types[ix];
+
+  return NULL;
+}
+
+/* See arch/tdesc.h.  */
+
+void
+tdesc_create_reg (struct tdesc_feature *feature, const char *name,
+		  int regnum, int save_restore, const char *group,
+		  int bitsize, const char *type)
+{
+  tdesc_reg *reg = new tdesc_reg (feature, name, regnum, save_restore,
+				  group, bitsize, type);
+
+  feature->registers.emplace_back (reg);
+}
+
+/* See arch/tdesc.h.  */
+
+struct tdesc_type *
+tdesc_create_vector (struct tdesc_feature *feature, const char *name,
+		     struct tdesc_type *field_type, int count)
+{
+  tdesc_type_vector *type = new tdesc_type_vector (name, field_type, count);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See arch/tdesc.h.  */
+
+tdesc_type_with_fields *
+tdesc_create_struct (struct tdesc_feature *feature, const char *name)
+{
+  tdesc_type_with_fields *type
+    = new tdesc_type_with_fields (name, TDESC_TYPE_STRUCT);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See arch/tdesc.h.  */
+
+void
+tdesc_set_struct_size (tdesc_type_with_fields *type, int size)
+{
+  gdb_assert (type->kind == TDESC_TYPE_STRUCT);
+  gdb_assert (size > 0);
+  type->size = size;
+}
+
+/* See arch/tdesc.h.  */
+
+tdesc_type_with_fields *
+tdesc_create_union (struct tdesc_feature *feature, const char *name)
+{
+  tdesc_type_with_fields *type
+    = new tdesc_type_with_fields (name, TDESC_TYPE_UNION);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See arch/tdesc.h.  */
+
+tdesc_type_with_fields *
+tdesc_create_flags (struct tdesc_feature *feature, const char *name,
+		    int size)
+{
+  gdb_assert (size > 0);
+
+  tdesc_type_with_fields *type
+    = new tdesc_type_with_fields (name, TDESC_TYPE_FLAGS, size);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+tdesc_type_with_fields *
+tdesc_create_enum (struct tdesc_feature *feature, const char *name,
+		   int size)
+{
+  gdb_assert (size > 0);
+
+  tdesc_type_with_fields *type
+    = new tdesc_type_with_fields (name, TDESC_TYPE_ENUM, size);
+  feature->types.emplace_back (type);
+
+  return type;
+}
+
+/* See arch/tdesc.h.  */
+
+void
+tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
+		 struct tdesc_type *field_type)
+{
+  gdb_assert (type->kind == TDESC_TYPE_UNION
+	      || type->kind == TDESC_TYPE_STRUCT);
+
+  /* Initialize start and end so we know this is not a bit-field
+     when we print-c-tdesc.  */
+  type->fields.emplace_back (field_name, field_type, -1, -1);
+}
+
+void
+tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_name,
+			  int start, int end, struct tdesc_type *field_type)
+{
+  gdb_assert (type->kind == TDESC_TYPE_STRUCT
+	      || type->kind == TDESC_TYPE_FLAGS);
+  gdb_assert (start >= 0 && end >= start);
+
+  type->fields.emplace_back (field_name, field_type, start, end);
+}
+
+/* See arch/tdesc.h.  */
+
+void
+tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
+		    int start, int end)
+{
+  struct tdesc_type *field_type;
+
+  gdb_assert (start >= 0 && end >= start);
+
+  if (type->size > 4)
+    field_type = tdesc_predefined_type (TDESC_TYPE_UINT64);
+  else
+    field_type = tdesc_predefined_type (TDESC_TYPE_UINT32);
+
+  tdesc_add_typed_bitfield (type, field_name, start, end, field_type);
+}
+
+/* See arch/tdesc.h.  */
+
+void
+tdesc_add_flag (tdesc_type_with_fields *type, int start,
+		const char *flag_name)
+{
+  gdb_assert (type->kind == TDESC_TYPE_FLAGS
+	      || type->kind == TDESC_TYPE_STRUCT);
+
+  type->fields.emplace_back (flag_name,
+			     tdesc_predefined_type (TDESC_TYPE_BOOL),
+			     start, start);
+}
+
+void
+tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
+		      const char *name)
+{
+  gdb_assert (type->kind == TDESC_TYPE_ENUM);
+  type->fields.emplace_back (name,
+			     tdesc_predefined_type (TDESC_TYPE_INT32),
+			     value, -1);
+}
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 1b20a12d769718e591dea6df8183c2e9ecfac990..cef65a8fe61e22362e0bc4e6dbd7e3c0a0f4d1b4 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -38,30 +38,6 @@
 #include "completer.h"
 #include "readline/tilde.h" /* tilde_expand */

-/* The interface to visit different elements of target description.  */
-
-class tdesc_element_visitor
-{
-public:
-  virtual void visit_pre (const target_desc *e) = 0;
-  virtual void visit_post (const target_desc *e) = 0;
-
-  virtual void visit_pre (const tdesc_feature *e) = 0;
-  virtual void visit_post (const tdesc_feature *e) = 0;
-
-  virtual void visit (const tdesc_type_builtin *e) = 0;
-  virtual void visit (const tdesc_type_vector *e) = 0;
-  virtual void visit (const tdesc_type_with_fields *e) = 0;
-
-  virtual void visit (const tdesc_reg *e) = 0;
-};
-
-class tdesc_element
-{
-public:
-  virtual void accept (tdesc_element_visitor &v) const = 0;
-};
-
 /* Types.  */

 struct property
@@ -74,41 +50,20 @@ struct property
   std::string value;
 };

-/* An individual register from a target description.  */
+/* A target description.  */

-struct tdesc_reg : tdesc_element
+struct target_desc : tdesc_element
 {
-  tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
-	     int regnum, int save_restore_, const char *group_,
-	     int bitsize_, const char *type_)
-    : name (name_), target_regnum (regnum),
-      save_restore (save_restore_),
-      group (group_ != NULL ? group_ : ""),
-      bitsize (bitsize_),
-      type (type_ != NULL ? type_ : "<unknown>")
-  {
-    /* If the register's type is target-defined, look it up now.  We may not
-       have easy access to the containing feature when we want it later.  */
-    tdesc_type = tdesc_named_type (feature, type.c_str ());
-  }
-
-  virtual ~tdesc_reg () = default;
-
-  DISABLE_COPY_AND_ASSIGN (tdesc_reg);
+  target_desc ()
+  {}

-  /* The name of this register.  In standard features, it may be
-     recognized by the architecture support code, or it may be purely
-     for the user.  */
-  std::string name;
+  virtual ~target_desc () = default;

-  /* The register number used by this target to refer to this
-     register.  This is used for remote p/P packets and to determine
-     the ordering of registers in the remote g/G packets.  */
-  long target_regnum;
+  target_desc (const target_desc &) = delete;
+  void operator= (const target_desc &) = delete;

-  /* If this flag is set, GDB should save and restore this register
-     around calls to an inferior function.  */
-  int save_restore;
+  /* The architecture reported by the target, if any.  */
+  const struct bfd_arch_info *arch = NULL;

   /* The name of the register group containing this register, or empty
      if the group should be automatically determined from the register's
@@ -118,554 +73,290 @@ struct tdesc_reg : tdesc_element
      limited to alphanumeric characters and internal hyphens.  */
   std::string group;

-  /* The size of the register, in bits.  */
-  int bitsize;
+  /* The osabi reported by the target, if any; GDB_OSABI_UNKNOWN
+     otherwise.  */
+  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
+
+  /* The list of compatible architectures reported by the target.  */
+  std::vector<const bfd_arch_info *> compatible;

-  /* The type of the register.  This string corresponds to either
-     a named type from the target description or a predefined
-     type from GDB.  */
-  std::string type;
+  /* Any architecture-specific properties specified by the target.  */
+  std::vector<property> properties;

-  /* The target-described type corresponding to TYPE, if found.  */
-  struct tdesc_type *tdesc_type;
+  /* The features associated with this target.  */
+  std::vector<tdesc_feature_up> features;

   void accept (tdesc_element_visitor &v) const override
   {
-    v.visit (this);
-  }
+    v.visit_pre (this);

-  bool operator== (const tdesc_reg &other) const
-  {
-    return (name == other.name
-	    && target_regnum == other.target_regnum
-	    && save_restore == other.save_restore
-	    && bitsize == other.bitsize
-	    && group == other.group
-	    && type == other.type);
-  }
+    for (const tdesc_feature_up &feature : features)
+      feature->accept (v);

-  bool operator!= (const tdesc_reg &other) const
-  {
-    return !(*this == other);
+    v.visit_post (this);
   }
-};
-
-typedef std::unique_ptr<tdesc_reg> tdesc_reg_up;
-
-/* A named type from a target description.  */
-
-struct tdesc_type_field
-{
-  tdesc_type_field (const std::string &name_, tdesc_type *type_,
-		    int start_, int end_)
-  : name (name_), type (type_), start (start_), end (end_)
-  {}
-
-  std::string name;
-  struct tdesc_type *type;
-  /* For non-enum-values, either both are -1 (non-bitfield), or both are
-     not -1 (bitfield).  For enum values, start is the value (which could be
-     -1), end is -1.  */
-  int start, end;
-};
-
-enum tdesc_type_kind
-{
-  /* Predefined types.  */
-  TDESC_TYPE_BOOL,
-  TDESC_TYPE_INT8,
-  TDESC_TYPE_INT16,
-  TDESC_TYPE_INT32,
-  TDESC_TYPE_INT64,
-  TDESC_TYPE_INT128,
-  TDESC_TYPE_UINT8,
-  TDESC_TYPE_UINT16,
-  TDESC_TYPE_UINT32,
-  TDESC_TYPE_UINT64,
-  TDESC_TYPE_UINT128,
-  TDESC_TYPE_CODE_PTR,
-  TDESC_TYPE_DATA_PTR,
-  TDESC_TYPE_IEEE_SINGLE,
-  TDESC_TYPE_IEEE_DOUBLE,
-  TDESC_TYPE_ARM_FPA_EXT,
-  TDESC_TYPE_I387_EXT,
-
-  /* Types defined by a target feature.  */
-  TDESC_TYPE_VECTOR,
-  TDESC_TYPE_STRUCT,
-  TDESC_TYPE_UNION,
-  TDESC_TYPE_FLAGS,
-  TDESC_TYPE_ENUM
-};

-struct tdesc_type : tdesc_element
-{
-  tdesc_type (const std::string &name_, enum tdesc_type_kind kind_)
-    : name (name_), kind (kind_)
-  {}
+  bool operator== (const target_desc &other) const
+  {
+    if (arch != other.arch)
+      return false;

-  virtual ~tdesc_type () = default;
+    if (osabi != other.osabi)
+      return false;

-  DISABLE_COPY_AND_ASSIGN (tdesc_type);
+    if (features.size () != other.features.size ())
+      return false;

-  /* The name of this type.   */
-  std::string name;
+    for (int ix = 0; ix < features.size (); ix++)
+      {
+	const tdesc_feature_up &feature1 = features[ix];
+	const tdesc_feature_up &feature2 = other.features[ix];

-  /* Identify the kind of this type.  */
-  enum tdesc_type_kind kind;
+	if (feature1 != feature2 && *feature1 != *feature2)
+	  return false;
+      }

-  bool operator== (const tdesc_type &other) const
-  {
-    return name == other.name && kind == other.kind;
+    return true;
   }

-  bool operator!= (const tdesc_type &other) const
+  bool operator!= (const target_desc &other) const
   {
     return !(*this == other);
   }
-
-  /* Construct, if necessary, and return the GDB type implementing this
-     target type for architecture GDBARCH.  */
-
-  virtual type *make_gdb_type (struct gdbarch *gdbarch) const = 0;
 };

-typedef std::unique_ptr<tdesc_type> tdesc_type_up;
-
-struct tdesc_type_builtin : tdesc_type
-{
-  tdesc_type_builtin (const std::string &name, enum tdesc_type_kind kind)
-  : tdesc_type (name, kind)
-  {}

-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit (this);
-  }

-  type *make_gdb_type (struct gdbarch *gdbarch) const override
-  {
-    switch (this->kind)
-      {
-      /* Predefined types.  */
-      case TDESC_TYPE_BOOL:
-        return builtin_type (gdbarch)->builtin_bool;
+type *tdesc_type_builtin::make_gdb_type (struct gdbarch *gdbarch) const
+{
+  switch (this->kind)
+    {
+    /* Predefined types.  */
+    case TDESC_TYPE_BOOL:
+      return builtin_type (gdbarch)->builtin_bool;

-      case TDESC_TYPE_INT8:
-        return builtin_type (gdbarch)->builtin_int8;
+    case TDESC_TYPE_INT8:
+      return builtin_type (gdbarch)->builtin_int8;

-      case TDESC_TYPE_INT16:
-        return builtin_type (gdbarch)->builtin_int16;
+    case TDESC_TYPE_INT16:
+      return builtin_type (gdbarch)->builtin_int16;

-      case TDESC_TYPE_INT32:
-        return builtin_type (gdbarch)->builtin_int32;
+    case TDESC_TYPE_INT32:
+      return builtin_type (gdbarch)->builtin_int32;

-      case TDESC_TYPE_INT64:
-        return builtin_type (gdbarch)->builtin_int64;
+    case TDESC_TYPE_INT64:
+      return builtin_type (gdbarch)->builtin_int64;

-      case TDESC_TYPE_INT128:
-        return builtin_type (gdbarch)->builtin_int128;
+    case TDESC_TYPE_INT128:
+      return builtin_type (gdbarch)->builtin_int128;

-      case TDESC_TYPE_UINT8:
-        return builtin_type (gdbarch)->builtin_uint8;
+    case TDESC_TYPE_UINT8:
+      return builtin_type (gdbarch)->builtin_uint8;

-      case TDESC_TYPE_UINT16:
-        return builtin_type (gdbarch)->builtin_uint16;
+    case TDESC_TYPE_UINT16:
+      return builtin_type (gdbarch)->builtin_uint16;

-      case TDESC_TYPE_UINT32:
-        return builtin_type (gdbarch)->builtin_uint32;
+    case TDESC_TYPE_UINT32:
+      return builtin_type (gdbarch)->builtin_uint32;

-      case TDESC_TYPE_UINT64:
-        return builtin_type (gdbarch)->builtin_uint64;
+    case TDESC_TYPE_UINT64:
+      return builtin_type (gdbarch)->builtin_uint64;

-      case TDESC_TYPE_UINT128:
-        return builtin_type (gdbarch)->builtin_uint128;
+    case TDESC_TYPE_UINT128:
+      return builtin_type (gdbarch)->builtin_uint128;

-      case TDESC_TYPE_CODE_PTR:
-        return builtin_type (gdbarch)->builtin_func_ptr;
+    case TDESC_TYPE_CODE_PTR:
+      return builtin_type (gdbarch)->builtin_func_ptr;

-      case TDESC_TYPE_DATA_PTR:
-        return builtin_type (gdbarch)->builtin_data_ptr;
-      }
+    case TDESC_TYPE_DATA_PTR:
+      return builtin_type (gdbarch)->builtin_data_ptr;
+    }

-    type *gdb_type = tdesc_find_type (gdbarch, this->name.c_str ());
-    if (gdb_type != NULL)
-      return gdb_type;
+  type *gdb_type = tdesc_find_type (gdbarch, this->name.c_str ());
+  if (gdb_type != NULL)
+    return gdb_type;

-    switch (this->kind)
-      {
-      case TDESC_TYPE_IEEE_SINGLE:
-        return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
-				floatformats_ieee_single);
+  switch (this->kind)
+    {
+    case TDESC_TYPE_IEEE_SINGLE:
+      return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
+			      floatformats_ieee_single);

-      case TDESC_TYPE_IEEE_DOUBLE:
-        return arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
-				floatformats_ieee_double);
+    case TDESC_TYPE_IEEE_DOUBLE:
+      return arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
+			      floatformats_ieee_double);

-      case TDESC_TYPE_ARM_FPA_EXT:
-        return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
-				floatformats_arm_ext);
+    case TDESC_TYPE_ARM_FPA_EXT:
+      return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
+			      floatformats_arm_ext);

-      case TDESC_TYPE_I387_EXT:
-        return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
-				floatformats_i387_ext);
-      }
+    case TDESC_TYPE_I387_EXT:
+      return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
+			      floatformats_i387_ext);
+    }

-    internal_error (__FILE__, __LINE__,
-		    "Type \"%s\" has an unknown kind %d",
-		    this->name.c_str (), this->kind);
+  internal_error (__FILE__, __LINE__,
+  		  "Type \"%s\" has an unknown kind %d",
+		  this->name.c_str (), this->kind);

-    return NULL;
-  }
-};
-
-/* tdesc_type for vector types.  */
+  return NULL;
+}

-struct tdesc_type_vector : tdesc_type
+type *tdesc_type_vector::make_gdb_type (struct gdbarch *gdbarch) const
 {
-  tdesc_type_vector (const std::string &name, tdesc_type *element_type_, int count_)
-  : tdesc_type (name, TDESC_TYPE_VECTOR),
-    element_type (element_type_), count (count_)
-  {}
-
-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit (this);
-  }
-
-  type *make_gdb_type (struct gdbarch *gdbarch) const override
-  {
-    type *vector_gdb_type = tdesc_find_type (gdbarch, this->name.c_str ());
-    if (vector_gdb_type != NULL)
-      return vector_gdb_type;
-
-    type *element_gdb_type = this->element_type->make_gdb_type (gdbarch);
-    vector_gdb_type = init_vector_type (element_gdb_type, this->count);
-    TYPE_NAME (vector_gdb_type) = xstrdup (this->name.c_str ());
-
+  type *vector_gdb_type = tdesc_find_type (gdbarch, this->name.c_str ());
+  if (vector_gdb_type != NULL)
     return vector_gdb_type;
-  }
-
-  struct tdesc_type *element_type;
-  int count;
-};

-/* tdesc_type for struct, union, flags, and enum types.  */
+  type *element_gdb_type = this->element_type->make_gdb_type (gdbarch);
+  vector_gdb_type = init_vector_type (element_gdb_type, this->count);
+  TYPE_NAME (vector_gdb_type) = xstrdup (this->name.c_str ());

-struct tdesc_type_with_fields : tdesc_type
-{
-  tdesc_type_with_fields (const std::string &name, tdesc_type_kind kind,
-			  int size_ = 0)
-  : tdesc_type (name, kind), size (size_)
-  {}
+  return vector_gdb_type;
+}

-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit (this);
-  }

-  type *make_gdb_type_struct (struct gdbarch *gdbarch) const
-  {
-    type *struct_gdb_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
-    TYPE_NAME (struct_gdb_type) = xstrdup (this->name.c_str ());
-    TYPE_TAG_NAME (struct_gdb_type) = TYPE_NAME (struct_gdb_type);
+type *tdesc_type_with_fields::make_gdb_type_struct (struct gdbarch *gdbarch) const
+{
+  type *struct_gdb_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  TYPE_NAME (struct_gdb_type) = xstrdup (this->name.c_str ());
+  TYPE_TAG_NAME (struct_gdb_type) = TYPE_NAME (struct_gdb_type);

-    for (const tdesc_type_field &f : this->fields)
-      {
-	if (f.start != -1 && f.end != -1)
-	  {
-	    /* Bitfield.  */
-	    struct field *fld;
-	    struct type *field_gdb_type;
-	    int bitsize, total_size;
-
-	    /* This invariant should be preserved while creating types.  */
-	    gdb_assert (this->size != 0);
-	    if (f.type != NULL)
-	      field_gdb_type = f.type->make_gdb_type (gdbarch);
-	    else if (this->size > 4)
-	      field_gdb_type = builtin_type (gdbarch)->builtin_uint64;
-	    else
-	      field_gdb_type = builtin_type (gdbarch)->builtin_uint32;
-
-	    fld = append_composite_type_field_raw
-	      (struct_gdb_type, xstrdup (f.name.c_str ()), field_gdb_type);
-
-	    /* For little-endian, BITPOS counts from the LSB of
-	       the structure and marks the LSB of the field.  For
-	       big-endian, BITPOS counts from the MSB of the
-	       structure and marks the MSB of the field.  Either
-	       way, it is the number of bits to the "left" of the
-	       field.  To calculate this in big-endian, we need
-	       the total size of the structure.  */
-	    bitsize = f.end - f.start + 1;
-	    total_size = this->size * TARGET_CHAR_BIT;
-	    if (gdbarch_bits_big_endian (gdbarch))
-	      SET_FIELD_BITPOS (fld[0], total_size - f.start - bitsize);
-	    else
-	      SET_FIELD_BITPOS (fld[0], f.start);
-	    FIELD_BITSIZE (fld[0]) = bitsize;
-	  }
-	else
-	  {
-	    gdb_assert (f.start == -1 && f.end == -1);
-	    type *field_gdb_type = f.type->make_gdb_type (gdbarch);
-	    append_composite_type_field (struct_gdb_type,
-					 xstrdup (f.name.c_str ()),
-					 field_gdb_type);
-	  }
-      }
+  for (const tdesc_type_field &f : this->fields)
+    {
+      if (f.start != -1 && f.end != -1)
+      	{
+	  /* Bitfield.  */
+	  struct field *fld;
+	  struct type *field_gdb_type;
+	  int bitsize, total_size;
+
+	  /* This invariant should be preserved while creating types.  */
+	  gdb_assert (this->size != 0);
+	  if (f.type != NULL)
+	    field_gdb_type = f.type->make_gdb_type (gdbarch);
+	  else if (this->size > 4)
+	    field_gdb_type = builtin_type (gdbarch)->builtin_uint64;
+	  else
+	    field_gdb_type = builtin_type (gdbarch)->builtin_uint32;
+
+	  fld = append_composite_type_field_raw
+	    (struct_gdb_type, xstrdup (f.name.c_str ()), field_gdb_type);
+
+	  /* For little-endian, BITPOS counts from the LSB of
+	     the structure and marks the LSB of the field.  For
+	     big-endian, BITPOS counts from the MSB of the
+	     structure and marks the MSB of the field.  Either
+	     way, it is the number of bits to the "left" of the
+	     field.  To calculate this in big-endian, we need
+	     the total size of the structure.  */
+	  bitsize = f.end - f.start + 1;
+	  total_size = this->size * TARGET_CHAR_BIT;
+	  if (gdbarch_bits_big_endian (gdbarch))
+	    SET_FIELD_BITPOS (fld[0], total_size - f.start - bitsize);
+	  else
+	    SET_FIELD_BITPOS (fld[0], f.start);
+	  FIELD_BITSIZE (fld[0]) = bitsize;
+	}
+      else
+	{
+	  gdb_assert (f.start == -1 && f.end == -1);
+	  type *field_gdb_type = f.type->make_gdb_type (gdbarch);
+	  append_composite_type_field (struct_gdb_type,
+				       xstrdup (f.name.c_str ()),
+				       field_gdb_type);
+	}
+    }

-    if (this->size != 0)
-      TYPE_LENGTH (struct_gdb_type) = this->size;
+  if (this->size != 0)
+    TYPE_LENGTH (struct_gdb_type) = this->size;

-    return struct_gdb_type;
-  }
+  return struct_gdb_type;
+}

-  type *make_gdb_type_union (struct gdbarch *gdbarch) const
-  {
-    type *union_gdb_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
-    TYPE_NAME (union_gdb_type) = xstrdup (this->name.c_str ());
+type *tdesc_type_with_fields::make_gdb_type_union (struct gdbarch *gdbarch) const
+{
+  type *union_gdb_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
+  TYPE_NAME (union_gdb_type) = xstrdup (this->name.c_str ());

-    for (const tdesc_type_field &f : this->fields)
-      {
-	type* field_gdb_type = f.type->make_gdb_type (gdbarch);
-	append_composite_type_field (union_gdb_type, xstrdup (f.name.c_str ()),
+  for (const tdesc_type_field &f : this->fields)
+    {
+      type* field_gdb_type = f.type->make_gdb_type (gdbarch);
+      append_composite_type_field (union_gdb_type, xstrdup (f.name.c_str ()),
 				     field_gdb_type);

-	/* If any of the children of a union are vectors, flag the
-	   union as a vector also.  This allows e.g. a union of two
-	   vector types to show up automatically in "info vector".  */
-	if (TYPE_VECTOR (field_gdb_type))
-	  TYPE_VECTOR (union_gdb_type) = 1;
-      }
+      /* If any of the children of a union are vectors, flag the
+	 union as a vector also.  This allows e.g. a union of two
+	 vector types to show up automatically in "info vector".  */
+      if (TYPE_VECTOR (field_gdb_type))
+	TYPE_VECTOR (union_gdb_type) = 1;
+    }

-    return union_gdb_type;
-  }
+  return union_gdb_type;
+}

-  type *make_gdb_type_flags (struct gdbarch *gdbarch) const
-  {
-    type *flags_gdb_type = arch_flags_type (gdbarch, this->name.c_str (),
+type *tdesc_type_with_fields::make_gdb_type_flags (struct gdbarch *gdbarch) const
+{
+  type *flags_gdb_type = arch_flags_type (gdbarch, this->name.c_str (),
 					  this->size * TARGET_CHAR_BIT);

-    for (const tdesc_type_field &f : this->fields)
-      {
+  for (const tdesc_type_field &f : this->fields)
+    {
       int bitsize = f.end - f.start + 1;

       gdb_assert (f.type != NULL);
       type *field_gdb_type = f.type->make_gdb_type (gdbarch);
       append_flags_type_field (flags_gdb_type, f.start, bitsize,
 			       field_gdb_type, f.name.c_str ());
-      }
+    }

-    return flags_gdb_type;
-  }
+  return flags_gdb_type;
+}

-  type *make_gdb_type_enum (struct gdbarch *gdbarch) const
-  {
-    type *enum_gdb_type = arch_type (gdbarch, TYPE_CODE_ENUM,
+type *tdesc_type_with_fields::make_gdb_type_enum (struct gdbarch *gdbarch) const
+{
+  type *enum_gdb_type = arch_type (gdbarch, TYPE_CODE_ENUM,
 				   this->size * TARGET_CHAR_BIT,
 				   this->name.c_str ());

-    TYPE_UNSIGNED (enum_gdb_type) = 1;
-    for (const tdesc_type_field &f : this->fields)
-      {
+  TYPE_UNSIGNED (enum_gdb_type) = 1;
+  for (const tdesc_type_field &f : this->fields)
+    {
       struct field *fld
 	= append_composite_type_field_raw (enum_gdb_type,
 					   xstrdup (f.name.c_str ()),
 					   NULL);

       SET_FIELD_BITPOS (fld[0], f.start);
-      }
-
-    return enum_gdb_type;
-  }
-
-  type *make_gdb_type (struct gdbarch *gdbarch) const override
-  {
-    type *gdb_type = tdesc_find_type (gdbarch, this->name.c_str ());
-    if (gdb_type != NULL)
-      return gdb_type;
-
-    switch (this->kind)
-    {
-      case TDESC_TYPE_STRUCT:
-	return make_gdb_type_struct (gdbarch);
-      case TDESC_TYPE_UNION:
-	return make_gdb_type_union (gdbarch);
-      case TDESC_TYPE_FLAGS:
-	return make_gdb_type_flags (gdbarch);
-      case TDESC_TYPE_ENUM:
-	return make_gdb_type_enum (gdbarch);
     }

-    internal_error (__FILE__, __LINE__,
-		    "Type \"%s\" has an unknown kind %d",
-		    this->name.c_str (), this->kind);
-
-    return NULL;
-  }
-
-  std::vector<tdesc_type_field> fields;
-  int size;
-};
-
-/* A feature from a target description.  Each feature is a collection
-   of other elements, e.g. registers and types.  */
-
-struct tdesc_feature : tdesc_element
-{
-  tdesc_feature (const std::string &name_)
-    : name (name_)
-  {}
-
-  virtual ~tdesc_feature () = default;
-
-  DISABLE_COPY_AND_ASSIGN (tdesc_feature);
-
-  /* The name of this feature.  It may be recognized by the architecture
-     support code.  */
-  std::string name;
-
-  /* The registers associated with this feature.  */
-  std::vector<tdesc_reg_up> registers;
-
-  /* The types associated with this feature.  */
-  std::vector<tdesc_type_up> types;
-
-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit_pre (this);
-
-    for (const tdesc_type_up &type : types)
-      type->accept (v);
-
-    for (const tdesc_reg_up &reg : registers)
-      reg->accept (v);
-
-    v.visit_post (this);
-  }
-
-  bool operator== (const tdesc_feature &other) const
-  {
-    if (name != other.name)
-      return false;
-
-    if (registers.size () != other.registers.size ())
-      return false;
-
-    for (int ix = 0; ix < registers.size (); ix++)
-      {
-	const tdesc_reg_up &reg1 = registers[ix];
-	const tdesc_reg_up &reg2 = other.registers[ix];
-
-	if (reg1 != reg2 && *reg1 != *reg2)
-	  return false;
-      }
-
-    if (types.size () != other.types.size ())
-      return false;
-
-    for (int ix = 0; ix < types.size (); ix++)
-      {
-	const tdesc_type_up &type1 = types[ix];
-	const tdesc_type_up &type2 = other.types[ix];
-
-	if (type1 != type2 && *type1 != *type2)
-	  return false;
-      }
-
-    return true;
-  }
-
-  bool operator!= (const tdesc_feature &other) const
-  {
-    return !(*this == other);
-  }
-};
-
-typedef std::unique_ptr<tdesc_feature> tdesc_feature_up;
-
-/* A target description.  */
+  return enum_gdb_type;
+}

-struct target_desc : tdesc_element
+type *tdesc_type_with_fields::make_gdb_type (struct gdbarch *gdbarch) const
 {
-  target_desc ()
-  {}
-
-  virtual ~target_desc () = default;
-
-  target_desc (const target_desc &) = delete;
-  void operator= (const target_desc &) = delete;
-
-  /* The architecture reported by the target, if any.  */
-  const struct bfd_arch_info *arch = NULL;
-
-  /* The osabi reported by the target, if any; GDB_OSABI_UNKNOWN
-     otherwise.  */
-  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
-
-  /* The list of compatible architectures reported by the target.  */
-  std::vector<const bfd_arch_info *> compatible;
-
-  /* Any architecture-specific properties specified by the target.  */
-  std::vector<property> properties;
-
-  /* The features associated with this target.  */
-  std::vector<tdesc_feature_up> features;
-
-  void accept (tdesc_element_visitor &v) const override
-  {
-    v.visit_pre (this);
-
-    for (const tdesc_feature_up &feature : features)
-      feature->accept (v);
-
-    v.visit_post (this);
-  }
-
-  bool operator== (const target_desc &other) const
-  {
-    if (arch != other.arch)
-      return false;
-
-    if (osabi != other.osabi)
-      return false;
-
-    if (features.size () != other.features.size ())
-      return false;
-
-    for (int ix = 0; ix < features.size (); ix++)
-      {
-	const tdesc_feature_up &feature1 = features[ix];
-	const tdesc_feature_up &feature2 = other.features[ix];
-
-	if (feature1 != feature2 && *feature1 != *feature2)
-	  return false;
-      }
-
-    return true;
-  }
-
-  bool operator!= (const target_desc &other) const
-  {
-    return !(*this == other);
-  }
-};
+  type *gdb_type = tdesc_find_type (gdbarch, this->name.c_str ());
+  if (gdb_type != NULL)
+    return gdb_type;

-/* Per-architecture data associated with a target description.  The
-   target description may be shared by multiple architectures, but
-   this data is private to one gdbarch.  */
+  switch (this->kind)
+    {
+    case TDESC_TYPE_STRUCT:
+      return make_gdb_type_struct (gdbarch);
+    case TDESC_TYPE_UNION:
+      return make_gdb_type_union (gdbarch);
+    case TDESC_TYPE_FLAGS:
+      return make_gdb_type_flags (gdbarch);
+    case TDESC_TYPE_ENUM:
+      return make_gdb_type_enum (gdbarch);
+    }

-struct tdesc_arch_reg
-{
-  tdesc_arch_reg (tdesc_reg *reg_, struct type *type_)
-  : reg (reg_), type (type_)
-  {}
+  internal_error (__FILE__, __LINE__,
+		  "Type \"%s\" has an unknown kind %d",
+		  this->name.c_str (), this->kind);

-  struct tdesc_reg *reg;
-  struct type *type;
-};
+  return NULL;
+}

 struct tdesc_arch_data
 {
@@ -957,58 +648,6 @@ tdesc_feature_name (const struct tdesc_feature *feature)
   return feature->name.c_str ();
 }

-/* Predefined types.  */
-static tdesc_type_builtin tdesc_predefined_types[] =
-{
-  { "bool", TDESC_TYPE_BOOL },
-  { "int8", TDESC_TYPE_INT8 },
-  { "int16", TDESC_TYPE_INT16 },
-  { "int32", TDESC_TYPE_INT32 },
-  { "int64", TDESC_TYPE_INT64 },
-  { "int128", TDESC_TYPE_INT128 },
-  { "uint8", TDESC_TYPE_UINT8 },
-  { "uint16", TDESC_TYPE_UINT16 },
-  { "uint32", TDESC_TYPE_UINT32 },
-  { "uint64", TDESC_TYPE_UINT64 },
-  { "uint128", TDESC_TYPE_UINT128 },
-  { "code_ptr", TDESC_TYPE_CODE_PTR },
-  { "data_ptr", TDESC_TYPE_DATA_PTR },
-  { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
-  { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
-  { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
-  { "i387_ext", TDESC_TYPE_I387_EXT }
-};
-
-/* Lookup a predefined type.  */
-
-static struct tdesc_type *
-tdesc_predefined_type (enum tdesc_type_kind kind)
-{
-  for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
-    if (tdesc_predefined_types[ix].kind == kind)
-      return &tdesc_predefined_types[ix];
-
-  gdb_assert_not_reached ("bad predefined tdesc type");
-}
-
-/* See arch/tdesc.h.  */
-
-struct tdesc_type *
-tdesc_named_type (const struct tdesc_feature *feature, const char *id)
-{
-  /* First try target-defined types.  */
-  for (const tdesc_type_up &type : feature->types)
-    if (type->name == id)
-      return type.get ();
-
-  /* Next try the predefined types.  */
-  for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
-    if (tdesc_predefined_types[ix].name == id)
-      return &tdesc_predefined_types[ix];
-
-  return NULL;
-}
-
 /* Lookup type associated with ID.  */

 struct type *
@@ -1440,161 +1079,6 @@ tdesc_use_registers (struct gdbarch *gdbarch,
 				      tdesc_remote_register_number);
   set_gdbarch_register_reggroup_p (gdbarch, tdesc_register_reggroup_p);
 }
-

-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_create_reg (struct tdesc_feature *feature, const char *name,
-		  int regnum, int save_restore, const char *group,
-		  int bitsize, const char *type)
-{
-  tdesc_reg *reg = new tdesc_reg (feature, name, regnum, save_restore,
-				  group, bitsize, type);
-
-  feature->registers.emplace_back (reg);
-}
-
-/* See arch/tdesc.h.  */
-
-struct tdesc_type *
-tdesc_create_vector (struct tdesc_feature *feature, const char *name,
-		     struct tdesc_type *field_type, int count)
-{
-  tdesc_type_vector *type = new tdesc_type_vector (name, field_type, count);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See arch/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_struct (struct tdesc_feature *feature, const char *name)
-{
-  tdesc_type_with_fields *type
-    = new tdesc_type_with_fields (name, TDESC_TYPE_STRUCT);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_set_struct_size (tdesc_type_with_fields *type, int size)
-{
-  gdb_assert (type->kind == TDESC_TYPE_STRUCT);
-  gdb_assert (size > 0);
-  type->size = size;
-}
-
-/* See arch/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_union (struct tdesc_feature *feature, const char *name)
-{
-  tdesc_type_with_fields *type
-    = new tdesc_type_with_fields (name, TDESC_TYPE_UNION);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See arch/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_flags (struct tdesc_feature *feature, const char *name,
-		    int size)
-{
-  gdb_assert (size > 0);
-
-  tdesc_type_with_fields *type
-    = new tdesc_type_with_fields (name, TDESC_TYPE_FLAGS, size);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-tdesc_type_with_fields *
-tdesc_create_enum (struct tdesc_feature *feature, const char *name,
-		   int size)
-{
-  gdb_assert (size > 0);
-
-  tdesc_type_with_fields *type
-    = new tdesc_type_with_fields (name, TDESC_TYPE_ENUM, size);
-  feature->types.emplace_back (type);
-
-  return type;
-}
-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
-		 struct tdesc_type *field_type)
-{
-  gdb_assert (type->kind == TDESC_TYPE_UNION
-	      || type->kind == TDESC_TYPE_STRUCT);
-
-  /* Initialize start and end so we know this is not a bit-field
-     when we print-c-tdesc.  */
-  type->fields.emplace_back (field_name, field_type, -1, -1);
-}
-
-void
-tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_name,
-			  int start, int end, struct tdesc_type *field_type)
-{
-  gdb_assert (type->kind == TDESC_TYPE_STRUCT
-	      || type->kind == TDESC_TYPE_FLAGS);
-  gdb_assert (start >= 0 && end >= start);
-
-  type->fields.emplace_back (field_name, field_type, start, end);
-}
-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
-		    int start, int end)
-{
-  struct tdesc_type *field_type;
-
-  gdb_assert (start >= 0 && end >= start);
-
-  if (type->size > 4)
-    field_type = tdesc_predefined_type (TDESC_TYPE_UINT64);
-  else
-    field_type = tdesc_predefined_type (TDESC_TYPE_UINT32);
-
-  tdesc_add_typed_bitfield (type, field_name, start, end, field_type);
-}
-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_add_flag (tdesc_type_with_fields *type, int start,
-		const char *flag_name)
-{
-  gdb_assert (type->kind == TDESC_TYPE_FLAGS
-	      || type->kind == TDESC_TYPE_STRUCT);
-
-  type->fields.emplace_back (flag_name,
-			     tdesc_predefined_type (TDESC_TYPE_BOOL),
-			     start, start);
-}
-
-void
-tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
-		      const char *name)
-{
-  gdb_assert (type->kind == TDESC_TYPE_ENUM);
-  type->fields.emplace_back (name,
-			     tdesc_predefined_type (TDESC_TYPE_INT32),
-			     value, -1);
-}

 /* See arch/tdesc.h.  */

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

* [PATCH 2/6]: gdbserver use common tdesc functions
  2018-01-16  9:52 [PATCH 0/6] : Remove XML files from gdbserver Alan Hayward
  2018-01-16  9:51 ` [PATCH 1/6] : Commonise various target-descriptions.c functions Alan Hayward
@ 2018-01-16  9:52 ` Alan Hayward
  2018-01-16  9:53 ` [PATCH 3/6] : Update dat files with arch and osabi Alan Hayward
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Alan Hayward @ 2018-01-16  9:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd

This moves gdbserver over to using the common tdesc functions.
gdbserver now parses target descriptions using the same code
as gdb. These parsed structures are not (yet) used once parsed.

tdesc_feature and target_desc are no longer interchangeable in
gdbserver, and is now it's own structure. It does not share
code with gdb, as gdbsever has additional fields it still
requires - mainly the reg_defs and registers_size fields (as
used by regcache). These fields are now populated in
init_target_desc() from the common tdesc fields. A future patch
could change regcache to access the newer tdesc fields but that
is outside of the scope of this patch series.

Alan.

2018-01-16  Alan Hayward  <alan.hayward@arm.com>

gdb/
	* arch/tdesc.h: Allow code to compile for gdbserver.
	* regformats/regdat.sh: Explicitly create a feature.

gdbserver/
	* Makefile.in: Add the new common file.
	* tdesc.c (tdesc_feature): Replaced by common version.
	(void target_desc::~target_desc): Moved from .c file.
	(void target_desc::accept): Blank function.
	(bool target_desc::operator==): Moved from .c file.
	(init_target_desc): Init reg_defs from parsed feature. 
	(tdesc_get_features_xml): features is now a vector.
	(struct tdesc_type): Remove. Use common version.
	(tdesc_create_feature): Create new structure.
	(tdesc_create_flags):  Remove. Use common version.
	(tdesc_add_flag): Likewise.
	(tdesc_named_type): Likewise.
	(tdesc_create_union): Likewise.
	(tdesc_create_struct): Likewise.
	(type *tdesc_type_builtin::make_gdb_type): Blank stub.
	(type *tdesc_type_vector::make_gdb_type): Likewise.
	(tdesc_add_bitfield): Likewise.
	(tdesc_add_field): Likewise.
	* tdesc.h (struct target_desc): Update field types.

diff --git a/gdb/arch/tdesc.h b/gdb/arch/tdesc.h
index 22da5efa48f8cf5e94c33c9eed4739127467c356..633853447d98c952cfed462939b486afd2738742 100644
--- a/gdb/arch/tdesc.h
+++ b/gdb/arch/tdesc.h
@@ -33,8 +33,6 @@ struct tdesc_reg;
 struct target_desc;
 struct type;

-#ifndef GDBSERVER
-
 /* The interface to visit different elements of target description.  */

 class tdesc_element_visitor
@@ -295,8 +293,6 @@ struct tdesc_arch_reg
   struct type *type;
 };

-#endif
-
 /* Allocate a new target_desc.  */
 target_desc *allocate_target_description (void);

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 3ce086d70f23df445b174c49c489ec8415d7614a..8ae124875dd08f31e8424b18281cb1454ed40edb 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -194,6 +194,7 @@ SFILES = \
 	$(srcdir)/arch/arm.c \
 	$(srcdir)/arch/arm-get-next-pcs.c \
 	$(srcdir)/arch/arm-linux.c \
+	$(srcdir)/../arch/tdesc.c \
 	$(srcdir)/common/btrace-common.c \
 	$(srcdir)/common/buffer.c \
 	$(srcdir)/common/cleanups.c \
@@ -232,6 +233,7 @@ TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS}

 OBS = \
 	agent.o \
+	arch/tdesc.o \
 	ax.o \
 	btrace-common.o \
 	buffer.o \
@@ -391,6 +393,7 @@ gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) $(LIBGNU) $(LIBIBERTY)
 	  $(XM_CLIBS) $(LIBGNU) $(LIBIBERTY)

 IPA_OBJS = \
+	arch/tdesc-ipa.o \
 	ax-ipa.o \
 	common-utils-ipa.o \
 	errors-ipa.o \
diff --git a/gdb/gdbserver/tdesc.h b/gdb/gdbserver/tdesc.h
index 783500598b5599e51f8e768a876fdfe499cdf0ef..499ed0e4598ae812f2d1ceb1fa8e8f1f50c14fff 100644
--- a/gdb/gdbserver/tdesc.h
+++ b/gdb/gdbserver/tdesc.h
@@ -24,13 +24,9 @@
 #include "regdef.h"
 #include <vector>

-struct tdesc_feature
-{};
+/* A target description.  */

-/* A target description.  Inherit from tdesc_feature so that target_desc
-   can be used as tdesc_feature.  */
-
-struct target_desc : tdesc_feature
+struct target_desc : tdesc_element
 {
   /* A vector of elements of register definitions that
      describe the inferior's register set.  */
@@ -52,70 +48,34 @@ struct target_desc : tdesc_feature
      It can be NULL, then, its content is got from the following three
      fields features, arch, and osabi in tdesc_get_features_xml.  */
   const char *xmltarget = NULL;
+#endif

   /* XML features in this target description.  */
-  VEC (char_ptr) *features = NULL;
+  std::vector<tdesc_feature_up> features;

+#ifndef IN_PROCESS_AGENT
   /* The value of <architecture> element in the XML, replying GDB.  */
   const char *arch = NULL;

   /* The value of <osabi> element in the XML, replying GDB.  */
   const char *osabi = NULL;
+#endif

 public:
   target_desc ()
     : registers_size (0)
   {}

-  ~target_desc ()
-  {
-    int i;
-
-    for (reg *reg : reg_defs)
-      xfree (reg);
+  ~target_desc ();

-    xfree ((char *) arch);
-    xfree ((char *) osabi);
+  void accept (tdesc_element_visitor &v) const override;

-    char *f;
-
-    for (i = 0; VEC_iterate (char_ptr, features, i, f); i++)
-      xfree (f);
-    VEC_free (char_ptr, features);
-  }
-
-  bool operator== (const target_desc &other) const
-  {
-    if (reg_defs.size () != other.reg_defs.size ())
-      return false;
-
-    for (int i = 0; i < reg_defs.size (); ++i)
-      {
-	struct reg *reg = reg_defs[i];
-	struct reg *reg2 = other.reg_defs[i];
-
-	if (reg != reg2 && *reg != *reg2)
-	  return false;
-      }
-
-    /* Compare expedite_regs.  */
-    int i = 0;
-    for (; expedite_regs[i] != NULL; i++)
-      {
-	if (strcmp (expedite_regs[i], other.expedite_regs[i]) != 0)
-	  return false;
-      }
-    if (other.expedite_regs[i] != NULL)
-      return false;
-
-    return true;
-  }
+  bool operator== (const target_desc &other) const;

   bool operator!= (const target_desc &other) const
   {
     return !(*this == other);
   }
-#endif
 };

 /* Copy target description SRC to DEST.  */
diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c
index c39b5e7d27e879c5d3fb49b6e04d1eb6128f8eef..a96b3f07e7aff81f32a160d6498c8012d18bd0c7 100644
--- a/gdb/gdbserver/tdesc.c
+++ b/gdb/gdbserver/tdesc.c
@@ -19,16 +19,78 @@
 #include "tdesc.h"
 #include "regdef.h"

+target_desc::~target_desc ()
+{
+  for (reg *reg : reg_defs)
+    xfree (reg);
+
+#ifndef IN_PROCESS_AGENT
+  xfree ((char *) arch);
+  xfree ((char *) osabi);
+#endif
+}
+
+void target_desc::accept (tdesc_element_visitor &v) const
+{}
+
+bool target_desc::operator== (const target_desc &other) const
+{
+  if (reg_defs.size () != other.reg_defs.size ())
+    return false;
+
+  for (int i = 0; i < reg_defs.size (); ++i)
+    {
+      struct reg *reg = reg_defs[i];
+      struct reg *reg2 = other.reg_defs[i];
+
+      if (reg != reg2 && *reg != *reg2)
+	return false;
+    }
+
+#ifndef IN_PROCESS_AGENT
+  /* Compare expedite_regs.  */
+  int i = 0;
+  for (; expedite_regs[i] != NULL; i++)
+    {
+      if (strcmp (expedite_regs[i], other.expedite_regs[i]) != 0)
+	return false;
+    }
+  if (other.expedite_regs[i] != NULL)
+    return false;
+#endif
+
+  return true;
+}
+
 void
 init_target_desc (struct target_desc *tdesc)
 {
   int offset = 0;

-  for (reg *reg : tdesc->reg_defs)
-    {
-      reg->offset = offset;
-      offset += reg->size;
-    }
+  /* Go through all the features and populate reg_defs.  */
+  for (const tdesc_feature_up &feature : tdesc->features)
+    for (const tdesc_reg_up &treg : feature->registers)
+      {
+	/* Fill in any blank spaces.  */
+	while (tdesc->reg_defs.size () < treg->target_regnum)
+	  {
+	    struct reg *reg = XCNEW (struct reg);
+	    reg->name = "";
+	    reg->size = 0;
+	    reg->offset = offset;
+	    tdesc->reg_defs.push_back (reg);
+	  }
+
+	gdb_assert (treg->target_regnum == 0
+		    || treg->target_regnum == tdesc->reg_defs.size ());
+
+	struct reg *reg = XCNEW (struct reg);
+	reg->name = treg->name.c_str ();
+	reg->size = treg->bitsize;
+	reg->offset = offset;
+	tdesc->reg_defs.push_back (reg);
+	offset += reg->size;
+      }

   tdesc->registers_size = offset / 8;

@@ -91,7 +153,7 @@ tdesc_get_features_xml (target_desc *tdesc)
 {
   /* Either .xmltarget or .features is not NULL.  */
   gdb_assert (tdesc->xmltarget != NULL
-	      || (tdesc->features != NULL
+	      || (!tdesc->features.empty ()
 		  && tdesc->arch != NULL));

   if (tdesc->xmltarget == NULL)
@@ -111,12 +173,10 @@ tdesc_get_features_xml (target_desc *tdesc)
 	  buffer += "</osabi>";
 	}

-      char *xml;
-
-      for (int i = 0; VEC_iterate (char_ptr, tdesc->features, i, xml); i++)
+      for (const tdesc_feature_up &feature : tdesc->features)
 	{
 	  buffer += "<xi:include href=\"";
-	  buffer += xml;
+	  buffer += feature->name;
 	  buffer += "\"/>";
 	}

@@ -129,113 +189,28 @@ tdesc_get_features_xml (target_desc *tdesc)
 }
 #endif

-struct tdesc_type
-{};
-
 /* See arch/tdesc.h.  */

 struct tdesc_feature *
 tdesc_create_feature (struct target_desc *tdesc, const char *name,
 		      const char *xml)
 {
-#ifndef IN_PROCESS_AGENT
-  VEC_safe_push (char_ptr, tdesc->features, xstrdup (xml));
-#endif
-  return tdesc;
-}
-
-/* See arch/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_flags (struct tdesc_feature *feature, const char *name,
-		    int size)
-{
-  return NULL;
-}
-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_add_flag (tdesc_type_with_fields *type, int start,
-		const char *flag_name)
-{}
-
-/* See arch/tdesc.h.  */
-
-struct tdesc_type *
-tdesc_named_type (const struct tdesc_feature *feature, const char *id)
-{
-  return NULL;
+  struct tdesc_feature *new_feature = new tdesc_feature (name);
+  tdesc->features.emplace_back (new_feature);
+  return new_feature;
 }

-/* See arch/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_union (struct tdesc_feature *feature, const char *id)
+type *tdesc_type_builtin::make_gdb_type (struct gdbarch *gdbarch) const
 {
-  return NULL;
-}
-
-/* See arch/tdesc.h.  */
-
-tdesc_type_with_fields *
-tdesc_create_struct (struct tdesc_feature *feature, const char *id)
-{
-  return NULL;
-}
-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_create_reg (struct tdesc_feature *feature, const char *name,
-		  int regnum, int save_restore, const char *group,
-		  int bitsize, const char *type)
-{
-  struct target_desc *tdesc = (struct target_desc *) feature;
-
-  while (tdesc->reg_defs.size () < regnum)
-    {
-      struct reg *reg = XCNEW (struct reg);
-
-      reg->name = "";
-      reg->size = 0;
-      tdesc->reg_defs.push_back (reg);
-    }
-
-  gdb_assert (regnum == 0
-	      || regnum == tdesc->reg_defs.size ());
-
-  struct reg *reg = XCNEW (struct reg);
-
-  reg->name = name;
-  reg->size = bitsize;
-  tdesc->reg_defs.push_back (reg);
+  error (_("Cannot create gdbtypes."));
 }

-/* See arch/tdesc.h.  */
-
-struct tdesc_type *
-tdesc_create_vector (struct tdesc_feature *feature, const char *name,
-		     struct tdesc_type *field_type, int count)
+type *tdesc_type_vector::make_gdb_type (struct gdbarch *gdbarch) const
 {
-  return NULL;
+  error (_("Cannot create gdbtypes."));
 }

-void
-tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
-		    int start, int end)
-{}
-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
-		 struct tdesc_type *field_type)
-{}
-
-/* See arch/tdesc.h.  */
-
-void
-tdesc_set_struct_size (tdesc_type_with_fields *type, int size)
+type *tdesc_type_with_fields::make_gdb_type (struct gdbarch *gdbarch) const
 {
-}
+  error (_("Cannot create gdbtypes."));
+}
\ No newline at end of file
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index ce1627120d9439082709c82c5804724f39477eb1..8c6e191596350fb4e983f8736985d9832f41e2d3 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -131,7 +131,7 @@ do
     echo "{"
     echo "  static struct target_desc tdesc_${name}_s;"
     echo "  struct target_desc *result = &tdesc_${name}_s;"
-
+    echo "  struct tdesc_feature *feature = tdesc_create_feature (result, \"${name}\");"
     continue
   elif test "${type}" = "xmltarget"; then
     xmltarget="${entry}"
@@ -149,7 +149,7 @@ do
     echo "$0: $1 does not specify \`\`name''." 1>&2
     exit 1
   else
-    echo "  tdesc_create_reg ((struct tdesc_feature *) result, \"${entry}\","
+    echo "  tdesc_create_reg (feature, \"${entry}\","
     echo "  0, 0, NULL, ${type}, NULL);"

     offset=`expr ${offset} + ${type}`


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

* [PATCH 0/6] : Remove XML files from gdbserver
@ 2018-01-16  9:52 Alan Hayward
  2018-01-16  9:51 ` [PATCH 1/6] : Commonise various target-descriptions.c functions Alan Hayward
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Alan Hayward @ 2018-01-16  9:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd

This set of patches removes the need for gdbserver to ship the xml files
in the binary.

In exisiting code, gdbserver uses C code auto generated from xml files to
create target descriptions. When sending an xml description to GDB, it
creates xml containing mostly just the name of the original xml file.

With this new patch, we add common code that allows gdbserver and gdb
to turn a C target description structure into xml. This allows gdbserver
to send a full xml description.

The first patch starts by commonising all the gdb target-description code,
which is then used by gdbserver in patch two.
Patch four is the meat, which adds the target description to xml parser,
including adding a generic debug(tdesc) function.
The other three patches proceed to remove the no longer required code and
xml files.

Patches have been tested on a make check on x86 targets=all build with
target board unix native-gdbserver. In addition, patch four adds new test
cases to unit test.


Alan.

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

* [PATCH 3/6] : Update dat files with arch and osabi
  2018-01-16  9:52 [PATCH 0/6] : Remove XML files from gdbserver Alan Hayward
  2018-01-16  9:51 ` [PATCH 1/6] : Commonise various target-descriptions.c functions Alan Hayward
  2018-01-16  9:52 ` [PATCH 2/6]: gdbserver use common tdesc functions Alan Hayward
@ 2018-01-16  9:53 ` Alan Hayward
  2018-01-19 22:01   ` Yao Qi
  2018-01-16  9:55 ` [PATCH 6/6]: Remove xml files from gdbserver Alan Hayward
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Alan Hayward @ 2018-01-16  9:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd

This patch simply ensures the osabi and arch fields exist in the dat
files. Otherwise, they will be missing in later patches when gdbserver
converts target descriptions to xml.

The patch changes regdat.sh and Makefile, and then regenerated the dat
files.

Alan.

2018-01-16  Alan Hayward  <alan.hayward@arm.com>

	* features/Makefile: Add arch and osabi to .dat.
	* regformats/aarch64.dat: Regenerate.
	* regformats/arm/arm-with-iwmmxt.dat: Likewise.
	* regformats/arm/arm-with-neon.dat: Likewise.
	* regformats/arm/arm-with-vfpv2.dat: Likewise.
	* regformats/arm/arm-with-vfpv3.dat: Likewise.
	* regformats/i386/amd64-avx-avx512-linux.dat: Likewise.
	* regformats/i386/amd64-avx-linux.dat: Likewise.
	* regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat: Likewise.
	* regformats/i386/amd64-avx-mpx-linux.dat: Likewise.
	* regformats/i386/amd64-linux.dat: Likewise.
	* regformats/i386/amd64-mpx-linux.dat: Likewise.
	* regformats/i386/amd64.dat: Likewise.
	* regformats/i386/i386-avx-avx512-linux.dat: Likewise.
	* regformats/i386/i386-avx-linux.dat: Likewise.
	* regformats/i386/i386-avx-mpx-avx512-pku-linux.dat: Likewise.
	* regformats/i386/i386-avx-mpx-linux.dat: Likewise.
	* regformats/i386/i386-avx.dat: Remove.
	* regformats/i386/i386-linux.dat: Likewise.
	* regformats/i386/i386-mmx-linux.dat: Likewise.
	* regformats/i386/i386-mpx-linux.dat: Likewise.
	* regformats/i386/i386.dat: Likewise.
	* regformats/i386/x32-avx-avx512-linux.dat: Likewise.
	* regformats/i386/x32-avx-linux.dat: Likewise.
	* regformats/i386/x32-linux.dat: Likewise.
	* regformats/mips-dsp-linux.dat: Likewise.
	* regformats/mips-linux.dat: Likewise.
	* regformats/mips64-dsp-linux.dat: Likewise.
	* regformats/mips64-linux.dat: Likewise.
	* regformats/nios2-linux.dat: Likewise.
	* regformats/regdat.sh: Check for arch and osabi.
	* regformats/rs6000/powerpc-32.dat:  Add arch and osabi to .dat.
	* regformats/rs6000/powerpc-32l.dat: Likewise.
	* regformats/rs6000/powerpc-64l.dat: Likewise.
	* regformats/rs6000/powerpc-altivec32l.dat: Likewise.
	* regformats/rs6000/powerpc-altivec64l.dat: Likewise.
	* regformats/rs6000/powerpc-cell32l.dat: Likewise.
	* regformats/rs6000/powerpc-cell64l.dat: Likewise.
	* regformats/rs6000/powerpc-e500l.dat: Likewise.
	* regformats/rs6000/powerpc-isa205-32l.dat: Likewise.
	* regformats/rs6000/powerpc-isa205-64l.dat: Likewise.
	* regformats/rs6000/powerpc-isa205-altivec32l.dat: Likewise.
	* regformats/rs6000/powerpc-isa205-altivec64l.dat: Likewise.
	* regformats/rs6000/powerpc-isa205-vsx32l.dat: Likewise.
	* regformats/rs6000/powerpc-isa205-vsx64l.dat: Likewise.
	* regformats/rs6000/powerpc-vsx32l.dat: Likewise.
	* regformats/rs6000/powerpc-vsx64l.dat: Likewise.
	* regformats/s390-gs-linux64.dat: Likewise.
	* regformats/s390-linux32.dat: Likewise.
	* regformats/s390-linux32v1.dat: Likewise.
	* regformats/s390-linux32v2.dat: Likewise.
	* regformats/s390-linux64.dat: Likewise.
	* regformats/s390-linux64v1.dat: Likewise.
	* regformats/s390-linux64v2.dat: Likewise.
	* regformats/s390-te-linux64.dat: Likewise.
	* regformats/s390-tevx-linux64.dat: Likewise.
	* regformats/s390-vx-linux64.dat: Likewise.
	* regformats/s390x-gs-linux64.dat: Likewise.
	* regformats/s390x-linux64.dat: Likewise.
	* regformats/s390x-linux64v1.dat: Likewise.
	* regformats/s390x-linux64v2.dat: Likewise.
	* regformats/s390x-te-linux64.dat: Likewise.
	* regformats/s390x-tevx-linux64.dat: Likewise.
	* regformats/s390x-vx-linux64.dat: Likewise.
	* regformats/tic6x-c62x-linux.dat: Likewise.
	* regformats/tic6x-c64x-linux.dat: Likewise.
	* regformats/tic6x-c64xp-linux.dat: Likewise.

diff --git a/gdb/features/Makefile b/gdb/features/Makefile
index 82609f5862fa95dbc587c7cc08537373faf7bfd6..96478b051262fadb074e37300f09cadbd5a1512c 100644
--- a/gdb/features/Makefile
+++ b/gdb/features/Makefile
@@ -202,6 +202,8 @@ $(outdir)/%.dat: %.xml number-regs.xsl sort-regs.xsl gdbserver-regs.xsl
 	echo "xmltarget:$(<F)" >> $(outdir)/$*.tmp
 	echo "expedite:$(if $($*-expedite),$($*-expedite),$($(firstword $(subst -, ,$(notdir $*)))-expedite))" \
 	  >> $(outdir)/$*.tmp
+	sed -n 's:.*<osabi>\(.*\)</osabi>.*:osabi\:\1:p' $*.xml >> $(outdir)/$*.tmp
+	sed -n 's:.*<architecture>\(.*\)</architecture>.*:xmlarch\:\1:p' $*.xml >> $(outdir)/$*.tmp
 	$(XSLTPROC) --path "$(PWD)" --xinclude number-regs.xsl $< | \
 	  $(XSLTPROC) sort-regs.xsl - | \
 	  $(XSLTPROC) gdbserver-regs.xsl - >> $(outdir)/$*.tmp
diff --git a/gdb/regformats/aarch64.dat b/gdb/regformats/aarch64.dat
index d4cea04358ecf6a7b0645353b1944d49113632ed..2a150e50bf8d2a1fea13e0ea3dbc024705865bb9 100644
--- a/gdb/regformats/aarch64.dat
+++ b/gdb/regformats/aarch64.dat
@@ -3,6 +3,7 @@
 name:aarch64
 xmltarget:aarch64.xml
 expedite:x29,sp,pc
+xmlarch:aarch64
 64:x0
 64:x1
 64:x2
diff --git a/gdb/regformats/arm/arm-with-iwmmxt.dat b/gdb/regformats/arm/arm-with-iwmmxt.dat
index f529c2c493c39ff204a22d34c8a2c7a622f349a2..71fd07075b0a80d062a93b4a5f81a8b703818fde 100644
--- a/gdb/regformats/arm/arm-with-iwmmxt.dat
+++ b/gdb/regformats/arm/arm-with-iwmmxt.dat
@@ -3,6 +3,7 @@
 name:arm_with_iwmmxt
 xmltarget:arm-with-iwmmxt.xml
 expedite:r11,sp,pc
+xmlarch:iwmmxt
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/arm/arm-with-neon.dat b/gdb/regformats/arm/arm-with-neon.dat
index 2e6cb85cf4bc1712b640fdca902774f87bdac376..2c58e1b590dc9a729f9e024b3d559878a7ccbf2d 100644
--- a/gdb/regformats/arm/arm-with-neon.dat
+++ b/gdb/regformats/arm/arm-with-neon.dat
@@ -3,6 +3,7 @@
 name:arm_with_neon
 xmltarget:arm-with-neon.xml
 expedite:r11,sp,pc
+xmlarch:arm
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/arm/arm-with-vfpv2.dat b/gdb/regformats/arm/arm-with-vfpv2.dat
index aa71f85bcb26f11c8a4ded0738d39fdaf3c3f9f9..456977ec09b6125f12071f9f5fec828fe0baecca 100644
--- a/gdb/regformats/arm/arm-with-vfpv2.dat
+++ b/gdb/regformats/arm/arm-with-vfpv2.dat
@@ -3,6 +3,7 @@
 name:arm_with_vfpv2
 xmltarget:arm-with-vfpv2.xml
 expedite:r11,sp,pc
+xmlarch:arm
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/arm/arm-with-vfpv3.dat b/gdb/regformats/arm/arm-with-vfpv3.dat
index 6fec4fd8f5d11ee8f29402704fb7e55f7fc9ea45..9fe6f6e0219f78f5dcdd04388874cb1bc9132f41 100644
--- a/gdb/regformats/arm/arm-with-vfpv3.dat
+++ b/gdb/regformats/arm/arm-with-vfpv3.dat
@@ -3,6 +3,7 @@
 name:arm_with_vfpv3
 xmltarget:arm-with-vfpv3.xml
 expedite:r11,sp,pc
+xmlarch:arm
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/i386/amd64-avx-avx512-linux.dat b/gdb/regformats/i386/amd64-avx-avx512-linux.dat
index 0743693886bb3984074191698155d7b0c422008b..76cb4bf3e1ab0d42ccf271a2c5263aec74438884 100644
--- a/gdb/regformats/i386/amd64-avx-avx512-linux.dat
+++ b/gdb/regformats/i386/amd64-avx-avx512-linux.dat
@@ -3,6 +3,8 @@
 name:amd64_avx_avx512_linux
 xmltarget:amd64-avx-avx512-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x86-64
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/amd64-avx-linux.dat b/gdb/regformats/i386/amd64-avx-linux.dat
index 7780b3b6a214592fdd6c7afce6215351ff4787d8..f07a45c1d7df267e69dfa3af7eb49a417e16d9f7 100644
--- a/gdb/regformats/i386/amd64-avx-linux.dat
+++ b/gdb/regformats/i386/amd64-avx-linux.dat
@@ -3,6 +3,8 @@
 name:amd64_avx_linux
 xmltarget:amd64-avx-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x86-64
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat b/gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat
index 9cd0fae8202596630fdab8321c6cb7c7ba38c7af..d55a3dbd08cb979ac8bf268f979fbb9b8461ff4f 100644
--- a/gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat
+++ b/gdb/regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat
@@ -3,6 +3,8 @@
 name:amd64_avx_mpx_avx512_pku_linux
 xmltarget:amd64-avx-mpx-avx512-pku-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x86-64
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/amd64-avx-mpx-linux.dat b/gdb/regformats/i386/amd64-avx-mpx-linux.dat
index 7c2f928070fe291e5ca1249617fe8b8e96644912..4b81aaebc7813dd50ac962a115f128e02a910a15 100644
--- a/gdb/regformats/i386/amd64-avx-mpx-linux.dat
+++ b/gdb/regformats/i386/amd64-avx-mpx-linux.dat
@@ -3,6 +3,8 @@
 name:amd64_avx_mpx_linux
 xmltarget:amd64-avx-mpx-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x86-64
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/amd64-linux.dat b/gdb/regformats/i386/amd64-linux.dat
index cd16a1544283edd5e22f9bd8ce4ae56012af7833..893a8873f783b40571f071b5ea3f1ec899a99bf8 100644
--- a/gdb/regformats/i386/amd64-linux.dat
+++ b/gdb/regformats/i386/amd64-linux.dat
@@ -3,6 +3,8 @@
 name:amd64_linux
 xmltarget:amd64-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x86-64
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/amd64-mpx-linux.dat b/gdb/regformats/i386/amd64-mpx-linux.dat
index 10487f698708b431ca9e5cf9c6a077c78651ad33..bf6fe32fd90c646b42db8eb00fd90d42b17cc8cb 100644
--- a/gdb/regformats/i386/amd64-mpx-linux.dat
+++ b/gdb/regformats/i386/amd64-mpx-linux.dat
@@ -3,6 +3,8 @@
 name:amd64_mpx_linux
 xmltarget:amd64-mpx-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x86-64
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/amd64.dat b/gdb/regformats/i386/amd64.dat
index 66f26ad0947eca8849ff5f5ca67f173d6705ba70..05d3d133caf07b105bab6ea50fa974b0ccf9b920 100644
--- a/gdb/regformats/i386/amd64.dat
+++ b/gdb/regformats/i386/amd64.dat
@@ -3,6 +3,7 @@
 name:amd64
 xmltarget:amd64.xml
 expedite:rbp,rsp,rip
+xmlarch:i386:x86-64
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/i386-avx-avx512-linux.dat b/gdb/regformats/i386/i386-avx-avx512-linux.dat
index 4477133997252ff3fc375b772dbdc1f8d723132d..e0bda8c6a94d12e535b75269957a1dc090051198 100644
--- a/gdb/regformats/i386/i386-avx-avx512-linux.dat
+++ b/gdb/regformats/i386/i386-avx-avx512-linux.dat
@@ -3,6 +3,8 @@
 name:i386_avx_avx512_linux
 xmltarget:i386-avx-avx512-linux.xml
 expedite:ebp,esp,eip
+osabi:GNU/Linux
+xmlarch:i386
 32:eax
 32:ecx
 32:edx
diff --git a/gdb/regformats/i386/i386-avx-linux.dat b/gdb/regformats/i386/i386-avx-linux.dat
index 1c3fcfd7633b937e2ce4e033a4706a8d9d14d277..9a21f7f1a2a21289e2619158f7c758bb5d37a629 100644
--- a/gdb/regformats/i386/i386-avx-linux.dat
+++ b/gdb/regformats/i386/i386-avx-linux.dat
@@ -3,6 +3,8 @@
 name:i386_avx_linux
 xmltarget:i386-avx-linux.xml
 expedite:ebp,esp,eip
+osabi:GNU/Linux
+xmlarch:i386
 32:eax
 32:ecx
 32:edx
diff --git a/gdb/regformats/i386/i386-avx-mpx-avx512-pku-linux.dat b/gdb/regformats/i386/i386-avx-mpx-avx512-pku-linux.dat
index 515ee10525bd8b9fb238e4f0fb14815b65a7b73f..5fe5f64e7868e27cf140fe26a0db72e34b15f178 100644
--- a/gdb/regformats/i386/i386-avx-mpx-avx512-pku-linux.dat
+++ b/gdb/regformats/i386/i386-avx-mpx-avx512-pku-linux.dat
@@ -3,6 +3,8 @@
 name:i386_avx_mpx_avx512_pku_linux
 xmltarget:i386-avx-mpx-avx512-pku-linux.xml
 expedite:ebp,esp,eip
+osabi:GNU/Linux
+xmlarch:i386
 32:eax
 32:ecx
 32:edx
diff --git a/gdb/regformats/i386/i386-avx-mpx-linux.dat b/gdb/regformats/i386/i386-avx-mpx-linux.dat
index 831c476fef4398d661fc00412f165f61daf3b2a0..82df093b25f39b1c88e78f4a5c19ad26409c086a 100644
--- a/gdb/regformats/i386/i386-avx-mpx-linux.dat
+++ b/gdb/regformats/i386/i386-avx-mpx-linux.dat
@@ -3,6 +3,8 @@
 name:i386_avx_mpx_linux
 xmltarget:i386-avx-mpx-linux.xml
 expedite:ebp,esp,eip
+osabi:GNU/Linux
+xmlarch:i386
 32:eax
 32:ecx
 32:edx
diff --git a/gdb/regformats/i386/i386-avx.dat b/gdb/regformats/i386/i386-avx.dat
deleted file mode 100644
index 67eaa33a1aef63457594d15bcec088e9771fa0d6..0000000000000000000000000000000000000000
--- a/gdb/regformats/i386/i386-avx.dat
+++ /dev/null
@@ -1,54 +0,0 @@
-# THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi :set ro:
-# Generated from: i386/i386-avx.xml
-name:i386_avx
-xmltarget:i386-avx.xml
-expedite:ebp,esp,eip
-32:eax
-32:ecx
-32:edx
-32:ebx
-32:esp
-32:ebp
-32:esi
-32:edi
-32:eip
-32:eflags
-32:cs
-32:ss
-32:ds
-32:es
-32:fs
-32:gs
-80:st0
-80:st1
-80:st2
-80:st3
-80:st4
-80:st5
-80:st6
-80:st7
-32:fctrl
-32:fstat
-32:ftag
-32:fiseg
-32:fioff
-32:foseg
-32:fooff
-32:fop
-128:xmm0
-128:xmm1
-128:xmm2
-128:xmm3
-128:xmm4
-128:xmm5
-128:xmm6
-128:xmm7
-32:mxcsr
-128:ymm0h
-128:ymm1h
-128:ymm2h
-128:ymm3h
-128:ymm4h
-128:ymm5h
-128:ymm6h
-128:ymm7h
diff --git a/gdb/regformats/i386/i386-linux.dat b/gdb/regformats/i386/i386-linux.dat
index 0e414e649029020eefd789026787f9959bb791d3..937b6536a15733432478ad5c5b2014ca792d038c 100644
--- a/gdb/regformats/i386/i386-linux.dat
+++ b/gdb/regformats/i386/i386-linux.dat
@@ -3,6 +3,8 @@
 name:i386_linux
 xmltarget:i386-linux.xml
 expedite:ebp,esp,eip
+osabi:GNU/Linux
+xmlarch:i386
 32:eax
 32:ecx
 32:edx
diff --git a/gdb/regformats/i386/i386-mmx-linux.dat b/gdb/regformats/i386/i386-mmx-linux.dat
index aa2a564ac7466e4cb13fb02c9c386b2847b3aa3b..1bef702be43e9ea29cfda7aeb6ac6d2090e52d82 100644
--- a/gdb/regformats/i386/i386-mmx-linux.dat
+++ b/gdb/regformats/i386/i386-mmx-linux.dat
@@ -3,6 +3,8 @@
 name:i386_mmx_linux
 xmltarget:i386-mmx-linux.xml
 expedite:ebp,esp,eip
+osabi:GNU/Linux
+xmlarch:i386
 32:eax
 32:ecx
 32:edx
diff --git a/gdb/regformats/i386/i386-mpx-linux.dat b/gdb/regformats/i386/i386-mpx-linux.dat
index 1dcdce98cf50141722cb273ad379d00339a33483..c7ee4b762cb1274e241a453503937fc27c1107c8 100644
--- a/gdb/regformats/i386/i386-mpx-linux.dat
+++ b/gdb/regformats/i386/i386-mpx-linux.dat
@@ -3,6 +3,8 @@
 name:i386_mpx_linux
 xmltarget:i386-mpx-linux.xml
 expedite:ebp,esp,eip
+osabi:GNU/Linux
+xmlarch:i386
 32:eax
 32:ecx
 32:edx
diff --git a/gdb/regformats/i386/i386.dat b/gdb/regformats/i386/i386.dat
index 13abb485e4913a471b2992fc12e49eded688fbe3..bb258b266b91c1a8bb32bc1614dda77c4ff820d8 100644
--- a/gdb/regformats/i386/i386.dat
+++ b/gdb/regformats/i386/i386.dat
@@ -3,6 +3,7 @@
 name:i386
 xmltarget:i386.xml
 expedite:ebp,esp,eip
+xmlarch:i386
 32:eax
 32:ecx
 32:edx
diff --git a/gdb/regformats/i386/x32-avx-avx512-linux.dat b/gdb/regformats/i386/x32-avx-avx512-linux.dat
index 00786172fb9809b4eb5f0cc4fc4408b31dc0f677..f5a79f453d3d1d71e7820685d4ef80bc191e1bf4 100644
--- a/gdb/regformats/i386/x32-avx-avx512-linux.dat
+++ b/gdb/regformats/i386/x32-avx-avx512-linux.dat
@@ -3,6 +3,8 @@
 name:x32_avx_avx512_linux
 xmltarget:x32-avx-avx512-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x64-32
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/x32-avx-linux.dat b/gdb/regformats/i386/x32-avx-linux.dat
index eb0e395366e68d692e38158302908bfed4269720..7bfc7a86269d7f037877f04301651f4e078ad9be 100644
--- a/gdb/regformats/i386/x32-avx-linux.dat
+++ b/gdb/regformats/i386/x32-avx-linux.dat
@@ -3,6 +3,8 @@
 name:x32_avx_linux
 xmltarget:x32-avx-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x64-32
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/i386/x32-linux.dat b/gdb/regformats/i386/x32-linux.dat
index eee378fd846a8ac5ee5ba503190bc25245eddef3..b669f325ec689f75b46396d85ff7965f3f9b3355 100644
--- a/gdb/regformats/i386/x32-linux.dat
+++ b/gdb/regformats/i386/x32-linux.dat
@@ -3,6 +3,8 @@
 name:x32_linux
 xmltarget:x32-linux.xml
 expedite:rbp,rsp,rip
+osabi:GNU/Linux
+xmlarch:i386:x64-32
 64:rax
 64:rbx
 64:rcx
diff --git a/gdb/regformats/mips-dsp-linux.dat b/gdb/regformats/mips-dsp-linux.dat
index ce37bf38bdb9322acd0ee5cebbecf7eb62183a9f..0994fbfe4f3b8068215ca3d8baa9bee5c137dbd0 100644
--- a/gdb/regformats/mips-dsp-linux.dat
+++ b/gdb/regformats/mips-dsp-linux.dat
@@ -3,6 +3,8 @@
 name:mips_dsp_linux
 xmltarget:mips-dsp-linux.xml
 expedite:r29,pc
+osabi:GNU/Linux
+xmlarch:mips
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/mips-linux.dat b/gdb/regformats/mips-linux.dat
index d95e2c9ed455d536eb046d1e56a11b8fd51ea3ea..e181c7a10879ea259e110c77082f77f651879315 100644
--- a/gdb/regformats/mips-linux.dat
+++ b/gdb/regformats/mips-linux.dat
@@ -3,6 +3,8 @@
 name:mips_linux
 xmltarget:mips-linux.xml
 expedite:r29,pc
+osabi:GNU/Linux
+xmlarch:mips
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/mips64-dsp-linux.dat b/gdb/regformats/mips64-dsp-linux.dat
index e73df93d69b8a2e9064e167e071eb2bf9e99e876..3c8179de2dca87e0b9ac99a135596176639f2a59 100644
--- a/gdb/regformats/mips64-dsp-linux.dat
+++ b/gdb/regformats/mips64-dsp-linux.dat
@@ -3,6 +3,7 @@
 name:mips64_dsp_linux
 xmltarget:mips64-dsp-linux.xml
 expedite:r29,pc
+xmlarch:mips
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/mips64-linux.dat b/gdb/regformats/mips64-linux.dat
index 6770c8f65455d6b5329e6eb430c7da1a6b269958..5e503ce59d5f348a1360147a7001996571234a4d 100644
--- a/gdb/regformats/mips64-linux.dat
+++ b/gdb/regformats/mips64-linux.dat
@@ -3,6 +3,7 @@
 name:mips64_linux
 xmltarget:mips64-linux.xml
 expedite:r29,pc
+xmlarch:mips
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/nios2-linux.dat b/gdb/regformats/nios2-linux.dat
index fe4af2f4f361d693ea64f59ae5ecdbe488f9945b..6036dc8439e1fe54e359ff46a9cb6c8aee535a95 100644
--- a/gdb/regformats/nios2-linux.dat
+++ b/gdb/regformats/nios2-linux.dat
@@ -3,6 +3,8 @@
 name:nios2_linux
 xmltarget:nios2-linux.xml
 expedite:sp,pc
+osabi:GNU/Linux
+xmlarch:nios2
 32:zero
 32:at
 32:r2
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 8c6e191596350fb4e983f8736985d9832f41e2d3..8341e11ba76031cc260d60fdc2071bc8a2188f8e 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -177,8 +177,17 @@ else
 fi
 echo

+echo "#ifndef IN_PROCESS_AGENT"
+
+if test "${xmlarch}" != x; then
+  echo "set_tdesc_architecture (result, \"${xmlarch}\");"
+fi
+
+if test "${xmlosabi}" != x; then
+  echo "set_tdesc_osabi (result, \"${xmlosabi}\");"
+fi
+
 cat <<EOF
-#ifndef IN_PROCESS_AGENT
   result->expedite_regs = expedite_regs_${name};
   result->xmltarget = xmltarget_${name};
 #endif
diff --git a/gdb/regformats/rs6000/powerpc-32.dat b/gdb/regformats/rs6000/powerpc-32.dat
index 266636b11f95d68a8842c86eff140582c1b3bb0a..fe648439bd14da8171ee5f9612bddfab0c812ea6 100644
--- a/gdb/regformats/rs6000/powerpc-32.dat
+++ b/gdb/regformats/rs6000/powerpc-32.dat
@@ -3,6 +3,7 @@
 name:powerpc_32
 xmltarget:powerpc-32.xml
 expedite:r1,pc
+xmlarch:powerpc:common
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-32l.dat b/gdb/regformats/rs6000/powerpc-32l.dat
index 2c8ccbe49b9827c54d7d6a3ec498a1e8d289bf29..626984f4892663d994788763ce79ba92c098a8b3 100644
--- a/gdb/regformats/rs6000/powerpc-32l.dat
+++ b/gdb/regformats/rs6000/powerpc-32l.dat
@@ -3,6 +3,7 @@
 name:powerpc_32l
 xmltarget:powerpc-32l.xml
 expedite:r1,pc
+xmlarch:powerpc:common
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-64l.dat b/gdb/regformats/rs6000/powerpc-64l.dat
index 10f43b16241a2cf94e2e9b21d9140e0a34d42f4f..20cfae1fc42a0c5ee5de1df3b221d0007c533fbc 100644
--- a/gdb/regformats/rs6000/powerpc-64l.dat
+++ b/gdb/regformats/rs6000/powerpc-64l.dat
@@ -3,6 +3,7 @@
 name:powerpc_64l
 xmltarget:powerpc-64l.xml
 expedite:r1,pc
+xmlarch:powerpc:common64
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/rs6000/powerpc-altivec32l.dat b/gdb/regformats/rs6000/powerpc-altivec32l.dat
index c792a2f96161ce55c63f9e17b14a35df7b71705d..4475dccbea85cbc5dd7115049e0502a4fc463618 100644
--- a/gdb/regformats/rs6000/powerpc-altivec32l.dat
+++ b/gdb/regformats/rs6000/powerpc-altivec32l.dat
@@ -3,6 +3,7 @@
 name:powerpc_altivec32l
 xmltarget:powerpc-altivec32l.xml
 expedite:r1,pc
+xmlarch:powerpc:common
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-altivec64l.dat b/gdb/regformats/rs6000/powerpc-altivec64l.dat
index a806141b6eee6a9015a06bddb5efb0b1eeafc002..73ff175c348738dee5e5ead296487fbd793ae3f4 100644
--- a/gdb/regformats/rs6000/powerpc-altivec64l.dat
+++ b/gdb/regformats/rs6000/powerpc-altivec64l.dat
@@ -3,6 +3,7 @@
 name:powerpc_altivec64l
 xmltarget:powerpc-altivec64l.xml
 expedite:r1,pc
+xmlarch:powerpc:common64
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/rs6000/powerpc-cell32l.dat b/gdb/regformats/rs6000/powerpc-cell32l.dat
index bd285054958360a13dfe3cc0424b2b70132f8be7..31975be687bc41159d1b6e3853ee4b5f3d5ec2b3 100644
--- a/gdb/regformats/rs6000/powerpc-cell32l.dat
+++ b/gdb/regformats/rs6000/powerpc-cell32l.dat
@@ -3,6 +3,7 @@
 name:powerpc_cell32l
 xmltarget:powerpc-cell32l.xml
 expedite:r1,pc,r0,orig_r3,r4
+xmlarch:powerpc:common
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-cell64l.dat b/gdb/regformats/rs6000/powerpc-cell64l.dat
index b5b162eced28b8b369765d72cde58828bfc7209b..ce940d9c410d0148567aa50a99c4226e86a393ca 100644
--- a/gdb/regformats/rs6000/powerpc-cell64l.dat
+++ b/gdb/regformats/rs6000/powerpc-cell64l.dat
@@ -3,6 +3,7 @@
 name:powerpc_cell64l
 xmltarget:powerpc-cell64l.xml
 expedite:r1,pc,r0,orig_r3,r4
+xmlarch:powerpc:common64
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/rs6000/powerpc-e500l.dat b/gdb/regformats/rs6000/powerpc-e500l.dat
index 750eafed7ca2fd872e0c30097fc305cb509b5c86..a13e29470e5dbd7c1d61fecc7b444f84447023f8 100644
--- a/gdb/regformats/rs6000/powerpc-e500l.dat
+++ b/gdb/regformats/rs6000/powerpc-e500l.dat
@@ -3,6 +3,7 @@
 name:powerpc_e500l
 xmltarget:powerpc-e500l.xml
 expedite:r1,pc
+xmlarch:powerpc:e500
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-isa205-32l.dat b/gdb/regformats/rs6000/powerpc-isa205-32l.dat
index 7227d06c977350c460d8bec46331e2ff470cdadd..3e011aa71321fcee9118433e2d2c8fe505433c95 100644
--- a/gdb/regformats/rs6000/powerpc-isa205-32l.dat
+++ b/gdb/regformats/rs6000/powerpc-isa205-32l.dat
@@ -3,6 +3,7 @@
 name:powerpc_isa205_32l
 xmltarget:powerpc-isa205-32l.xml
 expedite:r1,pc
+xmlarch:powerpc:common
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-isa205-64l.dat b/gdb/regformats/rs6000/powerpc-isa205-64l.dat
index 13a72c7eb8f14871252fe028b5ef67b9af170256..12a5e265e2eb9cc3d99ccfe1f78486d927b44bb5 100644
--- a/gdb/regformats/rs6000/powerpc-isa205-64l.dat
+++ b/gdb/regformats/rs6000/powerpc-isa205-64l.dat
@@ -3,6 +3,7 @@
 name:powerpc_isa205_64l
 xmltarget:powerpc-isa205-64l.xml
 expedite:r1,pc
+xmlarch:powerpc:common64
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/rs6000/powerpc-isa205-altivec32l.dat b/gdb/regformats/rs6000/powerpc-isa205-altivec32l.dat
index 051724c6132d2c23783b5cb2767e799ae89b48dc..539670e0b568937ebf85e13a24faaf810f296197 100644
--- a/gdb/regformats/rs6000/powerpc-isa205-altivec32l.dat
+++ b/gdb/regformats/rs6000/powerpc-isa205-altivec32l.dat
@@ -3,6 +3,7 @@
 name:powerpc_isa205_altivec32l
 xmltarget:powerpc-isa205-altivec32l.xml
 expedite:r1,pc
+xmlarch:powerpc:common
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-isa205-altivec64l.dat b/gdb/regformats/rs6000/powerpc-isa205-altivec64l.dat
index 867e82135167776d2f9febf2cfd001657ca1b827..929084354fbea7eef0f37cc47ecb6168f4def7a1 100644
--- a/gdb/regformats/rs6000/powerpc-isa205-altivec64l.dat
+++ b/gdb/regformats/rs6000/powerpc-isa205-altivec64l.dat
@@ -3,6 +3,7 @@
 name:powerpc_isa205_altivec64l
 xmltarget:powerpc-isa205-altivec64l.xml
 expedite:r1,pc
+xmlarch:powerpc:common64
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/rs6000/powerpc-isa205-vsx32l.dat b/gdb/regformats/rs6000/powerpc-isa205-vsx32l.dat
index fa05cae859452ed4d7587d09af21cf13dd1d1df0..82e9dd7a26a4084166607873fc379baf3bd04148 100644
--- a/gdb/regformats/rs6000/powerpc-isa205-vsx32l.dat
+++ b/gdb/regformats/rs6000/powerpc-isa205-vsx32l.dat
@@ -3,6 +3,7 @@
 name:powerpc_isa205_vsx32l
 xmltarget:powerpc-isa205-vsx32l.xml
 expedite:r1,pc
+xmlarch:powerpc:common
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-isa205-vsx64l.dat b/gdb/regformats/rs6000/powerpc-isa205-vsx64l.dat
index 75bd4539ad06964ed6937339f40ea1bb4f69a233..5f91fed8e6492c58eddef1dc800096921031d9d4 100644
--- a/gdb/regformats/rs6000/powerpc-isa205-vsx64l.dat
+++ b/gdb/regformats/rs6000/powerpc-isa205-vsx64l.dat
@@ -3,6 +3,7 @@
 name:powerpc_isa205_vsx64l
 xmltarget:powerpc-isa205-vsx64l.xml
 expedite:r1,pc
+xmlarch:powerpc:common64
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/rs6000/powerpc-vsx32l.dat b/gdb/regformats/rs6000/powerpc-vsx32l.dat
index 6db3e38d5f235b05f6fe736f3717023d6b516c13..3471d10d7a210b7d4ca008fca4ea25b7071631c8 100644
--- a/gdb/regformats/rs6000/powerpc-vsx32l.dat
+++ b/gdb/regformats/rs6000/powerpc-vsx32l.dat
@@ -3,6 +3,7 @@
 name:powerpc_vsx32l
 xmltarget:powerpc-vsx32l.xml
 expedite:r1,pc
+xmlarch:powerpc:common
 32:r0
 32:r1
 32:r2
diff --git a/gdb/regformats/rs6000/powerpc-vsx64l.dat b/gdb/regformats/rs6000/powerpc-vsx64l.dat
index bc0a45512c81c15b13c60d4478cd85b545a2e44c..a87b1f00a9777f29059c34b96721576861cd8078 100644
--- a/gdb/regformats/rs6000/powerpc-vsx64l.dat
+++ b/gdb/regformats/rs6000/powerpc-vsx64l.dat
@@ -3,6 +3,7 @@
 name:powerpc_vsx64l
 xmltarget:powerpc-vsx64l.xml
 expedite:r1,pc
+xmlarch:powerpc:common64
 64:r0
 64:r1
 64:r2
diff --git a/gdb/regformats/s390-gs-linux64.dat b/gdb/regformats/s390-gs-linux64.dat
index 130c8ecc026dc5fca6e6ee87ccdd39302d3fff5a..8f1dbb10c8eb46546b2c9cbb1f4fa09e31997e54 100644
--- a/gdb/regformats/s390-gs-linux64.dat
+++ b/gdb/regformats/s390-gs-linux64.dat
@@ -3,6 +3,7 @@
 name:s390_gs_linux64
 xmltarget:s390-gs-linux64.xml
 expedite:r14,r15,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0h
diff --git a/gdb/regformats/s390-linux32.dat b/gdb/regformats/s390-linux32.dat
index 545dd0fb91535288f01837f2d587c27de75fbb76..7445e64764050c0ff968b12206391d7ea99c1d80 100644
--- a/gdb/regformats/s390-linux32.dat
+++ b/gdb/regformats/s390-linux32.dat
@@ -3,6 +3,7 @@
 name:s390_linux32
 xmltarget:s390-linux32.xml
 expedite:r14,r15,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0
diff --git a/gdb/regformats/s390-linux32v1.dat b/gdb/regformats/s390-linux32v1.dat
index b9e7fc89730733db082dd2636bdab846b6004eee..98ffed8dd64acdede8d565b20ca6184a055a218e 100644
--- a/gdb/regformats/s390-linux32v1.dat
+++ b/gdb/regformats/s390-linux32v1.dat
@@ -3,6 +3,7 @@
 name:s390_linux32v1
 xmltarget:s390-linux32v1.xml
 expedite:r14,r15,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0
diff --git a/gdb/regformats/s390-linux32v2.dat b/gdb/regformats/s390-linux32v2.dat
index 220af5e3dfb2ef742550c31ef225d155cac14189..ff43ece3e754ce8a0512a94b9eaa202b70731f26 100644
--- a/gdb/regformats/s390-linux32v2.dat
+++ b/gdb/regformats/s390-linux32v2.dat
@@ -3,6 +3,7 @@
 name:s390_linux32v2
 xmltarget:s390-linux32v2.xml
 expedite:r14,r15,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0
diff --git a/gdb/regformats/s390-linux64.dat b/gdb/regformats/s390-linux64.dat
index b347b6bf33a789558f332cdc1d81089e7652caf5..ae61eb82c624d2b7d631e499dd3ffbc0e609baa2 100644
--- a/gdb/regformats/s390-linux64.dat
+++ b/gdb/regformats/s390-linux64.dat
@@ -3,6 +3,7 @@
 name:s390_linux64
 xmltarget:s390-linux64.xml
 expedite:r14l,r15l,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0h
diff --git a/gdb/regformats/s390-linux64v1.dat b/gdb/regformats/s390-linux64v1.dat
index 8abd92d3a2e4d1361f9617f51d78fb9f7741b475..8f50d028d04b44b25bbaec141525ae3433af4b78 100644
--- a/gdb/regformats/s390-linux64v1.dat
+++ b/gdb/regformats/s390-linux64v1.dat
@@ -3,6 +3,7 @@
 name:s390_linux64v1
 xmltarget:s390-linux64v1.xml
 expedite:r14l,r15l,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0h
diff --git a/gdb/regformats/s390-linux64v2.dat b/gdb/regformats/s390-linux64v2.dat
index b282025e2386aad11d446e33bb7d228220e58bbd..265bdf271c93f29520dfbc9d086b5e67d68267dd 100644
--- a/gdb/regformats/s390-linux64v2.dat
+++ b/gdb/regformats/s390-linux64v2.dat
@@ -3,6 +3,7 @@
 name:s390_linux64v2
 xmltarget:s390-linux64v2.xml
 expedite:r14l,r15l,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0h
diff --git a/gdb/regformats/s390-te-linux64.dat b/gdb/regformats/s390-te-linux64.dat
index 28e1b8733ebedf40c5238c754cfe95aad65ea0dd..a784a11553132d7079950f9c5578bc836fbceb68 100644
--- a/gdb/regformats/s390-te-linux64.dat
+++ b/gdb/regformats/s390-te-linux64.dat
@@ -3,6 +3,7 @@
 name:s390_te_linux64
 xmltarget:s390-te-linux64.xml
 expedite:r14l,r15l,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0h
diff --git a/gdb/regformats/s390-tevx-linux64.dat b/gdb/regformats/s390-tevx-linux64.dat
index 3db7a91546bb0172138413ffc76a54da0efa29df..020960e948e06e55ab9309d481d9e3d029809975 100644
--- a/gdb/regformats/s390-tevx-linux64.dat
+++ b/gdb/regformats/s390-tevx-linux64.dat
@@ -3,6 +3,7 @@
 name:s390_tevx_linux64
 xmltarget:s390-tevx-linux64.xml
 expedite:r14l,r15l,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0h
diff --git a/gdb/regformats/s390-vx-linux64.dat b/gdb/regformats/s390-vx-linux64.dat
index 6a821fd5ac47447d55a9a7fbf9120a2e02381968..f06ac589ce21cb27451c9b05875e54e4ddffaeda 100644
--- a/gdb/regformats/s390-vx-linux64.dat
+++ b/gdb/regformats/s390-vx-linux64.dat
@@ -3,6 +3,7 @@
 name:s390_vx_linux64
 xmltarget:s390-vx-linux64.xml
 expedite:r14l,r15l,pswa
+xmlarch:s390:31-bit
 32:pswm
 32:pswa
 32:r0h
diff --git a/gdb/regformats/s390x-gs-linux64.dat b/gdb/regformats/s390x-gs-linux64.dat
index 8cd57515e5163ee3221b635b1e3ea2a6714d8bf0..72e3e7089ba15668439904b62cb2fa33a96dd216 100644
--- a/gdb/regformats/s390x-gs-linux64.dat
+++ b/gdb/regformats/s390x-gs-linux64.dat
@@ -3,6 +3,7 @@
 name:s390x_gs_linux64
 xmltarget:s390x-gs-linux64.xml
 expedite:r14,r15,pswa
+xmlarch:s390:64-bit
 64:pswm
 64:pswa
 64:r0
diff --git a/gdb/regformats/s390x-linux64.dat b/gdb/regformats/s390x-linux64.dat
index 5832c438f59778d86cea30ad5faa06607b1f803e..802a6036577390695f8594ba7ef361c55f89f3bf 100644
--- a/gdb/regformats/s390x-linux64.dat
+++ b/gdb/regformats/s390x-linux64.dat
@@ -3,6 +3,7 @@
 name:s390x_linux64
 xmltarget:s390x-linux64.xml
 expedite:r14,r15,pswa
+xmlarch:s390:64-bit
 64:pswm
 64:pswa
 64:r0
diff --git a/gdb/regformats/s390x-linux64v1.dat b/gdb/regformats/s390x-linux64v1.dat
index 4d4de0a14cf60a694d418786fc1070998fe0f846..d499eafb7e4a6b24f7502942d4ebfb6d9780a8e3 100644
--- a/gdb/regformats/s390x-linux64v1.dat
+++ b/gdb/regformats/s390x-linux64v1.dat
@@ -3,6 +3,7 @@
 name:s390x_linux64v1
 xmltarget:s390x-linux64v1.xml
 expedite:r14,r15,pswa
+xmlarch:s390:64-bit
 64:pswm
 64:pswa
 64:r0
diff --git a/gdb/regformats/s390x-linux64v2.dat b/gdb/regformats/s390x-linux64v2.dat
index b1c5f830231a7ddfbf91fb2776928fa47ba6ef90..45a770541c4b0a4775a7dda35ebacc77caefc7b2 100644
--- a/gdb/regformats/s390x-linux64v2.dat
+++ b/gdb/regformats/s390x-linux64v2.dat
@@ -3,6 +3,7 @@
 name:s390x_linux64v2
 xmltarget:s390x-linux64v2.xml
 expedite:r14,r15,pswa
+xmlarch:s390:64-bit
 64:pswm
 64:pswa
 64:r0
diff --git a/gdb/regformats/s390x-te-linux64.dat b/gdb/regformats/s390x-te-linux64.dat
index 80f5ab127ee0d5a3f163641c791d328c564b5232..682d47e586304d74d08b2b0f0b4c902aaeb14b49 100644
--- a/gdb/regformats/s390x-te-linux64.dat
+++ b/gdb/regformats/s390x-te-linux64.dat
@@ -3,6 +3,7 @@
 name:s390x_te_linux64
 xmltarget:s390x-te-linux64.xml
 expedite:r14,r15,pswa
+xmlarch:s390:64-bit
 64:pswm
 64:pswa
 64:r0
diff --git a/gdb/regformats/s390x-tevx-linux64.dat b/gdb/regformats/s390x-tevx-linux64.dat
index 2df31e6863249e3ebf31dfead3a47621126f5a08..f3190cfd07c09dd129d3a7eb63771910086cd239 100644
--- a/gdb/regformats/s390x-tevx-linux64.dat
+++ b/gdb/regformats/s390x-tevx-linux64.dat
@@ -3,6 +3,7 @@
 name:s390x_tevx_linux64
 xmltarget:s390x-tevx-linux64.xml
 expedite:r14,r15,pswa
+xmlarch:s390:64-bit
 64:pswm
 64:pswa
 64:r0
diff --git a/gdb/regformats/s390x-vx-linux64.dat b/gdb/regformats/s390x-vx-linux64.dat
index 1d8f2b6f04370adca545f0b2caa17bc7423f45a0..fe21013119ba16fe3a1414a39311f9dcb77b21a2 100644
--- a/gdb/regformats/s390x-vx-linux64.dat
+++ b/gdb/regformats/s390x-vx-linux64.dat
@@ -3,6 +3,7 @@
 name:s390x_vx_linux64
 xmltarget:s390x-vx-linux64.xml
 expedite:r14,r15,pswa
+xmlarch:s390:64-bit
 64:pswm
 64:pswa
 64:r0
diff --git a/gdb/regformats/tic6x-c62x-linux.dat b/gdb/regformats/tic6x-c62x-linux.dat
index 82f2a0a0bf03d8bdfbbfc1917169e6ecd1497d4f..efcdee1342e88dae6680a9de182138d362ff0b10 100644
--- a/gdb/regformats/tic6x-c62x-linux.dat
+++ b/gdb/regformats/tic6x-c62x-linux.dat
@@ -3,6 +3,8 @@
 name:tic6x_c62x_linux
 xmltarget:tic6x-c62x-linux.xml
 expedite:A15,PC
+osabi:GNU/Linux
+xmlarch:tic6x
 32:A0
 32:A1
 32:A2
diff --git a/gdb/regformats/tic6x-c64x-linux.dat b/gdb/regformats/tic6x-c64x-linux.dat
index 542826ad1d34db5a291359ded18aaf52ba50c88c..8e70cf9cf913b807ea55a4f26921e1e4e79d7b8e 100644
--- a/gdb/regformats/tic6x-c64x-linux.dat
+++ b/gdb/regformats/tic6x-c64x-linux.dat
@@ -3,6 +3,8 @@
 name:tic6x_c64x_linux
 xmltarget:tic6x-c64x-linux.xml
 expedite:A15,PC
+osabi:GNU/Linux
+xmlarch:tic6x
 32:A0
 32:A1
 32:A2
diff --git a/gdb/regformats/tic6x-c64xp-linux.dat b/gdb/regformats/tic6x-c64xp-linux.dat
index 229b3c26c25f0361994789bf3d6e1b5e48a9d488..b6b0e8bc333123e6c1addc95842b84df8ab91b6c 100644
--- a/gdb/regformats/tic6x-c64xp-linux.dat
+++ b/gdb/regformats/tic6x-c64xp-linux.dat
@@ -3,6 +3,8 @@
 name:tic6x_c64xp_linux
 xmltarget:tic6x-c64xp-linux.xml
 expedite:A15,PC
+osabi:GNU/Linux
+xmlarch:tic6x
 32:A0
 32:A1
 32:A2


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

* [PATCH 6/6]: Remove xml files from gdbserver
  2018-01-16  9:52 [PATCH 0/6] : Remove XML files from gdbserver Alan Hayward
                   ` (2 preceding siblings ...)
  2018-01-16  9:53 ` [PATCH 3/6] : Update dat files with arch and osabi Alan Hayward
@ 2018-01-16  9:55 ` Alan Hayward
  2018-01-19 22:11   ` Yao Qi
  2018-01-16  9:55 ` [PATCH 5/6] : Remove xml file references from target descriptions Alan Hayward
  2018-01-16  9:55 ` [PATCH 4/6]: Create xml " Alan Hayward
  5 siblings, 1 reply; 17+ messages in thread
From: Alan Hayward @ 2018-01-16  9:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd

This patch removes the xml files from being built into gdbserver,

Alan.

2018-01-16  Alan Hayward  <alan.hayward@arm.com>

	* gdb/gdbserver/Makefile.in: Don't include xml.
	* gdb/gdbserver/configure: Remove all the xml files.
	* gdb/gdbserver/configure.ac: Don't include xml.
	* gdb/gdbserver/configure.srv: Likewise.

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 8ae124875dd08f31e8424b18281cb1454ed40edb..3158f8df86ab63b5642b0f38befc4b6bb71cf7dd 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -276,19 +276,13 @@ OBS = \
 	waitstatus.o \
 	xml-utils.o \
 	$(DEPFILES) \
-	$(LIBOBJS) \
-	$(XML_BUILTIN)
+	$(LIBOBJS)

 GDBREPLAY_OBS = gdbreplay.o version.o
 GDBSERVER_LIBS = @GDBSERVER_LIBS@
 XM_CLIBS = @LIBS@
 CDEPS = $(srcdir)/proc-service.list

-# XML files to compile in to gdbserver, if any.
-XML_DIR = $(srcdir)/../features
-XML_FILES = @srv_xmlfiles@
-XML_BUILTIN = @srv_xmlbuiltin@
-
 IPA_DEPFILES = @IPA_DEPFILES@
 extra_libraries = @extra_libraries@

@@ -498,15 +492,6 @@ version-generated.c: Makefile $(srcdir)/../version.in $(srcdir)/../../bfd/versio
 	$(SHELL) $(srcdir)/../common/create-version.sh $(srcdir)/.. \
 	    $(host_alias) $(target_alias) $@

-xml-builtin-generated.c: stamp-xml; @true
-stamp-xml: $(XML_DIR)/feature_to_c.sh Makefile $(XML_FILES)
-	rm -f xml-builtin.tmp
-	$(SHELL) $(XML_DIR)/feature_to_c.sh xml-builtin.tmp $(XML_FILES)
-	$(SHELL) $(srcdir)/../../move-if-change xml-builtin.tmp xml-builtin-generated.c
-	echo stamp > stamp-xml
-
-.PRECIOUS: xml-builtin.c
-
 # GNU Make has an annoying habit of putting *all* the Makefile variables
 # into the environment, unless you include this target as a circumvention.
 # Rumor is that this will be fixed (and this target can be removed)
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index ca51321c8469282a54dbc1adc8cf52ced64dc290..a49db164fed523238b2f944caf9187593b03e405 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -593,8 +593,6 @@ LIBOBJS
 GNULIB_STDINT_H
 extra_libraries
 IPA_DEPFILES
-srv_xmlfiles
-srv_xmlbuiltin
 GDBSERVER_LIBS
 GDBSERVER_DEPFILES
 RDYNAMIC
@@ -8275,19 +8273,6 @@ $as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1" >>confdefs.h

 fi

-if test "$srv_xmlfiles" != ""; then
-  srv_xmlbuiltin="xml-builtin.o"
-
-$as_echo "#define USE_XML 1" >>confdefs.h
-
-
-  tmp_xmlfiles=$srv_xmlfiles
-  srv_xmlfiles=""
-  for f in $tmp_xmlfiles; do
-    srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
-  done
-fi
-
 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_host_obs $srv_selftest_objs"
 GDBSERVER_LIBS="$srv_libs"

diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 7ea3654f63a5fbbb4419c926df1e15ea1222ae14..39c4dff4f0af017cf78dc31b525232e9088765d8 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -400,17 +400,6 @@ if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
   AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
 fi

-if test "$srv_xmlfiles" != ""; then
-  srv_xmlbuiltin="xml-builtin.o"
-  AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
-
-  tmp_xmlfiles=$srv_xmlfiles
-  srv_xmlfiles=""
-  for f in $tmp_xmlfiles; do
-    srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
-  done
-fi
-
 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_host_obs $srv_selftest_objs"
 GDBSERVER_LIBS="$srv_libs"

@@ -489,8 +478,6 @@ fi

 AC_SUBST(GDBSERVER_DEPFILES)
 AC_SUBST(GDBSERVER_LIBS)
-AC_SUBST(srv_xmlbuiltin)
-AC_SUBST(srv_xmlfiles)
 AC_SUBST(IPA_DEPFILES)
 AC_SUBST(extra_libraries)

diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index 087fd31426bc738fdae91dde4bd4d575d8b26224..00f27e4ee4c9b68972d17b64143a1ebe5a0bdcc9 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -8,8 +8,6 @@
 #			for this target.
 #   srv_hostio_err	The object implementing the hostio_last_error
 #			target method.
-#   srv_xmlfiles	All XML files which should be available for
-#			gdbserver in this configuration.
 #   ipa_obj		Any other target-specific modules appropriate
 #			for this target's in-process agent.
 #
@@ -34,14 +32,6 @@ fi

 ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o"

-srv_i386_32bit_xmlfiles="i386/32bit-core.xml i386/32bit-sse.xml i386/32bit-avx.xml i386/32bit-avx512.xml i386/32bit-mpx.xml i386/32bit-pkeys.xml"
-srv_i386_64bit_xmlfiles="i386/64bit-core.xml i386/64bit-segments.xml i386/64bit-sse.xml i386/64bit-avx.xml i386/64bit-avx512.xml i386/x32-core.xml i386/64bit-mpx.xml i386/64bit-pkeys.xml"
-srv_i386_xmlfiles="i386/i386.xml $srv_i386_32bit_xmlfiles"
-srv_amd64_xmlfiles="i386/amd64.xml $srv_i386_64bit_xmlfiles"
-srv_i386_linux_xmlfiles="i386/32bit-linux.xml $srv_i386_32bit_xmlfiles"
-srv_amd64_linux_xmlfiles="i386/64bit-linux.xml $srv_i386_64bit_xmlfiles"
-
-
 # Linux object files.  This is so we don't have to repeat
 # these files over and over again.
 srv_linux_obj="linux-low.o linux-osdata.o linux-procfs.o linux-ptrace.o linux-waitpid.o linux-personality.o linux-namespaces.o fork-child.o fork-inferior.o"
@@ -63,11 +53,6 @@ case "${target}" in
 			srv_tgtobj="$srv_tgtobj arch/aarch64.o"
 			srv_tgtobj="$srv_tgtobj linux-aarch64-tdesc.o"
 			srv_tgtobj="${srv_tgtobj} $srv_linux_obj"
-			srv_xmlfiles="aarch64.xml"
-			srv_xmlfiles="${srv_xmlfiles} aarch64-core.xml"
-			srv_xmlfiles="${srv_xmlfiles} aarch64-fpu.xml"
-			srv_xmlfiles="${srv_xmlfiles} arm/arm-core.xml arm/arm-vfpv3.xml"
-			srv_xmlfiles="${srv_xmlfiles} arm/arm-with-neon.xml"
 			srv_linux_regsets=yes
 			srv_linux_thread_db=yes
 			ipa_obj="linux-aarch64-ipa.o"
@@ -83,14 +68,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
@@ -121,13 +98,10 @@ case "${target}" in
   i[34567]86-*-cygwin*)	srv_regobj=""
 			srv_tgtobj="x86-low.o x86-dregs.o win32-low.o win32-i386-low.o"
 			srv_tgtobj="${srv_tgtobj} arch/i386.o"
-			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;
   i[34567]86-*-linux*)	srv_regobj="$srv_i386_linux_regobj"
-			srv_xmlfiles="$srv_i386_linux_xmlfiles"
 			if test "$gdb_cv_i386_is_x86_64" = yes ; then
 			    srv_regobj="$srv_regobj $srv_amd64_linux_regobj"
-			    srv_xmlfiles="${srv_xmlfiles} $srv_amd64_linux_xmlfiles"
 			    srv_tgtobj="amd64-linux-siginfo.o"
 			fi
 			srv_tgtobj="${srv_tgtobj} arch/i386.o"
@@ -145,9 +119,6 @@ case "${target}" in
   i[34567]86-*-lynxos*)	srv_regobj=""
 			srv_tgtobj="lynx-low.o lynx-i386-low.o fork-child.o fork-inferior.o"
 			srv_tgtobj="${srv_tgtobj} arch/i386.o"
-			srv_xmlfiles="i386/i386.xml"
-			srv_xmlfiles="${srv_xmlfiles} i386/32bit-core.xml"
-			srv_xmlfiles="${srv_xmlfiles} i386/32bit-sse.xml"
 			srv_lynxos=yes
 			;;
   i[34567]86-*-mingw32ce*)
@@ -155,7 +126,6 @@ case "${target}" in
 			srv_tgtobj="x86-low.o x86-dregs.o win32-low.o win32-i386-low.o"
 			srv_tgtobj="${srv_tgtobj} arch/i386.o"
 			srv_tgtobj="${srv_tgtobj} wincecompat.o"
-			srv_xmlfiles="$srv_i386_xmlfiles"
 			# hostio_last_error implementation is in win32-low.c
 			srv_hostio_err_objs=""
 			srv_mingw=yes
@@ -164,12 +134,10 @@ case "${target}" in
   i[34567]86-*-mingw*)	srv_regobj=""
 			srv_tgtobj="x86-low.o x86-dregs.o win32-low.o win32-i386-low.o"
 			srv_tgtobj="${srv_tgtobj} arch/i386.o"
-			srv_xmlfiles="$srv_i386_xmlfiles"
 			srv_mingw=yes
 			;;
   i[34567]86-*-nto*)	srv_regobj=""
 			srv_tgtobj="nto-low.o nto-x86-low.o arch/i386.o"
-			srv_xmlfiles="$srv_i386_xmlfiles"
 			srv_qnx="yes"
 			;;
   ia64-*-linux*)	srv_regobj=reg-ia64.o
@@ -207,26 +175,12 @@ case "${target}" in
 			srv_regobj="${srv_regobj} mips64-dsp-linux.o"
 			srv_tgtobj="$srv_linux_obj linux-mips-low.o"
 			srv_tgtobj="${srv_tgtobj} mips-linux-watch.o"
-			srv_xmlfiles="mips-linux.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips-dsp-linux.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips-cpu.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips-cp0.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips-fpu.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips-dsp.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips64-linux.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips64-dsp-linux.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips64-cpu.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips64-cp0.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips64-fpu.xml"
-			srv_xmlfiles="${srv_xmlfiles} mips64-dsp.xml"
 			srv_linux_regsets=yes
 			srv_linux_usrregs=yes
 			srv_linux_thread_db=yes
 			;;
   nios2*-*-linux*)	srv_regobj="nios2-linux.o"
 			srv_tgtobj="$srv_linux_obj linux-nios2-low.o"
-			srv_xmlfiles="nios2-linux.xml"
-			srv_xmlfiles="${srv_xmlfiles} nios2-cpu.xml"
 			srv_linux_regsets=yes
 			srv_linux_usrregs=yes
 			srv_linux_thread_db=yes
@@ -247,30 +201,6 @@ case "${target}" in
 			srv_regobj="${srv_regobj} powerpc-isa205-altivec64l.o"
 			srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o"
 			srv_tgtobj="$srv_linux_obj linux-ppc-low.o ppc-linux.o"
-			srv_xmlfiles="rs6000/powerpc-32l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-altivec32l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-cell32l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-vsx32l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-32l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-altivec32l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx32l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-altivec.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-vsx.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-core.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-linux.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-fpu.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-fpu-isa205.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-e500l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-spe.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-64l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-altivec64l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-cell64l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-vsx64l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-64l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-altivec64l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx64l.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power64-core.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power64-linux.xml"
 			srv_linux_usrregs=yes
 			srv_linux_regsets=yes
 			srv_linux_thread_db=yes
@@ -278,9 +208,6 @@ case "${target}" in
 			;;
   powerpc-*-lynxos*)	srv_regobj="powerpc-32.o"
 			srv_tgtobj="lynx-low.o lynx-ppc-low.o"
-			srv_xmlfiles="rs6000/powerpc-32.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-core.xml"
-			srv_xmlfiles="${srv_xmlfiles} rs6000/power-fpu.xml"
 			srv_lynxos=yes
 			;;
   s390*-*-linux*)	srv_regobj="s390-linux32.o"
@@ -301,32 +228,6 @@ case "${target}" in
 			srv_regobj="${srv_regobj} s390x-tevx-linux64.o"
 			srv_regobj="${srv_regobj} s390x-gs-linux64.o"
 			srv_tgtobj="$srv_linux_obj linux-s390-low.o"
-			srv_xmlfiles="s390-linux32.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-linux32v1.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-linux32v2.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-linux64v1.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-linux64v2.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-te-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-vx-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-tevx-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-gs-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390x-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390x-linux64v1.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390x-linux64v2.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390x-te-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390x-vx-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390x-tevx-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390x-gs-linux64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-core32.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-core64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390x-core64.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-acr.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-fpr.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-tdb.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-vx.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-gs.xml"
-			srv_xmlfiles="${srv_xmlfiles} s390-gsbc.xml"
 			srv_linux_usrregs=yes
 			srv_linux_regsets=yes
 			srv_linux_thread_db=yes
@@ -370,9 +271,6 @@ case "${target}" in
                         else
 			  srv_regobj=""
                         fi
-			srv_xmlfiles="${srv_xmlfiles} tic6x-core.xml"
-			srv_xmlfiles="${srv_xmlfiles} tic6x-gp.xml"
-			srv_xmlfiles="${srv_xmlfiles} tic6x-c6xp.xml"
 			srv_tgtobj="$srv_linux_obj linux-tic6x-low.o"
 			srv_tgtobj="${srv_tgtobj} arch/tic6x.o"
 			srv_linux_regsets=yes
@@ -386,7 +284,6 @@ case "${target}" in
 			srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o"
 			srv_tgtobj="${srv_tgtobj} x86-linux-dregs.o"
 			srv_tgtobj="${srv_tgtobj} amd64-linux-siginfo.o"
-			srv_xmlfiles="$srv_i386_linux_xmlfiles $srv_amd64_linux_xmlfiles"
 			srv_linux_usrregs=yes # This is for i386 progs.
 			srv_linux_regsets=yes
 			srv_linux_thread_db=yes
@@ -397,13 +294,11 @@ case "${target}" in
   x86_64-*-mingw*)	srv_regobj=""
 			srv_tgtobj="x86-low.o x86-dregs.o i387-fp.o win32-low.o win32-i386-low.o"
 			srv_tgtobj="${srv_tgtobj} arch/amd64.o"
-			srv_xmlfiles="$srv_i386_xmlfiles $srv_amd64_xmlfiles"
 			srv_mingw=yes
 			;;
   x86_64-*-cygwin*)	srv_regobj=""
 			srv_tgtobj="x86-low.o x86-dregs.o i387-fp.o win32-low.o win32-i386-low.o"
 			srv_tgtobj="${srv_tgtobj} arch/amd64.o"
-			srv_xmlfiles="$srv_i386_xmlfiles"
 			;;

   xtensa*-*-linux*)	srv_regobj=reg-xtensa.o

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

* [PATCH 4/6]: Create xml from target descriptions
  2018-01-16  9:52 [PATCH 0/6] : Remove XML files from gdbserver Alan Hayward
                   ` (4 preceding siblings ...)
  2018-01-16  9:55 ` [PATCH 5/6] : Remove xml file references from target descriptions Alan Hayward
@ 2018-01-16  9:55 ` Alan Hayward
  5 siblings, 0 replies; 17+ messages in thread
From: Alan Hayward @ 2018-01-16  9:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd

This patch adds a print_xml_feature visitor class which turns a C
target description into xml.

Tests are added to maintenance_check_xml_descriptions which takes
each pair of tested descriptions, turns them both into xml, then back
again, and confirms the descriptions still match.

I have added a new function void debug(const struct target_desc *)
which simply prints a given target description out as xml.
This follows the style of GCC which has debug functions for all major
structure types (eg rtx). When debugging GCC I can usually take any
tree or expression and just "call debug(x)" to get a nice dump of it,
or sprinkle debug(x) calls through my failing code. I find this really
useful, however I'm happy to remove (or rename) the function if people
don't like it.

Alan.

2018-01-16  Alan Hayward  <alan.hayward@arm.com>

gdb/
	* arch/tdesc.c (print_xml_feature::visit_post): Add xml parsing.
	(print_xml_feature::visit_pre): Likewise.
	(print_xml_feature::visit_post): Likewise.
	(print_xml_feature::visit): Likewise.
	(print_xml_feature::visit): Likewise.
	(print_xml_feature::visit): Likewise.
	(print_xml_feature::visit): Likewise.
	* arch/tdesc.h (print_xml_feature): Add new class.
	* regformats/regdat.sh: obtain xml.
	* target-descriptions.c (struct target_desc): Add xmltarget.
	(print_xml_feature::visit_pre): Add xml vistor.
	(tdesc_get_features_xml): Add function to get xml.
	(debug): Add target_desc debug function.
	(maintenance_check_xml_descriptions): Test xml generation.
	* target-descriptions.h (debug): Add declaration.
	* xml-tdesc.c (target_read_description_xml_string): Add function.
	* xml-tdesc.h (target_read_description_xml_string): Add declaration.

gdbserver/
	* tdesc.c (void target_desc::accept): Fill in function.
	(tdesc_get_features_xml): Remove old xml creation.
	(print_xml_feature::visit_pre): Add xml vistor.

diff --git a/gdb/arch/tdesc.h b/gdb/arch/tdesc.h
index 633853447d98c952cfed462939b486afd2738742..edd7de104973676fe69873ffe696e99eb77fbc84 100644
--- a/gdb/arch/tdesc.h
+++ b/gdb/arch/tdesc.h
@@ -359,4 +359,33 @@ void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
 		       int regnum, int save_restore, const char *group,
 		       int bitsize, const char *type);

+/* Return the tdesc in string XML format.  */
+
+const char *tdesc_get_features_xml (target_desc *tdesc);
+
+/* Print target description as xml.  */
+
+class print_xml_feature : public tdesc_element_visitor
+{
+public:
+  print_xml_feature (std::string *buffer_)
+    : m_buffer (buffer_)
+  {}
+
+  ~print_xml_feature ()
+  {}
+
+  void visit_pre (const target_desc *e) override;
+  void visit_post (const target_desc *e) override;
+  void visit_pre (const tdesc_feature *e) override;
+  void visit_post (const tdesc_feature *e) override;
+  void visit (const tdesc_type_builtin *type) override;
+  void visit (const tdesc_type_vector *type) override;
+  void visit (const tdesc_type_with_fields *type) override;
+  void visit (const tdesc_reg *reg) override;
+
+private:
+  std::string *m_buffer;
+};
+
 #endif /* ARCH_TDESC_H */
diff --git a/gdb/arch/tdesc.c b/gdb/arch/tdesc.c
index e6005a75a7264bba4cd177e4ec1efd90809e25c8..e43f37095d636cf680ce2b55c653deedd2c59eae 100644
--- a/gdb/arch/tdesc.c
+++ b/gdb/arch/tdesc.c
@@ -323,3 +323,138 @@ tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
 			     tdesc_predefined_type (TDESC_TYPE_INT32),
 			     value, -1);
 }
+
+
+void print_xml_feature::visit_post (const target_desc *e)
+{
+  *m_buffer += "</target>\n";
+}
+
+void print_xml_feature::visit_pre (const tdesc_feature *e)
+{
+  *m_buffer += "<feature name=\"";
+  *m_buffer += e->name;
+  *m_buffer += "\">\n";
+}
+
+void print_xml_feature::visit_post (const tdesc_feature *e)
+{
+  *m_buffer += "</feature>\n";
+}
+
+void print_xml_feature::visit (const tdesc_type_builtin *type)
+{
+  error (_("xml output is not supported type \"%s\"."), type->name.c_str ());
+}
+
+void print_xml_feature::visit (const tdesc_type_vector *type)
+{
+  *m_buffer += "<vector id=\"";
+  *m_buffer += type->name;
+  *m_buffer += "\" type=\"";
+  *m_buffer += type->element_type->name;
+  *m_buffer += "\" count=\"";
+  *m_buffer += std::to_string (type->count);
+  *m_buffer += "\"/>\n";
+}
+
+void print_xml_feature::visit (const tdesc_type_with_fields *type)
+{
+  struct tdesc_type_field *f;
+  const static char *types[] = { "struct", "union", "flags", "enum" };
+
+  gdb_assert (type->kind >= TDESC_TYPE_STRUCT && type->kind <= TDESC_TYPE_ENUM);
+  *m_buffer += "<";
+  *m_buffer += types[type->kind - TDESC_TYPE_STRUCT];
+
+  switch (type->kind)
+    {
+    case TDESC_TYPE_STRUCT:
+    case TDESC_TYPE_FLAGS:
+      *m_buffer += " id=\"";
+      *m_buffer += type->name;
+      if (type->size > 0)
+	{
+	  *m_buffer += "\" size=\"";
+	  *m_buffer += std::to_string (type->size);
+	}
+	*m_buffer += "\">\n";
+
+      for (const tdesc_type_field &f : type->fields)
+	{
+	  *m_buffer += "  <field name=\"";
+	  *m_buffer += f.name;
+	  if (f.start == -1)
+	  {
+	    *m_buffer += "\" type=\"";
+	    *m_buffer += f.type->name;
+	  }
+	  else
+	  {
+	    *m_buffer += "\" start=\"";
+	    *m_buffer += std::to_string (f.start);
+	    *m_buffer += "\" end=\"";
+	    *m_buffer += std::to_string (f.end);
+	  }
+
+	  *m_buffer += "\"/>\n";
+	}
+    break;
+
+    case TDESC_TYPE_ENUM:
+      *m_buffer += " id=\"";
+      *m_buffer += type->name;
+      *m_buffer += "\">\n";
+
+      for (const tdesc_type_field &f : type->fields)
+	{
+	  *m_buffer += "  <field name=\"";
+	  *m_buffer += f.name;
+	  *m_buffer += "\" start=\"";
+	  *m_buffer += std::to_string (f.start);
+	  *m_buffer += "\"/>\n";
+	}
+      break;
+
+    case TDESC_TYPE_UNION:
+      *m_buffer += " id=\"";
+      *m_buffer += type->name;
+      *m_buffer += "\">\n";
+
+      for (const tdesc_type_field &f : type->fields)
+	{
+	  *m_buffer += "  <field name=\"";
+	  *m_buffer += f.name;
+	  *m_buffer += "\" type=\"";
+	  *m_buffer += f.type->name;
+	  *m_buffer += "\"/>\n";
+	}
+      break;
+
+    default:
+      error (_("xml output is not supported type \"%s\"."),
+	     type->name.c_str ());
+    }
+
+  *m_buffer += "</";
+  *m_buffer += types[type->kind - TDESC_TYPE_STRUCT];
+  *m_buffer += ">\n";
+}
+
+void print_xml_feature::visit (const tdesc_reg *reg)
+{
+  *m_buffer += "<reg name=\"";
+  *m_buffer += reg->name;
+  *m_buffer += "\" bitsize=\"";
+  *m_buffer += std::to_string (reg->bitsize);
+  *m_buffer += "\" type=\"";
+  *m_buffer += reg->type;
+  *m_buffer += "\" regnum=\"";
+  *m_buffer += std::to_string (reg->target_regnum);
+  if (reg->group.length () > 0)
+    {
+      *m_buffer += "\" group=\"";
+      *m_buffer += reg->group;
+    }
+  *m_buffer += "\"/>\n";
+}
diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c
index a96b3f07e7aff81f32a160d6498c8012d18bd0c7..08b896ba790a0bbf7a47f35952555e278830800c 100644
--- a/gdb/gdbserver/tdesc.c
+++ b/gdb/gdbserver/tdesc.c
@@ -31,7 +31,16 @@ target_desc::~target_desc ()
 }

 void target_desc::accept (tdesc_element_visitor &v) const
-{}
+{
+#ifndef IN_PROCESS_AGENT
+  v.visit_pre (this);
+
+  for (const tdesc_feature_up &feature : features)
+    feature->accept (v);
+
+  v.visit_post (this);
+#endif
+}

 bool target_desc::operator== (const target_desc &other) const
 {
@@ -158,30 +167,9 @@ tdesc_get_features_xml (target_desc *tdesc)

   if (tdesc->xmltarget == NULL)
     {
-      std::string buffer ("@<?xml version=\"1.0\"?>");
-
-      buffer += "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">";
-      buffer += "<target>";
-      buffer += "<architecture>";
-      buffer += tdesc->arch;
-      buffer += "</architecture>";
-
-      if (tdesc->osabi != nullptr)
-	{
-	  buffer += "<osabi>";
-	  buffer += tdesc->osabi;
-	  buffer += "</osabi>";
-	}
-
-      for (const tdesc_feature_up &feature : tdesc->features)
-	{
-	  buffer += "<xi:include href=\"";
-	  buffer += feature->name;
-	  buffer += "\"/>";
-	}
-
-      buffer += "</target>";
-
+      std::string buffer ("");
+      print_xml_feature v (&buffer);
+      tdesc->accept (v);
       tdesc->xmltarget = xstrdup (buffer.c_str ());
     }

@@ -213,4 +201,24 @@ type *tdesc_type_vector::make_gdb_type (struct gdbarch *gdbarch) const
 type *tdesc_type_with_fields::make_gdb_type (struct gdbarch *gdbarch) const
 {
   error (_("Cannot create gdbtypes."));
-}
\ No newline at end of file
+}
+
+void print_xml_feature::visit_pre (const target_desc *e)
+{
+#ifndef IN_PROCESS_AGENT
+  *m_buffer += "@<?xml version=\"1.0\"?>\n";
+  *m_buffer += "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n";
+  *m_buffer += "<target>\n";
+  *m_buffer += "<architecture>";
+  *m_buffer += e->arch;
+  *m_buffer += "</architecture>\n";
+
+  if (e->osabi != nullptr)
+    {
+      *m_buffer += "<osabi>";
+      *m_buffer += e->osabi;
+      *m_buffer += "</osabi>\n";
+    }
+#endif
+  }
+
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 8341e11ba76031cc260d60fdc2071bc8a2188f8e..31312fae43dcd369d43e951ffa9e63af4bef450d 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -189,7 +189,7 @@ fi

 cat <<EOF
   result->expedite_regs = expedite_regs_${name};
-  result->xmltarget = xmltarget_${name};
+  tdesc_get_features_xml (result);
 #endif

   init_target_desc (result);
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 759fd34a0fe31f84a8531c799e5a3556e768c604..2a177d5b003c1461d837d22cc4fd5d52c0482ccc 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -218,6 +218,8 @@ void tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_n
 void tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
 			   const char *name);

+void debug (const struct target_desc *);
+
 #if GDB_SELF_TEST
 namespace selftests {

diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index cef65a8fe61e22362e0bc4e6dbd7e3c0a0f4d1b4..6787848b287414cd218ad62e274707d5b4b5a368 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -86,6 +86,8 @@ struct target_desc : tdesc_element
   /* The features associated with this target.  */
   std::vector<tdesc_feature_up> features;

+  char *xmltarget = nullptr;
+
   void accept (tdesc_element_visitor &v) const override
   {
     v.visit_pre (this);
@@ -1622,6 +1624,44 @@ private:
   int m_next_regnum = 0;
 };

+void print_xml_feature::visit_pre (const target_desc *e)
+{
+  *m_buffer += "<?xml version=\"1.0\"?>\n";
+  *m_buffer += "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n";
+  *m_buffer += "<target>\n";
+  *m_buffer += "<architecture>";
+  *m_buffer += tdesc_architecture (e)->printable_name;
+  *m_buffer += "</architecture>\n";
+
+  if (e->osabi != GDB_OSABI_UNKNOWN)
+    {
+      *m_buffer += "<osabi>";
+      *m_buffer += gdbarch_osabi_name (tdesc_osabi (e));
+      *m_buffer += "</osabi>\n";
+    }
+}
+
+/* Return a string which is of XML format, including XML target
+   description to be sent to GDB.  */
+
+const char *
+tdesc_get_features_xml (target_desc *tdesc)
+{
+  if (tdesc->xmltarget == nullptr)
+    {
+      std::string buffer ("");
+      print_xml_feature v (&buffer);
+      tdesc->accept (v);
+      tdesc->xmltarget = xstrdup (buffer.c_str ());
+    }
+  return tdesc->xmltarget;
+}
+
+void debug (const struct target_desc *tdesc)
+{
+  printf_filtered (_("%s\n"), tdesc_get_features_xml ((target_desc*) tdesc));
+}
+
 static void
 maint_print_c_tdesc_cmd (const char *args, int from_tty)
 {
@@ -1715,7 +1755,34 @@ maintenance_check_xml_descriptions (const char *dir, int from_tty)
 	= file_read_description_xml (tdesc_xml.data ());

       if (tdesc == NULL || *tdesc != *e.second)
-	failed++;
+	{
+	  printf_filtered ( _("Descriptions for %s do not match\n"), e.first);
+	  failed++;
+	  continue;
+	}
+
+      /* Convert both descriptions to xml, and then back again.  Confirm all
+	 descriptions are identical.  */
+
+      const char *xml = tdesc_get_features_xml ((target_desc *) tdesc);
+      const char *xml2 = tdesc_get_features_xml ((target_desc *) e.second);
+      const target_desc *t_trans = target_read_description_xml_string (xml);
+      const target_desc *t_trans2 = target_read_description_xml_string (xml2);
+
+      if (t_trans == NULL || t_trans2 == NULL)
+	{
+	  printf_filtered (
+	    _("Could not convert descriptions for %s back to xml (%p %p)\n"),
+	    e.first, t_trans, t_trans2);
+	  failed++;
+	}
+      else if (*tdesc != *t_trans || *tdesc != *t_trans2)
+	{
+	  printf_filtered
+	    (_("Translated descriptions for %s do not match (%d %d)\n"),
+	    e.first, *tdesc == *t_trans, *tdesc == *t_trans2);
+	  failed++;
+	}
     }
   printf_filtered (_("Tested %lu XML files, %d failed\n"),
 		   (long) selftests::xml_tdesc.size (), failed);
diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h
index 8f0679707ad0f1e04d803f955f7fb98b4cc0c8c8..fee60e86dd10e1543b935c3cebce505d4dc828e2 100644
--- a/gdb/xml-tdesc.h
+++ b/gdb/xml-tdesc.h
@@ -44,5 +44,10 @@ const struct target_desc *target_read_description_xml (struct target_ops *);
    otherwise.  */
 gdb::optional<std::string> target_fetch_description_xml (target_ops *ops);

+/* Take an xml string, parse it, and return the parsed description.  Does not
+   handle a string containing includes.  */
+
+const struct target_desc *target_read_description_xml_string (const char *);
+
 #endif /* XML_TDESC_H */

diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index 9190d5f3c64ffdc6d7987d651527f597d695c5a6..f793f07c96847a3d61188fff1c5d63952cc37565 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -752,3 +752,12 @@ target_fetch_description_xml (struct target_ops *ops)
   return output;
 #endif
 }
+
+/* Take an xml string, parse it, and return the parsed description.  Does not
+   handle a string containing includes.  */
+
+const struct target_desc *
+target_read_description_xml_string (const char *xml_str)
+{
+  return tdesc_parse_xml (xml_str, nullptr, nullptr);
+}


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

* [PATCH 5/6] : Remove xml file references from target descriptions.
  2018-01-16  9:52 [PATCH 0/6] : Remove XML files from gdbserver Alan Hayward
                   ` (3 preceding siblings ...)
  2018-01-16  9:55 ` [PATCH 6/6]: Remove xml files from gdbserver Alan Hayward
@ 2018-01-16  9:55 ` Alan Hayward
  2018-01-16  9:55 ` [PATCH 4/6]: Create xml " Alan Hayward
  5 siblings, 0 replies; 17+ messages in thread
From: Alan Hayward @ 2018-01-16  9:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd

With the previous patch we no longer need to know the name of the
xml file. This patch removes the references and regenerates the
C files.

Alan.


2018-01-16 Alan Hayward  <alan.hayward@arm.com>

gdb/
	* arch/tdesc.h (tdesc_create_feature): Remove xml filename parameter.
	* features/aarch64-core.c (create_feature_aarch64_core): Regenerate.
	* features/aarch64-fpu.c (create_feature_aarch64_fpu): Likewise.
	* features/i386/32bit-avx.c (create_feature_i386_32bit_avx): Likewise.
	* features/i386/32bit-avx512.c (create_feature_i386_32bit_avx512):
	Likewise.
	* features/i386/32bit-core.c (create_feature_i386_32bit_core):
	Likewise.
	* features/i386/32bit-linux.c (create_feature_i386_32bit_linux):
	Likewise.
	* features/i386/32bit-mpx.c (create_feature_i386_32bit_mpx): Likewise.
	* features/i386/32bit-pkeys.c (create_feature_i386_32bit_pkeys):
	Likewise.
	* features/i386/32bit-sse.c (create_feature_i386_32bit_sse): Likewise.
	* features/i386/64bit-avx.c (create_feature_i386_64bit_avx): Likewise.
	* features/i386/64bit-avx512.c (create_feature_i386_64bit_avx512):
	Likewise.
	* features/i386/64bit-core.c (create_feature_i386_64bit_core):
	Likewise.
	* features/i386/64bit-linux.c (create_feature_i386_64bit_linux):
	Likewise.
	* features/i386/64bit-mpx.c (create_feature_i386_64bit_mpx): Likewise.
	* features/i386/64bit-pkeys.c (create_feature_i386_64bit_pkeys):
	Likewise.
	* features/i386/64bit-segments.c (create_feature_i386_64bit_segments):
	Likewise.
	* features/i386/64bit-sse.c (create_feature_i386_64bit_sse): Likewise.
	* features/i386/x32-core.c (create_feature_i386_x32_core): Likewise.
	* features/tic6x-c6xp.c (create_feature_tic6x_c6xp): Likewise.
	* features/tic6x-core.c (create_feature_tic6x_core): Likewise.
	* features/tic6x-gp.c (create_feature_tic6x_gp): Likewise.
	* target-descriptions.c: In generated code, don't pass xml filename.

gdbserver/
	* gdbserver/tdesc.c: Remove xml parameter.


diff --git a/gdb/arch/tdesc.h b/gdb/arch/tdesc.h
index edd7de104973676fe69873ffe696e99eb77fbc84..b1b25d9f7f3eafb57b78795f6bee066410cbcc21 100644
--- a/gdb/arch/tdesc.h
+++ b/gdb/arch/tdesc.h
@@ -310,9 +310,7 @@ struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature,

 /* Return the created feature named NAME in target description TDESC.  */
 struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
-					    const char *name,
-					    const char *xml = nullptr);
-
+					    const char *name);

 /* Return the created vector tdesc_type named NAME in FEATURE.  */
 struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature,
diff --git a/gdb/features/aarch64-core.c b/gdb/features/aarch64-core.c
index 3707b7e05560507328077684215218ccbad63fee..a9ec3941a19a75ef27f35dd6bbf1fea1135e88f9 100644
--- a/gdb/features/aarch64-core.c
+++ b/gdb/features/aarch64-core.c
@@ -8,7 +8,7 @@ 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");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.core");
   tdesc_type_with_fields *type_with_fields;
   type_with_fields = tdesc_create_flags (feature, "cpsr_flags", 4);
   tdesc_add_flag (type_with_fields, 0, "SP");
diff --git a/gdb/features/aarch64-fpu.c b/gdb/features/aarch64-fpu.c
index cac3981f7dd918e051826272eb69da8e7ac5269a..32ff9e46a095e327f6af13f6b68333575440a2d8 100644
--- a/gdb/features/aarch64-fpu.c
+++ b/gdb/features/aarch64-fpu.c
@@ -8,7 +8,7 @@ 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");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.fpu");
   tdesc_type *element_type;
   element_type = tdesc_named_type (feature, "ieee_double");
   tdesc_create_vector (feature, "v2d", element_type, 2);
diff --git a/gdb/features/i386/32bit-avx.c b/gdb/features/i386/32bit-avx.c
index 8a0c35655d9a9efa19ea04053b05b0e6ba0035e8..3a98936a0c7a9715cb2d83feacde0cc6f675d8ac 100644
--- a/gdb/features/i386/32bit-avx.c
+++ b/gdb/features/i386/32bit-avx.c
@@ -8,7 +8,7 @@ create_feature_i386_32bit_avx (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx", "32bit-avx.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
   tdesc_create_reg (feature, "ymm0h", regnum++, 1, NULL, 128, "uint128");
   tdesc_create_reg (feature, "ymm1h", regnum++, 1, NULL, 128, "uint128");
   tdesc_create_reg (feature, "ymm2h", regnum++, 1, NULL, 128, "uint128");
diff --git a/gdb/features/i386/32bit-avx512.c b/gdb/features/i386/32bit-avx512.c
index 39c7e9771a94d06f05ebb72cb108ef1e569cbaa7..064e541de983bcb9309f22e2ff80900d98f58923 100644
--- a/gdb/features/i386/32bit-avx512.c
+++ b/gdb/features/i386/32bit-avx512.c
@@ -8,7 +8,7 @@ create_feature_i386_32bit_avx512 (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512", "32bit-avx512.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
   tdesc_type *element_type;
   element_type = tdesc_named_type (feature, "uint128");
   tdesc_create_vector (feature, "v2ui128", element_type, 2);
diff --git a/gdb/features/i386/32bit-core.c b/gdb/features/i386/32bit-core.c
index 294e86d81eecbd488adb45e29644290ce5fd313e..215c0b5ae2b7a0f3b0e6c06953257111f295f86e 100644
--- a/gdb/features/i386/32bit-core.c
+++ b/gdb/features/i386/32bit-core.c
@@ -8,7 +8,7 @@ create_feature_i386_32bit_core (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core", "32bit-core.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core");
   tdesc_type_with_fields *type_with_fields;
   type_with_fields = tdesc_create_flags (feature, "i386_eflags", 4);
   tdesc_add_flag (type_with_fields, 0, "CF");
diff --git a/gdb/features/i386/32bit-linux.c b/gdb/features/i386/32bit-linux.c
index 136e3d71b41a6e5af7f115fb94937a659a48185a..1ba932d795af393ebfa2860b29acdd069177ca19 100644
--- a/gdb/features/i386/32bit-linux.c
+++ b/gdb/features/i386/32bit-linux.c
@@ -8,7 +8,7 @@ create_feature_i386_32bit_linux (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux", "32bit-linux.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   regnum = 41;
   tdesc_create_reg (feature, "orig_eax", regnum++, 1, NULL, 32, "int");
   return regnum;
diff --git a/gdb/features/i386/32bit-mpx.c b/gdb/features/i386/32bit-mpx.c
index 8f1be3a60f03243bd5decde1fcb4ba3a94773159..4ec42466e7a77785fd249ec55c8d13eca196c103 100644
--- a/gdb/features/i386/32bit-mpx.c
+++ b/gdb/features/i386/32bit-mpx.c
@@ -8,7 +8,7 @@ create_feature_i386_32bit_mpx (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx", "32bit-mpx.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx");
   tdesc_type_with_fields *type_with_fields;
   type_with_fields = tdesc_create_struct (feature, "br128");
   tdesc_type *field_type;
diff --git a/gdb/features/i386/32bit-pkeys.c b/gdb/features/i386/32bit-pkeys.c
index 4ad7649915f21a0f62c9162a2fc425907c692ea4..89f1a5b3e0612ac5ad17cac7d78cd626d5ea9f3d 100644
--- a/gdb/features/i386/32bit-pkeys.c
+++ b/gdb/features/i386/32bit-pkeys.c
@@ -8,7 +8,7 @@ create_feature_i386_32bit_pkeys (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pkeys", "32bit-pkeys.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pkeys");
   tdesc_create_reg (feature, "pkru", regnum++, 1, NULL, 32, "uint32");
   return regnum;
 }
diff --git a/gdb/features/i386/32bit-sse.c b/gdb/features/i386/32bit-sse.c
index cf48960353881519789986fd7f1c46b8802d9a11..4913c9aec8cb04981bdef3747dd596589eabcad4 100644
--- a/gdb/features/i386/32bit-sse.c
+++ b/gdb/features/i386/32bit-sse.c
@@ -8,7 +8,7 @@ create_feature_i386_32bit_sse (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.sse", "32bit-sse.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.sse");
   tdesc_type *element_type;
   element_type = tdesc_named_type (feature, "ieee_single");
   tdesc_create_vector (feature, "v4f", element_type, 4);
diff --git a/gdb/features/i386/64bit-avx.c b/gdb/features/i386/64bit-avx.c
index d8e391423bc2f52fe491972d20aabea4ea26f21a..146b6a57b7e1afb5ef1b21251b0613df919de05b 100644
--- a/gdb/features/i386/64bit-avx.c
+++ b/gdb/features/i386/64bit-avx.c
@@ -8,7 +8,7 @@ create_feature_i386_64bit_avx (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx", "64bit-avx.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx");
   tdesc_create_reg (feature, "ymm0h", regnum++, 1, NULL, 128, "uint128");
   tdesc_create_reg (feature, "ymm1h", regnum++, 1, NULL, 128, "uint128");
   tdesc_create_reg (feature, "ymm2h", regnum++, 1, NULL, 128, "uint128");
diff --git a/gdb/features/i386/64bit-avx512.c b/gdb/features/i386/64bit-avx512.c
index e103e43464c7337f6556fb6035d953a3881f3e98..61108c2e5816062eb8bfd1de239edd58544ef304 100644
--- a/gdb/features/i386/64bit-avx512.c
+++ b/gdb/features/i386/64bit-avx512.c
@@ -8,7 +8,7 @@ create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512", "64bit-avx512.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
   tdesc_type *element_type;
   element_type = tdesc_named_type (feature, "ieee_single");
   tdesc_create_vector (feature, "v4f", element_type, 4);
diff --git a/gdb/features/i386/64bit-core.c b/gdb/features/i386/64bit-core.c
index 9e39ee42d9a31d68efbf838c47ae43b12a797e3f..ed540e091bcea98c3fa5548f16fd8d7aa6297280 100644
--- a/gdb/features/i386/64bit-core.c
+++ b/gdb/features/i386/64bit-core.c
@@ -8,7 +8,7 @@ create_feature_i386_64bit_core (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core", "64bit-core.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core");
   tdesc_type_with_fields *type_with_fields;
   type_with_fields = tdesc_create_flags (feature, "i386_eflags", 4);
   tdesc_add_flag (type_with_fields, 0, "CF");
diff --git a/gdb/features/i386/64bit-linux.c b/gdb/features/i386/64bit-linux.c
index 570910b9cc0f6ebf88f83dd4e73e54a38cf11636..5222ff22fb8dbb6281c0dea9deadbdd490b1d4a8 100644
--- a/gdb/features/i386/64bit-linux.c
+++ b/gdb/features/i386/64bit-linux.c
@@ -8,7 +8,7 @@ create_feature_i386_64bit_linux (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux", "64bit-linux.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
   regnum = 57;
   tdesc_create_reg (feature, "orig_rax", regnum++, 1, NULL, 64, "int");
   return regnum;
diff --git a/gdb/features/i386/64bit-mpx.c b/gdb/features/i386/64bit-mpx.c
index 725e76a0dd99cc79e1ac10dd62cd4bcca3cf682d..2b88dd5db994f6a29de78adb3d872b584d295022 100644
--- a/gdb/features/i386/64bit-mpx.c
+++ b/gdb/features/i386/64bit-mpx.c
@@ -8,7 +8,7 @@ create_feature_i386_64bit_mpx (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx", "64bit-mpx.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx");
   tdesc_type_with_fields *type_with_fields;
   type_with_fields = tdesc_create_struct (feature, "br128");
   tdesc_type *field_type;
diff --git a/gdb/features/i386/64bit-pkeys.c b/gdb/features/i386/64bit-pkeys.c
index 9d974c3772d93b44d5ae92ccc0752d6be9c21f4d..5bdeecd8460e02ba96a27fe9248fa30184d25d84 100644
--- a/gdb/features/i386/64bit-pkeys.c
+++ b/gdb/features/i386/64bit-pkeys.c
@@ -8,7 +8,7 @@ create_feature_i386_64bit_pkeys (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pkeys", "64bit-pkeys.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pkeys");
   tdesc_create_reg (feature, "pkru", regnum++, 1, NULL, 32, "uint32");
   return regnum;
 }
diff --git a/gdb/features/i386/64bit-segments.c b/gdb/features/i386/64bit-segments.c
index 7a1fbf53f35eb0106c2c3c4c32b1f7f0aa276b6a..9c7b0fe1ac15b60e66807e95bec94613a39575b7 100644
--- a/gdb/features/i386/64bit-segments.c
+++ b/gdb/features/i386/64bit-segments.c
@@ -8,7 +8,7 @@ create_feature_i386_64bit_segments (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments", "64bit-segments.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments");
   tdesc_create_reg (feature, "fs_base", regnum++, 1, NULL, 64, "int");
   tdesc_create_reg (feature, "gs_base", regnum++, 1, NULL, 64, "int");
   return regnum;
diff --git a/gdb/features/i386/64bit-sse.c b/gdb/features/i386/64bit-sse.c
index 2859217f45860d52c76650fa5ad17eb9611ab8c8..edb70e9de29400642c11a384dfe2e5e41edc6356 100644
--- a/gdb/features/i386/64bit-sse.c
+++ b/gdb/features/i386/64bit-sse.c
@@ -8,7 +8,7 @@ create_feature_i386_64bit_sse (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.sse", "64bit-sse.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.sse");
   tdesc_type *element_type;
   element_type = tdesc_named_type (feature, "ieee_single");
   tdesc_create_vector (feature, "v4f", element_type, 4);
diff --git a/gdb/features/i386/x32-core.c b/gdb/features/i386/x32-core.c
index c268e11bea9e81563fe586299ccea4bde9c7497f..aad5d687f7a4774bfca6790c049f968846422338 100644
--- a/gdb/features/i386/x32-core.c
+++ b/gdb/features/i386/x32-core.c
@@ -8,7 +8,7 @@ create_feature_i386_x32_core (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core", "x32-core.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core");
   tdesc_type_with_fields *type_with_fields;
   type_with_fields = tdesc_create_flags (feature, "i386_eflags", 4);
   tdesc_add_flag (type_with_fields, 0, "CF");
diff --git a/gdb/features/tic6x-c6xp.c b/gdb/features/tic6x-c6xp.c
index 5b0f566ee4c5687c1a8de4e08ab2828ba5242505..470ba21f4ad1d83c7a9398b62dcc974b518d0866 100644
--- a/gdb/features/tic6x-c6xp.c
+++ b/gdb/features/tic6x-c6xp.c
@@ -8,7 +8,7 @@ create_feature_tic6x_c6xp (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.tic6x.c6xp", "tic6x-c6xp.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.tic6x.c6xp");
   tdesc_create_reg (feature, "TSR", regnum++, 1, NULL, 32, "uint32");
   tdesc_create_reg (feature, "ILC", regnum++, 1, NULL, 32, "uint32");
   tdesc_create_reg (feature, "RILC", regnum++, 1, NULL, 32, "uint32");
diff --git a/gdb/features/tic6x-core.c b/gdb/features/tic6x-core.c
index 823d4c1da107786b5a983afb04a2fa88b69d3684..eb4891821296dd3a09db39667bdcbf25c3e1a954 100644
--- a/gdb/features/tic6x-core.c
+++ b/gdb/features/tic6x-core.c
@@ -8,7 +8,7 @@ create_feature_tic6x_core (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.tic6x.core", "tic6x-core.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.tic6x.core");
   tdesc_create_reg (feature, "A0", regnum++, 1, NULL, 32, "uint32");
   tdesc_create_reg (feature, "A1", regnum++, 1, NULL, 32, "uint32");
   tdesc_create_reg (feature, "A2", regnum++, 1, NULL, 32, "uint32");
diff --git a/gdb/features/tic6x-gp.c b/gdb/features/tic6x-gp.c
index df0d0e37fc2c085e8bddedff2ab00cf26ddb2c73..2efb8390ade1ad2ef1af64e30306868ab3096420 100644
--- a/gdb/features/tic6x-gp.c
+++ b/gdb/features/tic6x-gp.c
@@ -8,7 +8,7 @@ create_feature_tic6x_gp (struct target_desc *result, long regnum)
 {
   struct tdesc_feature *feature;

-  feature = tdesc_create_feature (result, "org.gnu.gdb.tic6x.gp", "tic6x-gp.xml");
+  feature = tdesc_create_feature (result, "org.gnu.gdb.tic6x.gp");
   tdesc_create_reg (feature, "A16", regnum++, 1, NULL, 32, "uint32");
   tdesc_create_reg (feature, "A17", regnum++, 1, NULL, 32, "uint32");
   tdesc_create_reg (feature, "A18", regnum++, 1, NULL, 32, "uint32");
diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c
index 08b896ba790a0bbf7a47f35952555e278830800c..e81f4f22b72574001919f505ec741e7350402394 100644
--- a/gdb/gdbserver/tdesc.c
+++ b/gdb/gdbserver/tdesc.c
@@ -180,8 +180,7 @@ tdesc_get_features_xml (target_desc *tdesc)
 /* See arch/tdesc.h.  */

 struct tdesc_feature *
-tdesc_create_feature (struct target_desc *tdesc, const char *name,
-		      const char *xml)
+tdesc_create_feature (struct target_desc *tdesc, const char *name)
 {
   struct tdesc_feature *new_feature = new tdesc_feature (name);
   tdesc->features.emplace_back (new_feature);
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 6787848b287414cd218ad62e274707d5b4b5a368..17521ee8add8ce51616f689a017948c4c7dff91c 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1085,8 +1085,7 @@ tdesc_use_registers (struct gdbarch *gdbarch,
 /* See arch/tdesc.h.  */

 struct tdesc_feature *
-tdesc_create_feature (struct target_desc *tdesc, const char *name,
-		      const char *xml)
+tdesc_create_feature (struct target_desc *tdesc, const char *name)
 {
   struct tdesc_feature *new_feature = new tdesc_feature (name);

@@ -1554,8 +1553,8 @@ public:
     printf_unfiltered ("  struct tdesc_feature *feature;\n");

     printf_unfiltered
-      ("\n  feature = tdesc_create_feature (result, \"%s\", \"%s\");\n",
-       e->name.c_str (), lbasename (m_filename_after_features.c_str ()));
+      ("\n  feature = tdesc_create_feature (result, \"%s\");\n",
+       e->name.c_str ());
   }

   void visit_post (const tdesc_feature *e) override

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

* Re: [PATCH 1/6] : Commonise various target-descriptions.c functions
  2018-01-16  9:51 ` [PATCH 1/6] : Commonise various target-descriptions.c functions Alan Hayward
@ 2018-01-16 14:18   ` Alan Hayward
  2018-01-19 23:05   ` Yao Qi
  1 sibling, 0 replies; 17+ messages in thread
From: Alan Hayward @ 2018-01-16 14:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd



> On 16 Jan 2018, at 09:50, Alan Hayward <Alan.Hayward@arm.com> wrote:
> 
> This patch simply moves functionality from target-descriptions.c
> to the common files arch/tdesc.c and arch/tdesc.h.
> No functionality is changed.
> This will allow usage by gdbserver.
> The "#ifndef GDBSERVER" around the functions in arch/tdesc.h will be removed
> in the next patch.
> 
> diff --git a/gdb/Makefile.in b/gdb/Makefile.in
> index 0a4a06b242e0423218648fe77d53fc192456cd2f..386ab5c117ebf34e1ae927b5fe78fd4618012945 100644
> --- a/gdb/Makefile.in
> +++ b/gdb/Makefile.in
> @@ -669,6 +669,7 @@ ALL_TARGET_OBS = \
> 	arch/arm-get-next-pcs.o \
> 	arch/arm-linux.o \
> 	arch/i386.o \
> +	arch/tdesc.o \
> 	arm-bsd-tdep.o \
> 	arm-fbsd-tdep.o \
> 	arm-linux-tdep.o \
> 

Apologies, just spotted a slight bug. If you build with don’t build with
--enable-targets=all then you’ll get a link error with gdb.

The Makefile.in diff needs changing to the following (instead of the change above)

--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -913,6 +912,7 @@ COMMON_SFILES = \
        agent.c \
        annotate.c \
        arch-utils.c \
+       arch/tdesc.c \
        auto-load.c \
        auxv.c \
        ax-gdb.c \

With this, everything builds with and without --enable-targets=all, and all run tests
continue to pass.

Alan.

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

* Re: [PATCH 3/6] : Update dat files with arch and osabi
  2018-01-16  9:53 ` [PATCH 3/6] : Update dat files with arch and osabi Alan Hayward
@ 2018-01-19 22:01   ` Yao Qi
  2018-01-22 13:22     ` Alan Hayward
  0 siblings, 1 reply; 17+ messages in thread
From: Yao Qi @ 2018-01-19 22:01 UTC (permalink / raw)
  To: Alan Hayward; +Cc: gdb-patches, nd

On Tue, Jan 16, 2018 at 9:52 AM, Alan Hayward <Alan.Hayward@arm.com> wrote:
> This patch simply ensures the osabi and arch fields exist in the dat
> files. Otherwise, they will be missing in later patches when gdbserver
> converts target descriptions to xml.

I don't think we need to change *.dat.  *.dat are used to generate *.c files
in gdbserver build directory for the following two reasons,

 - the port isn't converted to new style flexible target descriptions yet,
 - or the generated *.c files are used for test,

The goal of this series, IMO, is to get rid of the xml features for the ports
which already use new style flexible target descriptions, like x86
and aarch64.

For the old style target description, they still use xml files for each
description, and osabi/arch is written in these xml files.

-- 
Yao (齐尧)

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

* Re: [PATCH 6/6]: Remove xml files from gdbserver
  2018-01-16  9:55 ` [PATCH 6/6]: Remove xml files from gdbserver Alan Hayward
@ 2018-01-19 22:11   ` Yao Qi
  2018-01-22 13:23     ` Alan Hayward
  0 siblings, 1 reply; 17+ messages in thread
From: Yao Qi @ 2018-01-19 22:11 UTC (permalink / raw)
  To: Alan Hayward; +Cc: gdb-patches, nd

On Tue, Jan 16, 2018 at 9:54 AM, Alan Hayward <Alan.Hayward@arm.com> wrote:
> This patch removes the xml files from being built into gdbserver,
>

I really want to do that, but we can't do it now, because, we expect GDBserver
can generate xml contents from new style target features, rather than copy these
xml features into gdbserver.  GDBserver using old style target description still
has to copy xml contents to itself.

-- 
Yao (齐尧)

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

* Re: [PATCH 1/6] : Commonise various target-descriptions.c functions
  2018-01-16  9:51 ` [PATCH 1/6] : Commonise various target-descriptions.c functions Alan Hayward
  2018-01-16 14:18   ` Alan Hayward
@ 2018-01-19 23:05   ` Yao Qi
  2018-01-22 14:06     ` Alan Hayward
  1 sibling, 1 reply; 17+ messages in thread
From: Yao Qi @ 2018-01-19 23:05 UTC (permalink / raw)
  To: Alan Hayward; +Cc: gdb-patches, nd

On Tue, Jan 16, 2018 at 9:50 AM, Alan Hayward <Alan.Hayward@arm.com> wrote:
> This patch simply moves functionality from target-descriptions.c
> to the common files arch/tdesc.c and arch/tdesc.h.
> No functionality is changed.
> This will allow usage by gdbserver.
> The "#ifndef GDBSERVER" around the functions in arch/tdesc.h will be removed
> in the next patch.
>

It is not right to move everything to arch/ and remove unused bits.  GDB now
is able to visit different tdesc_element, you want to do the same in
GDBserver, and share the code in arch/.  However, tdesc stuff in GDB and
GDBserver are quite different, so the 1st step, IMO, is to make GDBserver
more similar to GDB.  You can change each tdesc-related struct in each
patch, and refactor GDBserver bits.  Then, only move *needed* structures
to arch/, and move one structure in one patch each, if possible.

-- 
Yao (齐尧)

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

* Re: [PATCH 3/6] : Update dat files with arch and osabi
  2018-01-19 22:01   ` Yao Qi
@ 2018-01-22 13:22     ` Alan Hayward
  2018-01-22 15:28       ` Yao Qi
  0 siblings, 1 reply; 17+ messages in thread
From: Alan Hayward @ 2018-01-22 13:22 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches, nd



> On 19 Jan 2018, at 22:01, Yao Qi <qiyaoltc@gmail.com> wrote:
> 
> On Tue, Jan 16, 2018 at 9:52 AM, Alan Hayward <Alan.Hayward@arm.com> wrote:
>> This patch simply ensures the osabi and arch fields exist in the dat
>> files. Otherwise, they will be missing in later patches when gdbserver
>> converts target descriptions to xml.
> 
> I don't think we need to change *.dat.  *.dat are used to generate *.c files
> in gdbserver build directory for the following two reasons,
> 
> - the port isn't converted to new style flexible target descriptions yet,
> - or the generated *.c files are used for test,
> 
> The goal of this series, IMO, is to get rid of the xml features for the ports
> which already use new style flexible target descriptions, like x86
> and aarch64.
> 
> For the old style target description, they still use xml files for each
> description, and osabi/arch is written in these xml files.
> 

If you remove this patch, but keep all the rest of the series, then the ports
using the new style target descriptions will segfault when printing the xml
in print_xml_feature::visit_pre() because the  -generated.c files do not
contain an arch or osabi.

The segfault happens on gdbserver init because the -generated.c functions
are calling tdesc_get_features_xml().
Thinking about it, I will remove this call from -generated.
That fixes the bug.

This leaves a question:
Is it required that the generated target descriptions have the osabi and arch?
If it does not need this information, then I will delete this patch.

Alan.





 

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

* Re: [PATCH 6/6]: Remove xml files from gdbserver
  2018-01-19 22:11   ` Yao Qi
@ 2018-01-22 13:23     ` Alan Hayward
  2018-01-22 14:52       ` Yao Qi
  0 siblings, 1 reply; 17+ messages in thread
From: Alan Hayward @ 2018-01-22 13:23 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches, nd



> On 19 Jan 2018, at 22:11, Yao Qi <qiyaoltc@gmail.com> wrote:
> 
> On Tue, Jan 16, 2018 at 9:54 AM, Alan Hayward <Alan.Hayward@arm.com> wrote:
>> This patch removes the xml files from being built into gdbserver,
>> 
> 
> I really want to do that, but we can't do it now, because, we expect GDBserver
> can generate xml contents from new style target features, rather than copy these
> xml features into gdbserver.  GDBserver using old style target description still
> has to copy xml contents to itself.
> 

Ok, happy to remove this patch from the series.


Alan.

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

* Re: [PATCH 1/6] : Commonise various target-descriptions.c functions
  2018-01-19 23:05   ` Yao Qi
@ 2018-01-22 14:06     ` Alan Hayward
  2018-01-22 15:47       ` Yao Qi
  0 siblings, 1 reply; 17+ messages in thread
From: Alan Hayward @ 2018-01-22 14:06 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches, nd



> On 19 Jan 2018, at 23:05, Yao Qi <qiyaoltc@gmail.com> wrote:
> 
> On Tue, Jan 16, 2018 at 9:50 AM, Alan Hayward <Alan.Hayward@arm.com> wrote:
>> This patch simply moves functionality from target-descriptions.c
>> to the common files arch/tdesc.c and arch/tdesc.h.
>> No functionality is changed.
>> This will allow usage by gdbserver.
>> The "#ifndef GDBSERVER" around the functions in arch/tdesc.h will be removed
>> in the next patch.
>> 
> 
> It is not right to move everything to arch/ and remove unused bits.  GDB now
> is able to visit different tdesc_element, you want to do the same in
> GDBserver, and share the code in arch/.  However, tdesc stuff in GDB and
> GDBserver are quite different, so the 1st step, IMO, is to make GDBserver
> more similar to GDB.  You can change each tdesc-related struct in each
> patch, and refactor GDBserver bits.  Then, only move *needed* structures
> to arch/, and move one structure in one patch each, if possible.
> 

Did you want me to change the ordering of the patches in the series or did you
want me to reduce the amount of code that gets moved into arch/ ?

When I wrote the whole patch series, I only moved across the functions I needed
from gdb to arch/. It turns out that I needed to move a lot of functions. Without
complicating the code, I think I need everything I moved into arch/

After I had finished writing my code, I looked at the ways of splitting it up into a
series. The simplest method was to put all the moving of functions into the first
patch. I agree that this makes the first patch a little odd to review. My reasoning
was to keep changes to the moved code separate from the moving.

I can look at making a new version of 2/6 the first patch, and then follow with
smaller versions of this patch? The final change across the whole series would
be the same. 


Alan.





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

* Re: [PATCH 6/6]: Remove xml files from gdbserver
  2018-01-22 13:23     ` Alan Hayward
@ 2018-01-22 14:52       ` Yao Qi
  0 siblings, 0 replies; 17+ messages in thread
From: Yao Qi @ 2018-01-22 14:52 UTC (permalink / raw)
  To: Alan Hayward; +Cc: gdb-patches, nd

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

> Ok, happy to remove this patch from the series.

Part of this patch is still needed, as we can remove srv_xmlfiles for
the arches which can generate xml contents from target descriptions,
like x86, aarch64 and tic6x.

-- 
Yao (齐尧)

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

* Re: [PATCH 3/6] : Update dat files with arch and osabi
  2018-01-22 13:22     ` Alan Hayward
@ 2018-01-22 15:28       ` Yao Qi
  0 siblings, 0 replies; 17+ messages in thread
From: Yao Qi @ 2018-01-22 15:28 UTC (permalink / raw)
  To: Alan Hayward; +Cc: gdb-patches, nd

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

> If you remove this patch, but keep all the rest of the series, then the ports
> using the new style target descriptions will segfault when printing the xml
> in print_xml_feature::visit_pre() because the  -generated.c files do not
> contain an arch or osabi.

Can you elaborate how does that happen?  New style target description
doesn't use anything from -generated.c files.  Note that there is even no
-generated.c files in gdbserver build directory when gdb is in release mode
(bfd/development.sh:development is false).

>
> The segfault happens on gdbserver init because the -generated.c functions
> are calling tdesc_get_features_xml().

I still don't see why -generated.c functions call
tdesc_get_features_xml.  For new style target description, it already
generate osabi and arch (see tdesc_get_features_xml path
tdesc->xmltarget == NULL).  For old style target description, arch and
osabi is from xml file.  Take i386-avx-linux-generated.c for example,

static const char *xmltarget_i386_avx_linux = "i386-avx-linux.xml";

#ifndef IN_PROCESS_AGENT
  result->expedite_regs = expedite_regs_i386_avx_linux;
  result->xmltarget = xmltarget_i386_avx_linux;
#endif

osabi and arch is specified in features/i386/i386-avx-linux.xml,

  <architecture>i386</architecture>
  <osabi>GNU/Linux</osabi>

> Thinking about it, I will remove this call from -generated.
> That fixes the bug.
>
> This leaves a question:
> Is it required that the generated target descriptions have the osabi and arch?
> If it does not need this information, then I will delete this patch.

If by "the generated target descriptions", you mean *-generated.c files
in gdbserver build directory, yes, they don't have osabi and arch.  As I
said above, arch and osabi, if any, are specified in the xml files.

-- 
Yao (齐尧)

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

* Re: [PATCH 1/6] : Commonise various target-descriptions.c functions
  2018-01-22 14:06     ` Alan Hayward
@ 2018-01-22 15:47       ` Yao Qi
  0 siblings, 0 replies; 17+ messages in thread
From: Yao Qi @ 2018-01-22 15:47 UTC (permalink / raw)
  To: Alan Hayward; +Cc: gdb-patches, nd

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

> Did you want me to change the ordering of the patches in the series or did you
> want me to reduce the amount of code that gets moved into arch/ ?
>

Both.

> When I wrote the whole patch series, I only moved across the functions I needed
> from gdb to arch/. It turns out that I needed to move a lot of
> functions. Without
> complicating the code, I think I need everything I moved into arch/
>
> After I had finished writing my code, I looked at the ways of
> splitting it up into a
> series. The simplest method was to put all the moving of functions
> into the first
> patch. I agree that this makes the first patch a little odd to
> review. My reasoning
> was to keep changes to the moved code separate from the moving.
>

For some big patch series, the patches (order and contents) I posted for
review are different from the patches I wrote to get things done.  After
I get my branch working, I'll restart a new branch, to rewrite them
in a way which is more friendly for review/upstreaming, because you've
never know what changes are needed until you finish the work.  It
happens to me that I realize that I need to refactor some part after I
committed ten patches in my branch, so I have to stop, rebase my
patches, to put refactor patches first.

> I can look at making a new version of 2/6 the first patch, and then follow with
> smaller versions of this patch? The final change across the whole series would
> be the same. 

That will be very helpful.  Steps matter, take a look at page 6 of my
presentation,
https://gcc.gnu.org/wiki/cauldron2013?action=AttachFile&do=get&target=port-gdb-tic6x-qi.pdf

-- 
Yao (齐尧)

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

end of thread, other threads:[~2018-01-22 15:47 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16  9:52 [PATCH 0/6] : Remove XML files from gdbserver Alan Hayward
2018-01-16  9:51 ` [PATCH 1/6] : Commonise various target-descriptions.c functions Alan Hayward
2018-01-16 14:18   ` Alan Hayward
2018-01-19 23:05   ` Yao Qi
2018-01-22 14:06     ` Alan Hayward
2018-01-22 15:47       ` Yao Qi
2018-01-16  9:52 ` [PATCH 2/6]: gdbserver use common tdesc functions Alan Hayward
2018-01-16  9:53 ` [PATCH 3/6] : Update dat files with arch and osabi Alan Hayward
2018-01-19 22:01   ` Yao Qi
2018-01-22 13:22     ` Alan Hayward
2018-01-22 15:28       ` Yao Qi
2018-01-16  9:55 ` [PATCH 6/6]: Remove xml files from gdbserver Alan Hayward
2018-01-19 22:11   ` Yao Qi
2018-01-22 13:23     ` Alan Hayward
2018-01-22 14:52       ` Yao Qi
2018-01-16  9:55 ` [PATCH 5/6] : Remove xml file references from target descriptions Alan Hayward
2018-01-16  9:55 ` [PATCH 4/6]: Create xml " Alan Hayward

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).