gdb/xml-tdesc.c - gdb

Global variables defined

Data types defined

Functions defined

Source code

  1. /* XML target description support for GDB.

  2.    Copyright (C) 2006-2015 Free Software Foundation, Inc.

  3.    Contributed by CodeSourcery.

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. #include "defs.h"
  16. #include "target.h"
  17. #include "target-descriptions.h"
  18. #include "xml-support.h"
  19. #include "xml-tdesc.h"
  20. #include "osabi.h"

  21. #include "filenames.h"

  22. #if !defined(HAVE_LIBEXPAT)

  23. /* Parse DOCUMENT into a target description.  Or don't, since we don't have
  24.    an XML parser.  */

  25. static struct target_desc *
  26. tdesc_parse_xml (const char *document, xml_fetch_another fetcher,
  27.                  void *fetcher_baton)
  28. {
  29.   static int have_warned;

  30.   if (!have_warned)
  31.     {
  32.       have_warned = 1;
  33.       warning (_("Can not parse XML target description; XML support was "
  34.                  "disabled at compile time"));
  35.     }

  36.   return NULL;
  37. }

  38. #else /* HAVE_LIBEXPAT */

  39. /* A record of every XML description we have parsed.  We never discard
  40.    old descriptions, because we never discard gdbarches.  As long as we
  41.    have a gdbarch referencing this description, we want to have a copy
  42.    of it here, so that if we parse the same XML document again we can
  43.    return the same "struct target_desc *"; if they are not singletons,
  44.    then we will create unnecessary duplicate gdbarches.  See
  45.    gdbarch_list_lookup_by_info.  */

  46. struct tdesc_xml_cache
  47. {
  48.   const char *xml_document;
  49.   struct target_desc *tdesc;
  50. };
  51. typedef struct tdesc_xml_cache tdesc_xml_cache_s;
  52. DEF_VEC_O(tdesc_xml_cache_s);

  53. static VEC(tdesc_xml_cache_s) *xml_cache;

  54. /* Callback data for target description parsing.  */

  55. struct tdesc_parsing_data
  56. {
  57.   /* The target description we are building.  */
  58.   struct target_desc *tdesc;

  59.   /* The target feature we are currently parsing, or last parsed.  */
  60.   struct tdesc_feature *current_feature;

  61.   /* The register number to use for the next register we see, if
  62.      it does not have its own.  This starts at zero.  */
  63.   int next_regnum;

  64.   /* The struct or union we are currently parsing, or last parsed.  */
  65.   struct tdesc_type *current_type;

  66.   /* The byte size of the current struct type, if specified.  Zero
  67.      if not specified.  */
  68.   int current_type_size;

  69.   /* Whether the current type is a flags type.  */
  70.   int current_type_is_flags;
  71. };

  72. /* Handle the end of an <architecture> element and its value.  */

  73. static void
  74. tdesc_end_arch (struct gdb_xml_parser *parser,
  75.                 const struct gdb_xml_element *element,
  76.                 void *user_data, const char *body_text)
  77. {
  78.   struct tdesc_parsing_data *data = user_data;
  79.   const struct bfd_arch_info *arch;

  80.   arch = bfd_scan_arch (body_text);
  81.   if (arch == NULL)
  82.     gdb_xml_error (parser, _("Target description specified unknown "
  83.                              "architecture \"%s\""), body_text);
  84.   set_tdesc_architecture (data->tdesc, arch);
  85. }

  86. /* Handle the end of an <osabi> element and its value.  */

  87. static void
  88. tdesc_end_osabi (struct gdb_xml_parser *parser,
  89.                  const struct gdb_xml_element *element,
  90.                  void *user_data, const char *body_text)
  91. {
  92.   struct tdesc_parsing_data *data = user_data;
  93.   enum gdb_osabi osabi;

  94.   osabi = osabi_from_tdesc_string (body_text);
  95.   if (osabi == GDB_OSABI_UNKNOWN)
  96.     warning (_("Target description specified unknown osabi \"%s\""),
  97.              body_text);
  98.   else
  99.     set_tdesc_osabi (data->tdesc, osabi);
  100. }

  101. /* Handle the end of a <compatible> element and its value.  */

  102. static void
  103. tdesc_end_compatible (struct gdb_xml_parser *parser,
  104.                       const struct gdb_xml_element *element,
  105.                       void *user_data, const char *body_text)
  106. {
  107.   struct tdesc_parsing_data *data = user_data;
  108.   const struct bfd_arch_info *arch;

  109.   arch = bfd_scan_arch (body_text);
  110.   tdesc_add_compatible (data->tdesc, arch);
  111. }

  112. /* Handle the start of a <target> element.  */

  113. static void
  114. tdesc_start_target (struct gdb_xml_parser *parser,
  115.                     const struct gdb_xml_element *element,
  116.                     void *user_data, VEC(gdb_xml_value_s) *attributes)
  117. {
  118.   char *version = xml_find_attribute (attributes, "version")->value;

  119.   if (strcmp (version, "1.0") != 0)
  120.     gdb_xml_error (parser,
  121.                    _("Target description has unsupported version \"%s\""),
  122.                    version);
  123. }

  124. /* Handle the start of a <feature> element.  */

  125. static void
  126. tdesc_start_feature (struct gdb_xml_parser *parser,
  127.                      const struct gdb_xml_element *element,
  128.                      void *user_data, VEC(gdb_xml_value_s) *attributes)
  129. {
  130.   struct tdesc_parsing_data *data = user_data;
  131.   char *name = xml_find_attribute (attributes, "name")->value;

  132.   data->current_feature = tdesc_create_feature (data->tdesc, name);
  133. }

  134. /* Handle the start of a <reg> element.  Fill in the optional
  135.    attributes and attach it to the containing feature.  */

  136. static void
  137. tdesc_start_reg (struct gdb_xml_parser *parser,
  138.                  const struct gdb_xml_element *element,
  139.                  void *user_data, VEC(gdb_xml_value_s) *attributes)
  140. {
  141.   struct tdesc_parsing_data *data = user_data;
  142.   struct gdb_xml_value *attrs = VEC_address (gdb_xml_value_s, attributes);
  143.   int ix = 0, length;
  144.   char *name, *group, *type;
  145.   int bitsize, regnum, save_restore;

  146.   length = VEC_length (gdb_xml_value_s, attributes);

  147.   name = attrs[ix++].value;
  148.   bitsize = * (ULONGEST *) attrs[ix++].value;

  149.   if (ix < length && strcmp (attrs[ix].name, "regnum") == 0)
  150.     regnum = * (ULONGEST *) attrs[ix++].value;
  151.   else
  152.     regnum = data->next_regnum;

  153.   if (ix < length && strcmp (attrs[ix].name, "type") == 0)
  154.     type = attrs[ix++].value;
  155.   else
  156.     type = "int";

  157.   if (ix < length && strcmp (attrs[ix].name, "group") == 0)
  158.     group = attrs[ix++].value;
  159.   else
  160.     group = NULL;

  161.   if (ix < length && strcmp (attrs[ix].name, "save-restore") == 0)
  162.     save_restore = * (ULONGEST *) attrs[ix++].value;
  163.   else
  164.     save_restore = 1;

  165.   if (strcmp (type, "int") != 0
  166.       && strcmp (type, "float") != 0
  167.       && tdesc_named_type (data->current_feature, type) == NULL)
  168.     gdb_xml_error (parser, _("Register \"%s\" has unknown type \"%s\""),
  169.                    name, type);

  170.   tdesc_create_reg (data->current_feature, name, regnum, save_restore, group,
  171.                     bitsize, type);

  172.   data->next_regnum = regnum + 1;
  173. }

  174. /* Handle the start of a <union> element.  Initialize the type and
  175.    record it with the current feature.  */

  176. static void
  177. tdesc_start_union (struct gdb_xml_parser *parser,
  178.                    const struct gdb_xml_element *element,
  179.                    void *user_data, VEC(gdb_xml_value_s) *attributes)
  180. {
  181.   struct tdesc_parsing_data *data = user_data;
  182.   char *id = xml_find_attribute (attributes, "id")->value;

  183.   data->current_type = tdesc_create_union (data->current_feature, id);
  184.   data->current_type_size = 0;
  185.   data->current_type_is_flags = 0;
  186. }

  187. /* Handle the start of a <struct> element.  Initialize the type and
  188.    record it with the current feature.  */

  189. static void
  190. tdesc_start_struct (struct gdb_xml_parser *parser,
  191.                    const struct gdb_xml_element *element,
  192.                    void *user_data, VEC(gdb_xml_value_s) *attributes)
  193. {
  194.   struct tdesc_parsing_data *data = user_data;
  195.   char *id = xml_find_attribute (attributes, "id")->value;
  196.   struct tdesc_type *type;
  197.   struct gdb_xml_value *attr;

  198.   type = tdesc_create_struct (data->current_feature, id);
  199.   data->current_type = type;
  200.   data->current_type_size = 0;
  201.   data->current_type_is_flags = 0;

  202.   attr = xml_find_attribute (attributes, "size");
  203.   if (attr != NULL)
  204.     {
  205.       int size = (int) * (ULONGEST *) attr->value;

  206.       tdesc_set_struct_size (type, size);
  207.       data->current_type_size = size;
  208.     }
  209. }

  210. static void
  211. tdesc_start_flags (struct gdb_xml_parser *parser,
  212.                    const struct gdb_xml_element *element,
  213.                    void *user_data, VEC(gdb_xml_value_s) *attributes)
  214. {
  215.   struct tdesc_parsing_data *data = user_data;
  216.   char *id = xml_find_attribute (attributes, "id")->value;
  217.   int length = (int) * (ULONGEST *)
  218.     xml_find_attribute (attributes, "size")->value;
  219.   struct tdesc_type *type;

  220.   type = tdesc_create_flags (data->current_feature, id, length);

  221.   data->current_type = type;
  222.   data->current_type_size = 0;
  223.   data->current_type_is_flags = 1;
  224. }

  225. /* Handle the start of a <field> element.  Attach the field to the
  226.    current struct or union.  */

  227. static void
  228. tdesc_start_field (struct gdb_xml_parser *parser,
  229.                    const struct gdb_xml_element *element,
  230.                    void *user_data, VEC(gdb_xml_value_s) *attributes)
  231. {
  232.   struct tdesc_parsing_data *data = user_data;
  233.   struct gdb_xml_value *attr;
  234.   struct tdesc_type *field_type;
  235.   char *field_name, *field_type_id;
  236.   int start, end;

  237.   field_name = xml_find_attribute (attributes, "name")->value;

  238.   attr = xml_find_attribute (attributes, "type");
  239.   if (attr != NULL)
  240.     field_type_id = attr->value;
  241.   else
  242.     field_type_id = NULL;

  243.   attr = xml_find_attribute (attributes, "start");
  244.   if (attr != NULL)
  245.     start = * (ULONGEST *) attr->value;
  246.   else
  247.     start = -1;

  248.   attr = xml_find_attribute (attributes, "end");
  249.   if (attr != NULL)
  250.     end = * (ULONGEST *) attr->value;
  251.   else
  252.     end = -1;

  253.   if (field_type_id != NULL)
  254.     {
  255.       if (data->current_type_is_flags)
  256.         gdb_xml_error (parser, _("Cannot add typed field \"%s\" to flags"),
  257.                        field_name);
  258.       if (data->current_type_size != 0)
  259.         gdb_xml_error (parser,
  260.                        _("Explicitly sized type can not "
  261.                          "contain non-bitfield \"%s\""),
  262.                        field_name);

  263.       field_type = tdesc_named_type (data->current_feature, field_type_id);
  264.       if (field_type == NULL)
  265.         gdb_xml_error (parser, _("Field \"%s\" references undefined "
  266.                                  "type \"%s\""),
  267.                        field_name, field_type_id);

  268.       tdesc_add_field (data->current_type, field_name, field_type);
  269.     }
  270.   else if (start != -1 && end != -1)
  271.     {
  272.       struct tdesc_type *t = data->current_type;

  273.       if (data->current_type_is_flags)
  274.         tdesc_add_flag (t, start, field_name);
  275.       else
  276.         {
  277.           if (data->current_type_size == 0)
  278.             gdb_xml_error (parser,
  279.                            _("Implicitly sized type can "
  280.                              "not contain bitfield \"%s\""),
  281.                            field_name);

  282.           if (end >= 64)
  283.             gdb_xml_error (parser,
  284.                            _("Bitfield \"%s\" goes past "
  285.                              "64 bits (unsupported)"),
  286.                            field_name);

  287.           /* Assume that the bit numbering in XML is "lsb-zero".  Most
  288.              architectures other than PowerPC use this ordering.  In
  289.              the future, we can add an XML tag to indicate "msb-zero"
  290.              numbering.  */
  291.           if (start > end)
  292.             gdb_xml_error (parser, _("Bitfield \"%s\" has start after end"),
  293.                            field_name);

  294.           if (end >= data->current_type_size * TARGET_CHAR_BIT)
  295.             gdb_xml_error (parser,
  296.                            _("Bitfield \"%s\" does not fit in struct"));

  297.           tdesc_add_bitfield (t, field_name, start, end);
  298.         }
  299.     }
  300.   else
  301.     gdb_xml_error (parser, _("Field \"%s\" has neither type nor bit position"),
  302.                    field_name);
  303. }

  304. /* Handle the start of a <vector> element.  Initialize the type and
  305.    record it with the current feature.  */

  306. static void
  307. tdesc_start_vector (struct gdb_xml_parser *parser,
  308.                     const struct gdb_xml_element *element,
  309.                     void *user_data, VEC(gdb_xml_value_s) *attributes)
  310. {
  311.   struct tdesc_parsing_data *data = user_data;
  312.   struct gdb_xml_value *attrs = VEC_address (gdb_xml_value_s, attributes);
  313.   struct tdesc_type *field_type;
  314.   char *id, *field_type_id;
  315.   int count;

  316.   id = attrs[0].value;
  317.   field_type_id = attrs[1].value;
  318.   count = * (ULONGEST *) attrs[2].value;

  319.   field_type = tdesc_named_type (data->current_feature, field_type_id);
  320.   if (field_type == NULL)
  321.     gdb_xml_error (parser, _("Vector \"%s\" references undefined type \"%s\""),
  322.                    id, field_type_id);

  323.   tdesc_create_vector (data->current_feature, id, field_type, count);
  324. }

  325. /* The elements and attributes of an XML target description.  */

  326. static const struct gdb_xml_attribute field_attributes[] = {
  327.   { "name", GDB_XML_AF_NONE, NULL, NULL },
  328.   { "type", GDB_XML_AF_OPTIONAL, NULL, NULL },
  329.   { "start", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
  330.   { "end", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
  331.   { NULL, GDB_XML_AF_NONE, NULL, NULL }
  332. };

  333. static const struct gdb_xml_element struct_union_children[] = {
  334.   { "field", field_attributes, NULL, GDB_XML_EF_REPEATABLE,
  335.     tdesc_start_field, NULL },
  336.   { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
  337. };

  338. static const struct gdb_xml_attribute reg_attributes[] = {
  339.   { "name", GDB_XML_AF_NONE, NULL, NULL },
  340.   { "bitsize", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
  341.   { "regnum", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
  342.   { "type", GDB_XML_AF_OPTIONAL, NULL, NULL },
  343.   { "group", GDB_XML_AF_OPTIONAL, NULL, NULL },
  344.   { "save-restore", GDB_XML_AF_OPTIONAL,
  345.     gdb_xml_parse_attr_enum, gdb_xml_enums_boolean },
  346.   { NULL, GDB_XML_AF_NONE, NULL, NULL }
  347. };

  348. static const struct gdb_xml_attribute struct_union_attributes[] = {
  349.   { "id", GDB_XML_AF_NONE, NULL, NULL },
  350.   { "size", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL},
  351.   { NULL, GDB_XML_AF_NONE, NULL, NULL }
  352. };

  353. static const struct gdb_xml_attribute flags_attributes[] = {
  354.   { "id", GDB_XML_AF_NONE, NULL, NULL },
  355.   { "size", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL},
  356.   { NULL, GDB_XML_AF_NONE, NULL, NULL }
  357. };

  358. static const struct gdb_xml_attribute vector_attributes[] = {
  359.   { "id", GDB_XML_AF_NONE, NULL, NULL },
  360.   { "type", GDB_XML_AF_NONE, NULL, NULL },
  361.   { "count", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
  362.   { NULL, GDB_XML_AF_NONE, NULL, NULL }
  363. };

  364. static const struct gdb_xml_attribute feature_attributes[] = {
  365.   { "name", GDB_XML_AF_NONE, NULL, NULL },
  366.   { NULL, GDB_XML_AF_NONE, NULL, NULL }
  367. };

  368. static const struct gdb_xml_element feature_children[] = {
  369.   { "reg", reg_attributes, NULL,
  370.     GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
  371.     tdesc_start_reg, NULL },
  372.   { "struct", struct_union_attributes, struct_union_children,
  373.     GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
  374.     tdesc_start_struct, NULL },
  375.   { "union", struct_union_attributes, struct_union_children,
  376.     GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
  377.     tdesc_start_union, NULL },
  378.   { "flags", flags_attributes, struct_union_children,
  379.     GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
  380.     tdesc_start_flags, NULL },
  381.   { "vector", vector_attributes, NULL,
  382.     GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
  383.     tdesc_start_vector, NULL },
  384.   { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
  385. };

  386. static const struct gdb_xml_attribute target_attributes[] = {
  387.   { "version", GDB_XML_AF_NONE, NULL, NULL },
  388.   { NULL, GDB_XML_AF_NONE, NULL, NULL }
  389. };

  390. static const struct gdb_xml_element target_children[] = {
  391.   { "architecture", NULL, NULL, GDB_XML_EF_OPTIONAL,
  392.     NULL, tdesc_end_arch },
  393.   { "osabi", NULL, NULL, GDB_XML_EF_OPTIONAL,
  394.     NULL, tdesc_end_osabi },
  395.   { "compatible", NULL, NULL, GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
  396.     NULL, tdesc_end_compatible },
  397.   { "feature", feature_attributes, feature_children,
  398.     GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
  399.     tdesc_start_feature, NULL },
  400.   { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
  401. };

  402. static const struct gdb_xml_element tdesc_elements[] = {
  403.   { "target", target_attributes, target_children, GDB_XML_EF_NONE,
  404.     tdesc_start_target, NULL },
  405.   { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
  406. };

  407. /* Parse DOCUMENT into a target description and return it.  */

  408. static struct target_desc *
  409. tdesc_parse_xml (const char *document, xml_fetch_another fetcher,
  410.                  void *fetcher_baton)
  411. {
  412.   struct cleanup *back_to, *result_cleanup;
  413.   struct tdesc_parsing_data data;
  414.   struct tdesc_xml_cache *cache;
  415.   char *expanded_text;
  416.   int ix;

  417.   /* Expand all XInclude directives.  */
  418.   expanded_text = xml_process_xincludes (_("target description"),
  419.                                          document, fetcher, fetcher_baton, 0);
  420.   if (expanded_text == NULL)
  421.     {
  422.       warning (_("Could not load XML target description; ignoring"));
  423.       return NULL;
  424.     }

  425.   /* Check for an exact match in the list of descriptions we have
  426.      previously parsed.  strcmp is a slightly inefficient way to
  427.      do this; an SHA-1 checksum would work as well.  */
  428.   for (ix = 0; VEC_iterate (tdesc_xml_cache_s, xml_cache, ix, cache); ix++)
  429.     if (strcmp (cache->xml_document, expanded_text) == 0)
  430.       {
  431.        xfree (expanded_text);
  432.        return cache->tdesc;
  433.       }

  434.   back_to = make_cleanup (null_cleanup, NULL);

  435.   memset (&data, 0, sizeof (struct tdesc_parsing_data));
  436.   data.tdesc = allocate_target_description ();
  437.   result_cleanup = make_cleanup_free_target_description (data.tdesc);
  438.   make_cleanup (xfree, expanded_text);

  439.   if (gdb_xml_parse_quick (_("target description"), "gdb-target.dtd",
  440.                            tdesc_elements, expanded_text, &data) == 0)
  441.     {
  442.       /* Parsed successfully.  */
  443.       struct tdesc_xml_cache new_cache;

  444.       new_cache.xml_document = expanded_text;
  445.       new_cache.tdesc = data.tdesc;
  446.       VEC_safe_push (tdesc_xml_cache_s, xml_cache, &new_cache);
  447.       discard_cleanups (result_cleanup);
  448.       do_cleanups (back_to);
  449.       return data.tdesc;
  450.     }
  451.   else
  452.     {
  453.       warning (_("Could not load XML target description; ignoring"));
  454.       do_cleanups (back_to);
  455.       return NULL;
  456.     }
  457. }
  458. #endif /* HAVE_LIBEXPAT */


  459. /* Read an XML target description from FILENAME.  Parse it, and return
  460.    the parsed description.  */

  461. const struct target_desc *
  462. file_read_description_xml (const char *filename)
  463. {
  464.   struct target_desc *tdesc;
  465.   char *tdesc_str;
  466.   struct cleanup *back_to;
  467.   char *dirname;

  468.   tdesc_str = xml_fetch_content_from_file (filename, NULL);
  469.   if (tdesc_str == NULL)
  470.     {
  471.       warning (_("Could not open \"%s\""), filename);
  472.       return NULL;
  473.     }

  474.   back_to = make_cleanup (xfree, tdesc_str);

  475.   dirname = ldirname (filename);
  476.   if (dirname != NULL)
  477.     make_cleanup (xfree, dirname);

  478.   tdesc = tdesc_parse_xml (tdesc_str, xml_fetch_content_from_file, dirname);
  479.   do_cleanups (back_to);

  480.   return tdesc;
  481. }

  482. /* Read a string representation of available features from the target,
  483.    using TARGET_OBJECT_AVAILABLE_FEATURES.  The returned string is
  484.    malloc allocated and NUL-terminated.  NAME should be a non-NULL
  485.    string identifying the XML document we want; the top level document
  486.    is "target.xml".  Other calls may be performed for the DTD or
  487.    for <xi:include>.  */

  488. static char *
  489. fetch_available_features_from_target (const char *name, void *baton_)
  490. {
  491.   struct target_ops *ops = baton_;

  492.   /* Read this object as a string.  This ensures that a NUL
  493.      terminator is added.  */
  494.   return target_read_stralloc (ops,
  495.                                TARGET_OBJECT_AVAILABLE_FEATURES,
  496.                                name);
  497. }


  498. /* Read an XML target description using OPS.  Parse it, and return the
  499.    parsed description.  */

  500. const struct target_desc *
  501. target_read_description_xml (struct target_ops *ops)
  502. {
  503.   struct target_desc *tdesc;
  504.   char *tdesc_str;
  505.   struct cleanup *back_to;

  506.   tdesc_str = fetch_available_features_from_target ("target.xml", ops);
  507.   if (tdesc_str == NULL)
  508.     return NULL;

  509.   back_to = make_cleanup (xfree, tdesc_str);
  510.   tdesc = tdesc_parse_xml (tdesc_str,
  511.                            fetch_available_features_from_target,
  512.                            ops);
  513.   do_cleanups (back_to);

  514.   return tdesc;
  515. }