-/* Copyright (C) 2012-2018 Free Software Foundation, Inc.
+/* Copyright (C) 2012-2020 Free Software Foundation, Inc.
This file is part of GDB.
#endif
+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
+}
+
void
-init_target_desc (struct target_desc *tdesc)
+init_target_desc (struct target_desc *tdesc,
+ const char **expedite_regs)
{
int offset = 0;
/* Make sure PBUFSIZ is large enough to hold a full register
packet. */
gdb_assert (2 * tdesc->registers_size + 32 <= PBUFSIZ);
+
+#ifndef IN_PROCESS_AGENT
+ tdesc->expedite_regs = expedite_regs;
+#endif
}
struct target_desc *
return current_process ()->tdesc;
}
-/* See common/tdesc.h. */
+/* See gdbsupport/tdesc.h. */
+
+const char *
+tdesc_architecture_name (const struct target_desc *target_desc)
+{
+ return target_desc->arch;
+}
+
+/* See gdbsupport/tdesc.h. */
void
set_tdesc_architecture (struct target_desc *target_desc,
target_desc->arch = xstrdup (name);
}
-/* See common/tdesc.h. */
+/* See gdbsupport/tdesc.h. */
+
+const char *
+tdesc_osabi_name (const struct target_desc *target_desc)
+{
+ return target_desc->osabi;
+}
+
+/* See gdbsupport/tdesc.h. */
void
set_tdesc_osabi (struct target_desc *target_desc, const char *name)
target_desc->osabi = xstrdup (name);
}
-/* Return a string which is of XML format, including XML target
- description to be sent to GDB. */
+/* See gdbsupport/tdesc.h. */
const char *
-tdesc_get_features_xml (target_desc *tdesc)
+tdesc_get_features_xml (const target_desc *tdesc)
{
/* Either .xmltarget or .features is not NULL. */
gdb_assert (tdesc->xmltarget != NULL
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 ());
}
}
#endif
-/* See common/tdesc.h. */
+/* See gdbsupport/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
- (xml != nullptr ? xml : name);
+ struct tdesc_feature *new_feature = new tdesc_feature (name);
tdesc->features.emplace_back (new_feature);
return new_feature;
}
-/* See common/tdesc.h. */
-
-tdesc_type_with_fields *
-tdesc_create_flags (struct tdesc_feature *feature, const char *name,
- int size)
-{
- return NULL;
-}
-
-/* See common/tdesc.h. */
+/* See gdbsupport/tdesc.h. */
-void
-tdesc_add_flag (tdesc_type_with_fields *type, int start,
- const char *flag_name)
-{}
-
-/* See common/tdesc.h. */
-
-struct tdesc_type *
-tdesc_named_type (const struct tdesc_feature *feature, const char *id)
-{
- return NULL;
-}
-
-/* See common/tdesc.h. */
-
-tdesc_type_with_fields *
-tdesc_create_union (struct tdesc_feature *feature, const char *id)
+bool
+tdesc_contains_feature (const target_desc *tdesc, const std::string &feature)
{
- return NULL;
-}
-
-/* See common/tdesc.h. */
-
-tdesc_type_with_fields *
-tdesc_create_struct (struct tdesc_feature *feature, const char *id)
-{
- return NULL;
-}
-
-/* See common/tdesc.h. */
+ gdb_assert (tdesc != nullptr);
-struct tdesc_type *
-tdesc_create_vector (struct tdesc_feature *feature, const char *name,
- struct tdesc_type *field_type, int count)
-{
- return NULL;
-}
-
-void
-tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
- int start, int end)
-{}
-
-/* See common/tdesc.h. */
-
-void
-tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
- struct tdesc_type *field_type)
-{}
-
-/* See common/tdesc.h. */
+ for (const tdesc_feature_up &f : tdesc->features)
+ {
+ if (f->name == feature)
+ return true;
+ }
-void
-tdesc_set_struct_size (tdesc_type_with_fields *type, int size)
-{
+ return false;
}