From patchwork Fri Jun 21 11:58:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 33250 Received: (qmail 28786 invoked by alias); 21 Jun 2019 11:58:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28728 invoked by uid 89); 21 Jun 2019 11:58:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HDKIM-Filter:v2.10.3, tus, Everything X-HELO: mail.efficios.com Received: from mail.efficios.com (HELO mail.efficios.com) (167.114.142.138) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Jun 2019 11:58:33 +0000 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 979FB259D05 for ; Fri, 21 Jun 2019 07:58:31 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 4vR5QUojZV1Z; Fri, 21 Jun 2019 07:58:31 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id EAEB9259CFC; Fri, 21 Jun 2019 07:58:30 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com EAEB9259CFC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1561118310; bh=y/zpi4cSPjOoUvk6mTN0tOA6T4g2D2PvEJwFS4FkUvA=; h=From:To:Date:Message-Id:MIME-Version; b=jCkdhYHhleJP/TVW7pYnW+vx084py97NUnx3ZmlPkl1czWzx1KWFrhFwMO4O4RDE6 1hAt55i1v9B1DQ0LlQd7m6AbzR1vLOk8ZKlAnxY2DYUt7OdChFNAMthLOu5pZxhMQa OH8PirJ11f0baRuKfLamQRuXbSplj/RFLQj9ROfyT8IsCSRx4rFtAiyRDldRHH+113 FToMlMZfdnNlvL9ig+MY3EkWyir47s8pdz1Qn+JdamJEGDeT6gewIrQhb1zkcE3b4V QZyN/KmYBcE34Fc99yO6uLgoQWtpYwDamy2/zDFNIi2lP4PlRmcsxMRdIY38kEfJBR aokv+hMpTEV9w== Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id GwgLOjqVG3IX; Fri, 21 Jun 2019 07:58:30 -0400 (EDT) Received: from smarchi-efficios.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id 9D6A7259CE3; Fri, 21 Jun 2019 07:58:30 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/4] dwarf2read: Get rid of VEC (dwarf2_section_info_def) Date: Fri, 21 Jun 2019 07:58:16 -0400 Message-Id: <20190621115816.14841-5-simon.marchi@efficios.com> In-Reply-To: <20190621115816.14841-1-simon.marchi@efficios.com> References: <20190621115816.14841-1-simon.marchi@efficios.com> MIME-Version: 1.0 This patch removes uses of VEC (dwarf2_section_info_def) in favor of std::vector. The conversion is relatively straightforward, no function changes are intended. gdb/ChangeLog: * dwarf2read.h (dwarf2_section_info_def): Remove. (DEF_VEC_O (dwarf2_section_info_def)): Remove. * dwarf2read.c (struct dwo_sections) : Change type to std::vector. (struct dwo_file) <~dwo_file>: Remove. (dwarf2_per_objfile::~dwarf2_per_objfile): Don't manually free types field. (dwarf2_per_objfile::locate_sections): Adjust to std::vector. (dwarf2_read_debug_names): Likewise. (create_debug_types_hash_table): Change parameter type to array_view, adjust code accordingly. (dwarf2_locate_dwo_sections): Adjust to std::vector. (partial_die_info::fixup): Likewise. (determine_prefix): Likewise. * dwarf-index-write.c (write_psymtabs_to_index): Adjust. --- gdb/dwarf-index-write.c | 2 +- gdb/dwarf2read.c | 46 +++++++++++------------------------------ gdb/dwarf2read.h | 5 +---- 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c index 9979ae44402f..3f5862aeb4ca 100644 --- a/gdb/dwarf-index-write.c +++ b/gdb/dwarf-index-write.c @@ -1638,7 +1638,7 @@ write_psymtabs_to_index (struct dwarf2_per_objfile *dwarf2_per_objfile, if (dwarf2_per_objfile->using_index) error (_("Cannot use an index to create the index")); - if (VEC_length (dwarf2_section_info_def, dwarf2_per_objfile->types) > 1) + if (dwarf2_per_objfile->types.size () > 1) error (_("Cannot make an index when the file has multiple .debug_types sections")); if (!objfile->partial_symtabs->psymtabs diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 05c872017066..fccbd05e2d69 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -655,7 +655,7 @@ struct dwo_sections struct dwarf2_section_info str_offsets; /* In the case of a virtual DWO file, these two are unused. */ struct dwarf2_section_info info; - VEC (dwarf2_section_info_def) *types; + std::vector types; }; /* CUs/TUs in DWP/DWO files. */ @@ -706,11 +706,6 @@ struct dwo_file dwo_file () = default; DISABLE_COPY_AND_ASSIGN (dwo_file); - ~dwo_file () - { - VEC_free (dwarf2_section_info_def, sections.types); - } - /* The DW_AT_GNU_dwo_name attribute. For virtual DWO files the name is constructed from the section offsets of abbrev,line,loc,str_offsets so that we combine virtual DWO files @@ -2160,8 +2155,6 @@ dwarf2_per_objfile::~dwarf2_per_objfile () for (signatured_type *sig_type : all_type_units) VEC_free (dwarf2_per_cu_ptr, sig_type->per_cu.imported_symtabs); - VEC_free (dwarf2_section_info_def, types); - /* Everything else should be on the objfile obstack. */ } @@ -2418,8 +2411,7 @@ dwarf2_per_objfile::locate_sections (bfd *abfd, asection *sectp, type_section.s.section = sectp; type_section.size = bfd_get_section_size (sectp); - VEC_safe_push (dwarf2_section_info_def, this->types, - &type_section); + this->types.push_back (type_section); } else if (section_is_p (sectp->name, &names.gdb_index)) { @@ -3592,15 +3584,12 @@ dwarf2_read_gdb_index if (types_list_elements) { - struct dwarf2_section_info *section; - /* We can only handle a single .debug_types when we have an index. */ - if (VEC_length (dwarf2_section_info_def, dwarf2_per_objfile->types) != 1) + if (dwarf2_per_objfile->types.size () != 1) return 0; - section = VEC_index (dwarf2_section_info_def, - dwarf2_per_objfile->types, 0); + dwarf2_section_info *section = &dwarf2_per_objfile->types[0]; create_signatured_type_table_from_index (dwarf2_per_objfile, section, types_list, types_list_elements); @@ -5636,11 +5625,10 @@ dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile) { /* We can only handle a single .debug_types when we have an index. */ - if (VEC_length (dwarf2_section_info_def, dwarf2_per_objfile->types) != 1) + if (dwarf2_per_objfile->types.size () != 1) return false; - dwarf2_section_info *section = VEC_index (dwarf2_section_info_def, - dwarf2_per_objfile->types, 0); + dwarf2_section_info *section = &dwarf2_per_objfile->types[0]; create_signatured_type_table_from_debug_names (dwarf2_per_objfile, *map, section, &dwarf2_per_objfile->abbrev); @@ -6817,19 +6805,11 @@ create_debug_type_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, static void create_debug_types_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, struct dwo_file *dwo_file, - VEC (dwarf2_section_info_def) *types, + gdb::array_view type_sections, htab_t &types_htab) { - int ix; - struct dwarf2_section_info *section; - - if (VEC_empty (dwarf2_section_info_def, types)) - return; - - for (ix = 0; - VEC_iterate (dwarf2_section_info_def, types, ix, section); - ++ix) - create_debug_type_hash_table (dwarf2_per_objfile, dwo_file, section, + for (dwarf2_section_info §ion : type_sections) + create_debug_type_hash_table (dwarf2_per_objfile, dwo_file, §ion, types_htab, rcuh_kind::TYPE); } @@ -12943,8 +12923,7 @@ dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, void *dwo_sections_ptr) memset (&type_section, 0, sizeof (type_section)); type_section.s.section = sectp; type_section.size = bfd_get_section_size (sectp); - VEC_safe_push (dwarf2_section_info_def, dwo_sections->types, - &type_section); + dwo_sections->types.push_back (type_section); } } @@ -19030,8 +19009,7 @@ partial_die_info::fixup (struct dwarf2_cu *cu) children, see if we can determine the namespace from their linkage name. */ if (cu->language == language_cplus - && !VEC_empty (dwarf2_section_info_def, - cu->per_cu->dwarf2_per_objfile->types) + && !cu->per_cu->dwarf2_per_objfile->types.empty () && die_parent == NULL && has_children && (tag == DW_TAG_class_type @@ -22533,7 +22511,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_partial_unit: /* gcc-4.5 -gdwarf-4 can drop the enclosing namespace. Cope. */ if (cu->language == language_cplus - && !VEC_empty (dwarf2_section_info_def, dwarf2_per_objfile->types) + && !dwarf2_per_objfile->types.empty () && die->child != NULL && (die->tag == DW_TAG_class_type || die->tag == DW_TAG_structure_type diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h index 4a1cd9cf00ed..9251bde12592 100644 --- a/gdb/dwarf2read.h +++ b/gdb/dwarf2read.h @@ -73,9 +73,6 @@ struct dwarf2_section_info bool is_virtual; }; -typedef struct dwarf2_section_info dwarf2_section_info_def; -DEF_VEC_O (dwarf2_section_info_def); - /* Read the contents of the section INFO. OBJFILE is the main object file, but not necessarily the file where the section comes from. E.g., for DWO files the bfd of INFO is the bfd @@ -167,7 +164,7 @@ public: dwarf2_section_info debug_names {}; dwarf2_section_info debug_aranges {}; - VEC (dwarf2_section_info_def) *types = NULL; + std::vector types; /* Back link. */ struct objfile *objfile = NULL;