+2018-07-31 Simon Marchi <simon.marchi@ericsson.com>
+
+ * target-descriptions.c (struct xml_test_tdesc): New.
+ (xml_tdesc): Change type to std::vector<xml_test_tdesc>.
+ (record_xml_tdesc): Update.
+ (maintenance_check_xml_descriptions): Update.
+ * target-descriptions.h (record_xml_tdesc): Update comment.
+
2018-07-30 Andrew Burgess <andrew.burgess@embecosm.com>
* eval.c (evaluate_subexp_for_sizeof): Check for array type before
namespace selftests {
-static std::vector<std::pair<const char*, const target_desc *>> xml_tdesc;
+/* A reference target description, used for testing (see record_xml_tdesc). */
+
+struct xml_test_tdesc
+{
+ xml_test_tdesc (const char *name, std::unique_ptr<const target_desc> &&tdesc)
+ : name (name), tdesc (std::move (tdesc))
+ {}
+
+ const char *name;
+ std::unique_ptr<const target_desc> tdesc;
+};
+
+static std::vector<xml_test_tdesc> xml_tdesc;
#if GDB_SELF_TEST
void
record_xml_tdesc (const char *xml_file, const struct target_desc *tdesc)
{
- xml_tdesc.emplace_back (xml_file, tdesc);
+ xml_tdesc.emplace_back (xml_file, std::unique_ptr<const target_desc> (tdesc));
}
#endif
for (auto const &e : selftests::xml_tdesc)
{
- std::string tdesc_xml = (feature_dir + SLASH_STRING + e.first);
+ std::string tdesc_xml = (feature_dir + SLASH_STRING + e.name);
const target_desc *tdesc
= file_read_description_xml (tdesc_xml.data ());
- if (tdesc == NULL || *tdesc != *e.second)
+ if (tdesc == NULL || *tdesc != *e.tdesc)
{
- printf_filtered ( _("Descriptions for %s do not match.\n"), e.first);
+ printf_filtered ( _("Descriptions for %s do not match.\n"), e.name);
failed++;
}
- else if (!maintenance_check_tdesc_xml_convert (tdesc, e.first)
- || !maintenance_check_tdesc_xml_convert (e.second, e.first))
+ else if (!maintenance_check_tdesc_xml_convert (tdesc, e.name)
+ || !maintenance_check_tdesc_xml_convert (e.tdesc.get (), e.name))
failed++;
}
printf_filtered (_("Tested %lu XML files, %d failed\n"),
/* Record that XML_FILE should generate a target description that equals
TDESC, to be verified by the "maintenance check xml-descriptions"
- command. */
+ command. This function takes ownership of TDESC. */
void record_xml_tdesc (const char *xml_file,
const struct target_desc *tdesc);