- struct target_desc *tdesc;
- char *tdesc_str;
- char *expanded_text;
- struct cleanup *back_to;
-
- tdesc_str = fetch_available_features_from_target ("target.xml", ops);
- if (tdesc_str == NULL)
- return NULL;
-
- back_to = make_cleanup (xfree, tdesc_str);
- expanded_text = xml_process_xincludes (_("target description"),
- tdesc_str,
- fetch_available_features_from_target, ops, 0);
- do_cleanups (back_to);
- if (expanded_text == NULL)
+ gdb::optional<gdb::char_vector>
+ tdesc_str = fetch_available_features_from_target ("target.xml", ops);
+ if (!tdesc_str)
+ return {};
+
+ std::string output;
+ if (!xml_process_xincludes (output,
+ _("target description"),
+ tdesc_str->data (),
+ fetch_available_features_from_target, ops, 0))