{
m_type = arch_composite_type (m_gdbarch, NULL, TYPE_CODE_STRUCT);
TYPE_NAME (m_type) = xstrdup (e->name.c_str ());
- TYPE_TAG_NAME (m_type) = TYPE_NAME (m_type);
for (const tdesc_type_field &f : e->fields)
{
/* The features associated with this target. */
std::vector<tdesc_feature_up> features;
+ /* Used to cache the generated xml version of the target description. */
+ mutable char *xmltarget = nullptr;
+
void accept (tdesc_element_visitor &v) const override
{
v.visit_pre (this);
/* Next try to read the description from the current target using
target objects. */
if (current_target_desc == NULL)
- current_target_desc = target_read_description_xml (¤t_target);
+ current_target_desc = target_read_description_xml (current_top_target ());
/* If that failed try a target-specific hook. */
if (current_target_desc == NULL)
- current_target_desc = target_read_description (¤t_target);
+ current_target_desc = target_read_description (current_top_target ());
/* If a non-NULL description was returned, then update the current
architecture. */
return target_desc->arch;
}
+/* See common/tdesc.h. */
+
+const char *
+tdesc_architecture_name (const struct target_desc *target_desc)
+{
+ return target_desc->arch->printable_name;
+}
+
/* Return the OSABI associated with this target description, or
GDB_OSABI_UNKNOWN if no osabi was specified. */
return target_desc->osabi;
}
-\f
+/* See common/tdesc.h. */
+
+const char *
+tdesc_osabi_name (const struct target_desc *target_desc)
+{
+ enum gdb_osabi osabi = tdesc_osabi (target_desc);
+ if (osabi > GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
+ return gdbarch_osabi_name (osabi);
+ return nullptr;
+}
/* Return 1 if this target description includes any registers. */
static void *
tdesc_data_init (struct obstack *obstack)
{
- struct tdesc_arch_data *data;
-
- data = OBSTACK_ZALLOC (obstack, struct tdesc_arch_data);
- new (data) tdesc_arch_data ();
-
- return data;
+ return obstack_new<tdesc_arch_data> (obstack);
}
/* Similar, but for the temporary copy used during architecture
/* See common/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);
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
int m_next_regnum = 0;
};
+/* See common/tdesc.h. */
+
+const char *
+tdesc_get_features_xml (const 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;
+}
+
static void
maint_print_c_tdesc_cmd (const char *args, int from_tty)
{
}
+/* Test the convesion process of a target description to/from xml: Take a target
+ description TDESC, convert to xml, back to a description, and confirm the new
+ tdesc is identical to the original. */
+static bool
+maintenance_check_tdesc_xml_convert (const target_desc *tdesc, const char *name)
+{
+ const char *xml = tdesc_get_features_xml (tdesc);
+
+ if (xml == nullptr || *xml != '@')
+ {
+ printf_filtered (_("Could not convert description for %s to xml.\n"),
+ name);
+ return false;
+ }
+
+ const target_desc *tdesc_trans = string_read_description_xml (xml + 1);
+
+ if (tdesc_trans == nullptr)
+ {
+ printf_filtered (_("Could not convert description for %s from xml.\n"),
+ name);
+ return false;
+ }
+ else if (*tdesc != *tdesc_trans)
+ {
+ printf_filtered (_("Converted description for %s does not match.\n"),
+ name);
+ return false;
+ }
+ return true;
+}
+
+
/* Check that the target descriptions created dynamically by
architecture-specific code equal the descriptions created from XML files
found in the specified directory DIR. */
= file_read_description_xml (tdesc_xml.data ());
if (tdesc == NULL || *tdesc != *e.second)
+ {
+ printf_filtered ( _("Descriptions for %s do not match.\n"), e.first);
+ failed++;
+ }
+ else if (!maintenance_check_tdesc_xml_convert (tdesc, e.first)
+ || !maintenance_check_tdesc_xml_convert (e.second, e.first))
failed++;
}
printf_filtered (_("Tested %lu XML files, %d failed\n"),