Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Philipp Rudo <prudo@linux.vnet.ibm.com>
To: Alan Hayward <Alan.Hayward@arm.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	       nd <nd@arm.com>
Subject: Re: [PATCH v2 3/8] Use tdesc_feature in gdbserver tdesc
Date: Thu, 25 Jan 2018 13:12:00 -0000	[thread overview]
Message-ID: <20180125141152.2d10125b@ThinkPad> (raw)
In-Reply-To: <F034FBFB-3FD3-4A5E-8861-183BEC4018E4@arm.com>

On Wed, 24 Jan 2018 09:28:01 +0000
Alan Hayward <Alan.Hayward@arm.com> wrote:
[...]
> diff --git a/gdb/gdbserver/tdesc.h b/gdb/gdbserver/tdesc.h
> index cfc1a194def019ecf899e9184385be94de39d08c..8ae6cddc1896af99d86206d159fb952a0f666043 100644
> --- a/gdb/gdbserver/tdesc.h
> +++ b/gdb/gdbserver/tdesc.h
> @@ -24,16 +24,10 @@
>  #include "regdef.h"
>  #include <vector>
> 
> -struct tdesc_feature
> -{
> -  /* The registers associated with this feature.  */
> -  std::vector<tdesc_reg_up> registers;
> -};
> -
>  /* 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

With your change the comment above is no longer true.

Philipp

>  {
>    /* A vector of elements of register definitions that
>       describe the inferior's register set.  */
> @@ -42,6 +36,9 @@ struct target_desc : tdesc_feature
>    /* The register cache size, in bytes.  */
>    int registers_size;
> 
> +  /* XML features in this target description.  */
> +  std::vector<tdesc_feature_up> features;
> +
>  #ifndef IN_PROCESS_AGENT
>    /* An array of register names.  These are the "expedite" registers:
>       registers whose values are sent along with stop replies.  */
> @@ -56,9 +53,6 @@ struct target_desc : tdesc_feature
>       fields features, arch, and osabi in tdesc_get_features_xml.  */
>    const char *xmltarget = NULL;
> 
> -  /* XML features in this target description.  */
> -  VEC (char_ptr) *features = NULL;
> -
>    /* The value of <architecture> element in the XML, replying GDB.  */
>    const char *arch = NULL;
> 
> diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c
> index 5dec636baa6b899490e8c700eea21d363fb79fa3..bc94d83ae58b9e79d8b71d0ce21c073f11765dd4 100644
> --- a/gdb/gdbserver/tdesc.c
> +++ b/gdb/gdbserver/tdesc.c
> @@ -23,19 +23,11 @@
> 
>  target_desc::~target_desc ()
>  {
> -  int i;
> -
>    for (reg *reg : reg_defs)
>      xfree (reg);
> 
>    xfree ((char *) arch);
>    xfree ((char *) osabi);
> -
> -  char *f;
> -
> -  for (i = 0; VEC_iterate (char_ptr, features, i, f); i++)
> -    xfree (f);
> -  VEC_free (char_ptr, features);
>  }
> 
>  bool target_desc::operator== (const target_desc &other) const
> @@ -73,28 +65,29 @@ init_target_desc (struct target_desc *tdesc)
>    int offset = 0;
> 
>    /* Go through all the features and populate reg_defs.  */
> -  for (const tdesc_reg_up &treg : tdesc->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;
> -    }
> +  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;
> 
> @@ -157,7 +150,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)
> @@ -177,12 +170,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 += "\"/>";
>  	}
> 
> @@ -195,19 +186,15 @@ 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;
> +  struct tdesc_feature *new_feature = new tdesc_feature (name);
> +  tdesc->features.emplace_back (new_feature);
> +  return new_feature;
>  }
> 
>  /* See arch/tdesc.h.  */
> @@ -252,21 +239,6 @@ tdesc_create_struct (struct tdesc_feature *feature, const char *id)
> 
>  /* 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;
> -
> -  tdesc_reg *reg = new tdesc_reg (feature, name, regnum, save_restore,
> -				  group, bitsize, type);
> -
> -  tdesc->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)
> 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}`
> diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
> index 881ef78d2e3adde409e8585deb67c96e2f0594ed..6df29521eb2319919c7e20df14ca5aebc1d25321 100644
> --- a/gdb/target-descriptions.c
> +++ b/gdb/target-descriptions.c
> @@ -67,69 +67,6 @@ struct tdesc_type_field
>    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_)
> -  {}
> -
> -  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;
> -};
> -
> -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)
> @@ -408,82 +345,6 @@ struct tdesc_type_with_fields : tdesc_type
>    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.  */
> 
>  struct target_desc : tdesc_element
> @@ -1338,20 +1199,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.  */
> 


  reply	other threads:[~2018-01-25 13:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24  9:26 [PATCH v2 0/8] Remove XML files from gdbserver Alan Hayward
2018-01-24  9:26 ` [PATCH v2 1/8] Move tdesc header funcs to c file Alan Hayward
2018-01-24  9:27 ` [PATCH v2 2/8] Use tdesc_reg in gxdbserver tdesc Alan Hayward
2018-01-25 13:12   ` Philipp Rudo
2018-01-24  9:28 ` [PATCH v2 3/8] Use tdesc_feature in gdbserver tdesc Alan Hayward
2018-01-25 13:12   ` Philipp Rudo [this message]
2018-01-24  9:28 ` [PATCH v2 4/8] Move make_gdb_type functions within file Alan Hayward
2018-01-24  9:29 ` [PATCH v2 5/8] Use tdesc types in gdbserver tdesc Alan Hayward
2018-01-25 13:13   ` Philipp Rudo
2018-01-29  7:28     ` Omair Javaid
2018-01-29 11:01       ` Alan Hayward
     [not found]         ` <20180129123042.4a1674d6@ThinkPad>
2018-01-29 15:52           ` Alan Hayward
2018-01-24  9:30 ` [PATCH v2 6/8] Create xml from target descriptions Alan Hayward
2018-01-25 13:14   ` Philipp Rudo
2018-01-25 15:45     ` Yao Qi
2018-01-25 16:13       ` Alan Hayward
2018-01-25 16:56         ` Philipp Rudo
2018-01-24  9:31 ` [PATCH v2 7/8]: Remove xml file references " Alan Hayward
2018-01-24  9:32 ` [PATCH v2 8/8] Remove xml files from gdbserver Alan Hayward
2018-01-24 10:57 ` [PATCH v2 0/8] Remove XML " Omair Javaid
2018-01-24 12:29   ` Alan Hayward
     [not found]     ` <CANW4E-30Q5zRPrA0Vqe648f4psPqPMUCmSADYRjTK292kZy_Ng@mail.gmail.com>
2018-01-24 18:53       ` Alan Hayward
2018-01-25 13:11 ` Philipp Rudo
2018-01-26 22:31   ` Omair Javaid
2018-01-29 16:28     ` Yao Qi
2018-01-29 17:13       ` Alan Hayward
2018-01-31 11:28         ` Alan Hayward
2018-01-29 18:18 ` Pedro Alves
2018-01-30 12:16   ` Alan Hayward

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180125141152.2d10125b@ThinkPad \
    --to=prudo@linux.vnet.ibm.com \
    --cc=Alan.Hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox