From patchwork Sat Nov 4 16:10:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 24095 Received: (qmail 70544 invoked by alias); 4 Nov 2017 16:10:22 -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 70532 invoked by uid 89); 4 Nov 2017 16:10:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 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= X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 Nov 2017 16:10:19 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway32.websitewelcome.com (Postfix) with ESMTP id F1A2345E5A9 for ; Sat, 4 Nov 2017 11:10:17 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id B11Veoo85pOTvB11VeZwTH; Sat, 04 Nov 2017 11:10:17 -0500 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:32786 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eB11V-003mRF-P9; Sat, 04 Nov 2017 11:10:17 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove symbolp vector Date: Sat, 4 Nov 2017 10:10:15 -0600 Message-Id: <20171104161015.16757-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eB11V-003mRF-P9 X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya.Home) [71.218.90.63]:32786 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes the symbolp typedef from dwarf2read.c and converts the associated VEC uses to std::vector. This fixes a latent possible memory leak if an exception were thrown, because there were no cleanups installed for these VECs. Regression tested on the buildbot. gdb/ChangeLog 2017-11-04 Tom Tromey * dwarf2read.c (symbolp): Remove typedef. (read_func_scope): Use std::vector. (process_structure_scope): Use std::vector. --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2read.c | 26 ++++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 686fa3f3d3..d6513281e1 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -82,9 +82,6 @@ #include #include -typedef struct symbol *symbolp; -DEF_VEC_P (symbolp); - /* When == 1, print basic high level tracing messages. When > 1, be more verbose. This is in contrast to the low level DIE reading of dwarf_die_debug. */ @@ -11614,7 +11611,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) CORE_ADDR baseaddr; struct block *block; int inlined_func = (die->tag == DW_TAG_inlined_subroutine); - VEC (symbolp) *template_args = NULL; + std::vector template_args; struct template_symbol *templ_func = NULL; if (inlined_func) @@ -11707,7 +11704,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) struct symbol *arg = new_symbol (child_die, NULL, cu); if (arg != NULL) - VEC_safe_push (symbolp, template_args, arg); + template_args.push_back (arg); } else process_die (child_die, cu); @@ -11762,18 +11759,17 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) gdbarch_make_symbol_special (gdbarch, newobj->name, objfile); /* Attach template arguments to function. */ - if (! VEC_empty (symbolp, template_args)) + if (!template_args.empty ()) { gdb_assert (templ_func != NULL); - templ_func->n_template_arguments = VEC_length (symbolp, template_args); + templ_func->n_template_arguments = template_args.size (); templ_func->template_arguments = XOBNEWVEC (&objfile->objfile_obstack, struct symbol *, templ_func->n_template_arguments); memcpy (templ_func->template_arguments, - VEC_address (symbolp, template_args), + template_args.data (), (templ_func->n_template_arguments * sizeof (struct symbol *))); - VEC_free (symbolp, template_args); } /* In C++, we can have functions nested inside functions (e.g., when @@ -13724,7 +13720,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) if (die->child != NULL && ! die_is_declaration (die, cu)) { struct field_info fi; - VEC (symbolp) *template_args = NULL; + std::vector template_args; struct cleanup *back_to = make_cleanup (null_cleanup, 0); memset (&fi, 0, sizeof (struct field_info)); @@ -13769,27 +13765,25 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) struct symbol *arg = new_symbol (child_die, NULL, cu); if (arg != NULL) - VEC_safe_push (symbolp, template_args, arg); + template_args.push_back (arg); } child_die = sibling_die (child_die); } /* Attach template arguments to type. */ - if (! VEC_empty (symbolp, template_args)) + if (!template_args.empty ()) { ALLOCATE_CPLUS_STRUCT_TYPE (type); - TYPE_N_TEMPLATE_ARGUMENTS (type) - = VEC_length (symbolp, template_args); + TYPE_N_TEMPLATE_ARGUMENTS (type) = template_args.size (); TYPE_TEMPLATE_ARGUMENTS (type) = XOBNEWVEC (&objfile->objfile_obstack, struct symbol *, TYPE_N_TEMPLATE_ARGUMENTS (type)); memcpy (TYPE_TEMPLATE_ARGUMENTS (type), - VEC_address (symbolp, template_args), + template_args.data (), (TYPE_N_TEMPLATE_ARGUMENTS (type) * sizeof (struct symbol *))); - VEC_free (symbolp, template_args); } /* Attach fields and member functions to the type. */