+2021-05-07 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * target-descriptions.c (struct target_desc_info) <filename>:
+ Make std::string.
+ (copy_inferior_target_desc_info): Adjust.
+ (target_desc_info_free): Adjust.
+ (target_find_description): Adjust.
+ (set_tdesc_filename_cmd): Adjust.
+ (show_tdesc_filename_cmd): Adjust.
+ (unset_tdesc_filename_cmd): Adjust.
+ (maint_print_c_tdesc_cmd): Adjust.
+
2021-05-07 Simon Marchi <simon.marchi@polymtl.ca>
* target-descriptions.c (struct target_desc_info): Initialize
const struct target_desc *tdesc = nullptr;
- /* The filename to read a target description from, as set by "set
- tdesc filename ..." */
+ /* If not empty, the filename to read a target description from, as set by
+ "set tdesc filename ...".
- char *filename = nullptr;
+ If empty, there is not filename specified by the user. */
+
+ std::string filename;
};
/* Get the inferior INF's target description info, allocating one on
int
target_desc_info_from_user_p (struct target_desc_info *info)
{
- return info != NULL && info->filename != NULL;
+ return info != nullptr && !info->filename.empty ();
}
/* See target-descriptions.h. */
struct target_desc_info *src = get_tdesc_info (srcinf);
struct target_desc_info *dest = get_tdesc_info (destinf);
- dest->fetched = src->fetched;
- dest->tdesc = src->tdesc;
- dest->filename = src->filename != NULL ? xstrdup (src->filename) : NULL;
+ *dest = *src;
}
/* See target-descriptions.h. */
void
target_desc_info_free (struct target_desc_info *tdesc_info)
{
- if (tdesc_info != NULL)
- {
- xfree (tdesc_info->filename);
- delete tdesc_info;
- }
+ delete tdesc_info;
}
/* The string manipulated by the "set tdesc filename ..." command. */
/* First try to fetch an XML description from the user-specified
file. */
tdesc_info->tdesc = nullptr;
- if (tdesc_info->filename != nullptr && *tdesc_info->filename != '\0')
- tdesc_info->tdesc = file_read_description_xml (tdesc_info->filename);
+ if (!tdesc_info->filename.empty ())
+ tdesc_info->tdesc = file_read_description_xml (tdesc_info->filename.data ());
/* Next try to read the description from the current target using
target objects. */
{
target_desc_info *tdesc_info = get_tdesc_info (current_inferior ());
- xfree (tdesc_info->filename);
- tdesc_info->filename = xstrdup (tdesc_filename_cmd_string);
+ tdesc_info->filename = tdesc_filename_cmd_string;
target_clear_description ();
target_find_description ();
struct cmd_list_element *c,
const char *value)
{
- value = get_tdesc_info (current_inferior ())->filename;
+ value = get_tdesc_info (current_inferior ())->filename.data ();
if (value != NULL && *value != '\0')
printf_filtered (_("The target description will be read from \"%s\".\n"),
{
target_desc_info *tdesc_info = get_tdesc_info (current_inferior ());
- xfree (tdesc_info->filename);
- tdesc_info->filename = nullptr;
+ tdesc_info->filename.clear ();
target_clear_description ();
target_find_description ();
}
initialization code will reject the new description. */
target_desc_info *tdesc_info = get_tdesc_info (current_inferior ());
tdesc = tdesc_info->tdesc;
- filename = tdesc_info->filename;
+ filename = tdesc_info->filename.data ();
}
else
{