tfile_target::close: trace_fd can't be -1
[deliverable/binutils-gdb.git] / gdb / xml-tdesc.c
index 1c3409d53b684250d9192a43339ff75459abc695..6f108a4e3ef620361b2f611efbfd251964662519 100644 (file)
@@ -1,6 +1,6 @@
 /* XML target description support for GDB.
 
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2020 Free Software Foundation, Inc.
 
    Contributed by CodeSourcery.
 
@@ -66,7 +66,7 @@ tdesc_parse_xml (const char *document, xml_fetch_another fetcher,
    then we will create unnecessary duplicate gdbarches.  See
    gdbarch_list_lookup_by_info.  */
 
-static std::unordered_map<std::string, target_desc *> xml_cache;
+static std::unordered_map<std::string, target_desc_up> xml_cache;
 
 /* Callback data for target description parsing.  */
 
@@ -637,25 +637,22 @@ tdesc_parse_xml (const char *document, xml_fetch_another fetcher,
      previously parsed.  */
   const auto it = xml_cache.find (expanded_text);
   if (it != xml_cache.end ())
-    return it->second;
+    return it->second.get ();
 
   memset (&data, 0, sizeof (struct tdesc_parsing_data));
-  data.tdesc = allocate_target_description ();
-  struct cleanup *result_cleanup
-    = make_cleanup_free_target_description (data.tdesc);
+  target_desc_up description (allocate_target_description ());
+  data.tdesc = description.get ();
 
   if (gdb_xml_parse_quick (_("target description"), "gdb-target.dtd",
                           tdesc_elements, expanded_text.c_str (), &data) == 0)
     {
       /* Parsed successfully.  */
-      xml_cache.emplace (std::move (expanded_text), data.tdesc);
-      discard_cleanups (result_cleanup);
+      xml_cache.emplace (std::move (expanded_text), std::move (description));
       return data.tdesc;
     }
   else
     {
       warning (_("Could not load XML target description; ignoring"));
-      do_cleanups (result_cleanup);
       return NULL;
     }
 }
@@ -752,3 +749,15 @@ target_fetch_description_xml (struct target_ops *ops)
   return output;
 #endif
 }
+
+/* See xml-tdesc.h.  */
+
+const struct target_desc *
+string_read_description_xml (const char *xml)
+{
+  return tdesc_parse_xml (xml, [] (const char *href, void *baton)
+    {
+      error (_("xincludes are unsupported with this method"));
+      return gdb::optional<gdb::char_vector> ();
+    }, nullptr);
+}
This page took 0.027011 seconds and 4 git commands to generate.