From: Simon Marchi Date: Tue, 10 Oct 2023 18:56:11 +0000 (-0400) Subject: gdb: remove lm_info_vector typedef X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1c0dfccba7bac021456198597fdce080d4a8315b;p=binutils-gdb.git gdb: remove lm_info_vector typedef I think this typedef hinders readability. First, it's not well named (it's not clear it contains lm_info_target objects). And hiding the fact that it contains unique pointers is not very useful either. I was looking at the code in solib_target_current_sos where the unique pointers get moved from the vector, and it wasn't obvious at all what the source of the move was. Change-Id: I4a5cda7c90554f018b7c466b1535b41d69cbcbe7 Approved-By: Pedro Alves Reviewed-By: Reviewed-By: Lancelot Six --- diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 05b35103091..e20a336f9ad 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -50,7 +50,7 @@ struct lm_info_target final : public lm_info section_offsets offsets; }; -typedef std::vector> lm_info_vector; +using lm_info_target_up = std::unique_ptr; #if !defined(HAVE_LIBEXPAT) @@ -81,7 +81,7 @@ library_list_start_segment (struct gdb_xml_parser *parser, void *user_data, std::vector &attributes) { - lm_info_vector *list = (lm_info_vector *) user_data; + auto *list = (std::vector *) user_data; lm_info_target *last = list->back ().get (); ULONGEST *address_p = (ULONGEST *) xml_find_attribute (attributes, "address")->value.get (); @@ -100,7 +100,7 @@ library_list_start_section (struct gdb_xml_parser *parser, void *user_data, std::vector &attributes) { - lm_info_vector *list = (lm_info_vector *) user_data; + auto *list = (std::vector *) user_data; lm_info_target *last = list->back ().get (); ULONGEST *address_p = (ULONGEST *) xml_find_attribute (attributes, "address")->value.get (); @@ -121,7 +121,7 @@ library_list_start_library (struct gdb_xml_parser *parser, void *user_data, std::vector &attributes) { - lm_info_vector *list = (lm_info_vector *) user_data; + auto *list = (std::vector *) user_data; lm_info_target *item = new lm_info_target; item->name = (const char *) xml_find_attribute (attributes, "name")->value.get (); @@ -134,7 +134,7 @@ library_list_end_library (struct gdb_xml_parser *parser, const struct gdb_xml_element *element, void *user_data, const char *body_text) { - lm_info_vector *list = (lm_info_vector *) user_data; + auto *list = (std::vector *) user_data; lm_info_target *lm_info = list->back ().get (); if (lm_info->segment_bases.empty () && lm_info->section_bases.empty ()) @@ -210,10 +210,10 @@ static const struct gdb_xml_element library_list_elements[] = { { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL } }; -static lm_info_vector +static std::vector solib_target_parse_libraries (const char *library) { - lm_info_vector result; + std::vector result; if (gdb_xml_parse_quick (_("target library list"), "library-list.dtd", library_list_elements, library, &result) == 0) @@ -240,14 +240,14 @@ solib_target_current_sos (void) return NULL; /* Parse the list. */ - lm_info_vector library_list + std::vector library_list = solib_target_parse_libraries (library_document->data ()); if (library_list.empty ()) return NULL; /* Build a struct so_list for each entry on the list. */ - for (auto &&info : library_list) + for (lm_info_target_up &info : library_list) { so_list *new_solib = new so_list; strncpy (new_solib->so_name, info->name.c_str (),