aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/tdesc.c
diff options
context:
space:
mode:
authorAlan Hayward <alan.hayward@arm.com>2018-04-18 11:39:53 +0100
committerAlan Hayward <alan.hayward@arm.com>2018-04-18 14:00:34 +0100
commit82ec9bc7055ca76f1f7dd344f3f58bf6aecec7c8 (patch)
treee9dfea1cdae7262eb147050fe6480d8c39f27c7e /gdb/gdbserver/tdesc.c
parentea3e7d717982e3c467edc7886b1d6cc2807195af (diff)
downloadfsf-binutils-gdb-82ec9bc7055ca76f1f7dd344f3f58bf6aecec7c8.zip
fsf-binutils-gdb-82ec9bc7055ca76f1f7dd344f3f58bf6aecec7c8.tar.gz
fsf-binutils-gdb-82ec9bc7055ca76f1f7dd344f3f58bf6aecec7c8.tar.bz2
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.
Diffstat (limited to 'gdb/gdbserver/tdesc.c')
-rw-r--r--gdb/gdbserver/tdesc.c55
1 files changed, 18 insertions, 37 deletions
diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c
index afe0187..1047949 100644
--- a/gdb/gdbserver/tdesc.c
+++ b/gdb/gdbserver/tdesc.c
@@ -23,8 +23,6 @@
target_desc::~target_desc ()
{
- int i;
-
xfree ((char *) arch);
xfree ((char *) osabi);
}
@@ -55,19 +53,21 @@ 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)
- {
- int regnum = treg->target_regnum;
+ for (const tdesc_feature_up &feature : tdesc->features)
+ for (const tdesc_reg_up &treg : feature->registers)
+ {
+ int regnum = treg->target_regnum;
- /* Register number will increase (possibly with gaps) or be zero. */
- gdb_assert (regnum == 0 || regnum >= tdesc->reg_defs.size ());
+ /* Register number will increase (possibly with gaps) or be zero. */
+ gdb_assert (regnum == 0 || regnum >= tdesc->reg_defs.size ());
- if (regnum != 0)
- tdesc->reg_defs.resize (regnum, reg (offset));
+ if (regnum != 0)
+ tdesc->reg_defs.resize (regnum, reg (offset));
- tdesc->reg_defs.emplace_back (treg->name.c_str (), offset, treg->bitsize);
- offset += treg->bitsize;
- }
+ tdesc->reg_defs.emplace_back (treg->name.c_str (), offset,
+ treg->bitsize);
+ offset += treg->bitsize;
+ }
tdesc->registers_size = offset / 8;
@@ -150,11 +150,10 @@ tdesc_get_features_xml (target_desc *tdesc)
buffer += "</osabi>";
}
-
- for (const std::string &xml : tdesc->features)
+ for (const tdesc_feature_up &feature : tdesc->features)
{
buffer += "<xi:include href=\"";
- buffer += xml;
+ buffer += feature->name;
buffer += "\"/>";
}
@@ -167,19 +166,16 @@ tdesc_get_features_xml (target_desc *tdesc)
}
#endif
-struct tdesc_type
-{};
-
/* See common/tdesc.h. */
struct tdesc_feature *
tdesc_create_feature (struct target_desc *tdesc, const char *name,
const char *xml)
{
-#ifndef IN_PROCESS_AGENT
- tdesc->features.emplace_back (xml);
-#endif
- return tdesc;
+ struct tdesc_feature *new_feature = new tdesc_feature
+ (xml != nullptr ? xml : name);
+ tdesc->features.emplace_back (new_feature);
+ return new_feature;
}
/* See common/tdesc.h. */
@@ -224,21 +220,6 @@ tdesc_create_struct (struct tdesc_feature *feature, const char *id)
/* See common/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 common/tdesc.h. */
-
struct tdesc_type *
tdesc_create_vector (struct tdesc_feature *feature, const char *name,
struct tdesc_type *field_type, int count)