From patchwork Sat May 19 20:37:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27340 Received: (qmail 81609 invoked by alias); 19 May 2018 20:37:08 -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 81537 invoked by uid 89); 19 May 2018 20:37:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.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_HELO_PASS autolearn=ham version=3.3.2 spammy=cu, sk:partial, price, sk:load_fu X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.152.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 May 2018 20:37:05 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 6A320A8F8 for ; Sat, 19 May 2018 15:37:04 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id K8bAfTmPabXuJK8bAfm2Wi; Sat, 19 May 2018 15:37:04 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:41568 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fK8bA-0039EF-6z; Sat, 19 May 2018 15:37:04 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/2] Use std::vector for dwarf2_per_cu_data Date: Sat, 19 May 2018 14:37:01 -0600 Message-Id: <20180519203701.31211-3-tom@tromey.com> In-Reply-To: <20180519203701.31211-1-tom@tromey.com> References: <20180519203701.31211-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fK8bA-0039EF-6z X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:41568 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes one use of VEC from dwarf2read, in favor of std::vector. gdb/ChangeLog 2018-05-18 Tom Tromey * dwarf2read.c (dwarf2_per_cu_data): Update. (process_psymtab_comp_unit_reader, scan_partial_symbols) (recursively_compute_inclusions) (compute_compunit_symtab_includes, process_cu_includes) (process_full_comp_unit, process_imported_unit_die) (queue_and_load_dwo_tu, follow_die_sig_1): Update. * dwarf2read.h (dwarf2_per_cu_ptr): Remove typedef. Don't declare VEC. (struct dwarf2_per_objfile) : Now a std::vector. (struct dwarf2_per_cu_data) : Now a std::vector. --- gdb/ChangeLog | 14 ++++++++++++ gdb/dwarf2read.c | 69 ++++++++++++++++---------------------------------------- gdb/dwarf2read.h | 7 ++---- 3 files changed, 36 insertions(+), 54 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index e53c015932..11d66bc0ee 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2130,7 +2130,6 @@ dwarf2_per_cu_data::dwarf2_per_cu_data () dwarf2_per_cu_data::~dwarf2_per_cu_data () { - VEC_free (dwarf2_per_cu_ptr, imported_symtabs); } /* See declaration. */ @@ -8010,24 +8009,20 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader, end_psymtab_common (objfile, pst); - if (!VEC_empty (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs)) + if (!cu->per_cu->imported_symtabs.empty ()) { int i; - int len = VEC_length (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs); - struct dwarf2_per_cu_data *iter; + int len = cu->per_cu->imported_symtabs.size (); /* Fill in 'dependencies' here; we fill in 'users' in a post-pass. */ pst->number_of_dependencies = len; pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len); - for (i = 0; - VEC_iterate (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs, - i, iter); - ++i) - pst->dependencies[i] = iter->v.psymtab; + for (i = 0; i < len; ++i) + pst->dependencies[i] = cu->per_cu->imported_symtabs[i]->v.psymtab; - VEC_free (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs); + cu->per_cu->imported_symtabs.clear (); } /* Get the list of files included in the current compilation unit, @@ -8656,8 +8651,7 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc, if (per_cu->v.psymtab == NULL) process_psymtab_comp_unit (per_cu, 1, cu->language); - VEC_safe_push (dwarf2_per_cu_ptr, - cu->per_cu->imported_symtabs, per_cu); + cu->per_cu->imported_symtabs.push_back (per_cu); } break; case DW_TAG_imported_declaration: @@ -10150,9 +10144,7 @@ recursively_compute_inclusions (VEC (compunit_symtab_ptr) **result, struct compunit_symtab *immediate_parent) { void **slot; - int ix; struct compunit_symtab *cust; - struct dwarf2_per_cu_data *iter; slot = htab_find_slot (all_children, per_cu, INSERT); if (*slot != NULL) @@ -10187,13 +10179,9 @@ recursively_compute_inclusions (VEC (compunit_symtab_ptr) **result, } } - for (ix = 0; - VEC_iterate (dwarf2_per_cu_ptr, per_cu->imported_symtabs, ix, iter); - ++ix) - { - recursively_compute_inclusions (result, all_children, - all_type_symtabs, iter, cust); - } + for (struct dwarf2_per_cu_data *iter : per_cu->imported_symtabs) + recursively_compute_inclusions (result, all_children, + all_type_symtabs, iter, cust); } /* Compute the compunit_symtab 'includes' fields for the compunit_symtab of @@ -10204,10 +10192,9 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu) { gdb_assert (! per_cu->is_debug_types); - if (!VEC_empty (dwarf2_per_cu_ptr, per_cu->imported_symtabs)) + if (!per_cu->imported_symtabs.empty ()) { int ix, len; - struct dwarf2_per_cu_data *per_cu_iter; struct compunit_symtab *compunit_symtab_iter; VEC (compunit_symtab_ptr) *result_symtabs = NULL; htab_t all_children, all_type_symtabs; @@ -10222,15 +10209,10 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu) all_type_symtabs = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer, NULL, xcalloc, xfree); - for (ix = 0; - VEC_iterate (dwarf2_per_cu_ptr, per_cu->imported_symtabs, - ix, per_cu_iter); - ++ix) - { - recursively_compute_inclusions (&result_symtabs, all_children, - all_type_symtabs, per_cu_iter, - cust); - } + for (struct dwarf2_per_cu_data *per_cu_iter : per_cu->imported_symtabs) + recursively_compute_inclusions (&result_symtabs, all_children, + all_type_symtabs, per_cu_iter, + cust); /* Now we have a transitive closure of all the included symtabs. */ len = VEC_length (compunit_symtab_ptr, result_symtabs); @@ -10256,19 +10238,13 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu) static void process_cu_includes (struct dwarf2_per_objfile *dwarf2_per_objfile) { - int ix; - struct dwarf2_per_cu_data *iter; - - for (ix = 0; - VEC_iterate (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus, - ix, iter); - ++ix) + for (struct dwarf2_per_cu_data *iter : dwarf2_per_objfile->just_read_cus) { if (! iter->is_debug_types) compute_compunit_symtab_includes (iter); } - VEC_free (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus); + dwarf2_per_objfile->just_read_cus.clear (); } /* Generate full symbol information for PER_CU, whose DIEs have @@ -10376,7 +10352,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu, } /* Push it for inclusion processing later. */ - VEC_safe_push (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus, per_cu); + dwarf2_per_objfile->just_read_cus.push_back (per_cu); } /* Generate full symbol information for type unit PER_CU, whose DIEs have @@ -10485,8 +10461,7 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu) if (maybe_queue_comp_unit (cu, per_cu, cu->language)) load_full_comp_unit (per_cu, false, cu->language); - VEC_safe_push (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs, - per_cu); + cu->per_cu->imported_symtabs.push_back (per_cu); } } @@ -13408,7 +13383,7 @@ queue_and_load_dwo_tu (void **slot, void *info) while processing PER_CU. */ if (maybe_queue_comp_unit (NULL, sig_cu, per_cu->cu->language)) load_full_type_unit (sig_cu); - VEC_safe_push (dwarf2_per_cu_ptr, per_cu->imported_symtabs, sig_cu); + per_cu->imported_symtabs.push_back (sig_cu); } return 1; @@ -23260,11 +23235,7 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type, http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */ if (dwarf2_per_objfile->index_table != NULL && dwarf2_per_objfile->index_table->version <= 7) - { - VEC_safe_push (dwarf2_per_cu_ptr, - (*ref_cu)->per_cu->imported_symtabs, - sig_cu->per_cu); - } + (*ref_cu)->per_cu->imported_symtabs.push_back (sig_cu->per_cu); *ref_cu = sig_cu; return die; diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h index 369461f965..405a7edf4f 100644 --- a/gdb/dwarf2read.h +++ b/gdb/dwarf2read.h @@ -23,9 +23,6 @@ #include "filename-seen-cache.h" #include "gdb_obstack.h" -typedef struct dwarf2_per_cu_data *dwarf2_per_cu_ptr; -DEF_VEC_P (dwarf2_per_cu_ptr); - /* A descriptor for dwarf sections. S.ASECTION, SIZE are typically initialized when the objfile is first @@ -233,7 +230,7 @@ public: htab_t die_type_hash {}; /* The CUs we recently read. */ - VEC (dwarf2_per_cu_ptr) *just_read_cus = NULL; + std::vector just_read_cus; /* Table containing line_header indexed by offset and offset_in_dwz. */ htab_t line_header_hash {}; @@ -350,7 +347,7 @@ struct dwarf2_per_cu_data to. Concurrently with this change gdb was modified to emit version 8 indices so we only pay a price for gold generated indices. http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */ - VEC (dwarf2_per_cu_ptr) *imported_symtabs = nullptr; + std::vector imported_symtabs; }; /* Entry in the signatured_types hash table. */