Commonise tdesc_feature and makes use of it in gdbserver tdesc

gdb/
	* common/tdesc.c (tdesc_feature::accept): Move to here.
	(tdesc_feature::operator==): Likewise.
	(tdesc_create_reg): Likewise.
	* common/tdesc.h (tdesc_type_kind): Likewise.
	(struct tdesc_type): Likewise.
	(struct tdesc_feature): Likewise.
	* regformats/regdat.sh: Create a feature.
	* target-descriptions.c (tdesc_type_kind): Move from here.
	(tdesc_type): Likewise.
	(tdesc_type_up): Likewise.
	(tdesc_feature): Likewise.
	(tdesc_create_reg): Likewise.

gdbserver/
	* tdesc.c (~target_desc): Remove implictly deleted items.
	(init_target_desc): Iterate all features.
	(tdesc_get_features_xml): Use vector.
	(tdesc_create_feature): Create feature.
	* tdesc.h (tdesc_feature) Remove
	(target_desc): Add features.
This commit is contained in:
Alan Hayward
2018-04-18 11:39:53 +01:00
parent ea3e7d7179
commit 82ec9bc705
8 changed files with 199 additions and 197 deletions

View File

@@ -131,6 +131,99 @@ struct tdesc_reg : tdesc_element
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);
}
};
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;
/* Allocate a new target_desc. */
target_desc *allocate_target_description (void);