From patchwork Thu May 10 00:09: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: 27195 Received: (qmail 124111 invoked by alias); 10 May 2018 00:09:13 -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 123789 invoked by uid 89); 10 May 2018 00:09:10 -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=adr, PST, pst, images X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.38) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 May 2018 00:09:08 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 0B953AC0F7D for ; Wed, 9 May 2018 19:09:06 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GZ8rf7i1XQUwqGZ8rfq33L; Wed, 09 May 2018 19:09:06 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:50606 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fGZ8r-001qeO-5H; Wed, 09 May 2018 19:09:05 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove cleanups from mdebugread.c Date: Wed, 9 May 2018 18:09:01 -0600 Message-Id: <20180510000901.26651-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fGZ8r-001qeO-5H X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:50606 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes the remaining cleanups from mdebugread.c, replacing them with gdb::def_vector. Tested by the buildbot, though I doubt this exercises mdebugread. gdb/ChangeLog 2018-05-09 Tom Tromey * mdebugread.c (parse_partial_symbols, psymtab_to_symtab_1): Use gdb::def_vector. --- gdb/ChangeLog | 5 +++++ gdb/mdebugread.c | 45 +++++++++++++++------------------------------ 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 59c4c89839..d9f119af40 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -2339,7 +2339,6 @@ parse_partial_symbols (minimal_symbol_reader &reader, FDR *fh; char *ext_out; char *ext_out_end; - EXTR *ext_block; EXTR *ext_in; EXTR *ext_in_end; SYMR sh; @@ -2355,7 +2354,6 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Index within current psymtab dependency list. */ struct partial_symtab **dependency_list; int dependencies_used, dependencies_allocated; - struct cleanup *old_chain; char *name; enum language prev_language; asection *text_sect; @@ -2404,8 +2402,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, /* Allocate the map FDR -> PST. Minor hack: -O3 images might claim some global data belongs to FDR -1. We`ll go along with that. */ - fdr_to_pst = XCNEWVEC (struct pst_map, hdr->ifdMax + 1); - old_chain = make_cleanup (xfree, fdr_to_pst); + gdb::def_vector fdr_to_pst_holder (hdr->ifdMax + 1); + fdr_to_pst = fdr_to_pst_holder.data (); fdr_to_pst++; { struct partial_symtab *pst = new_psymtab ("", objfile); @@ -2423,17 +2421,16 @@ parse_partial_symbols (minimal_symbol_reader &reader, hdr->ifdMax * sizeof (struct mdebug_pending *)); /* Pass 0 over external syms: swap them in. */ - ext_block = XNEWVEC (EXTR, hdr->iextMax); - make_cleanup (xfree, ext_block); + gdb::def_vector ext_block (hdr->iextMax); ext_out = (char *) debug_info->external_ext; ext_out_end = ext_out + hdr->iextMax * external_ext_size; - ext_in = ext_block; + ext_in = ext_block.data (); for (; ext_out < ext_out_end; ext_out += external_ext_size, ext_in++) (*swap_ext_in) (cur_bfd, ext_out, ext_in); /* Pass 1 over external syms: Presize and partition the list. */ - ext_in = ext_block; + ext_in = ext_block.data (); ext_in_end = ext_in + hdr->iextMax; for (; ext_in < ext_in_end; ext_in++) { @@ -2486,7 +2483,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, symbol table. */ /* Pass 2 over external syms: fill in external symbols. */ - ext_in = ext_block; + ext_in = ext_block.data (); ext_in_end = ext_in + hdr->iextMax; for (; ext_in < ext_in_end; ext_in++) { @@ -3812,7 +3809,6 @@ parse_partial_symbols (minimal_symbol_reader &reader, && objfile->psymtabs->n_global_syms == 0 && objfile->psymtabs->n_static_syms == 0) objfile->psymtabs = NULL; - do_cleanups (old_chain); } /* If the current psymbol has an enumerated type, we need to add @@ -4121,20 +4117,17 @@ psymtab_to_symtab_1 (struct objfile *objfile, /* Fill in procedure info next. */ if (fh->cpd > 0) { - PDR *pr_block; - struct cleanup *old_chain; char *pdr_ptr; char *pdr_end; PDR *pdr_in; PDR *pdr_in_end; - pr_block = XNEWVEC (PDR, fh->cpd); - old_chain = make_cleanup (xfree, pr_block); + gdb::def_vector pr_block (fh->cpd); pdr_ptr = ((char *) debug_info->external_pdr + fh->ipdFirst * external_pdr_size); pdr_end = pdr_ptr + fh->cpd * external_pdr_size; - pdr_in = pr_block; + pdr_in = pr_block.data (); for (; pdr_ptr < pdr_end; pdr_ptr += external_pdr_size, pdr_in++) @@ -4143,18 +4136,16 @@ psymtab_to_symtab_1 (struct objfile *objfile, /* Determine lowest PDR address, the PDRs are not always sorted. */ - if (pdr_in == pr_block) + if (pdr_in == pr_block.data ()) lowest_pdr_addr = pdr_in->adr; else if (pdr_in->adr < lowest_pdr_addr) lowest_pdr_addr = pdr_in->adr; } - pdr_in = pr_block; + pdr_in = pr_block.data (); pdr_in_end = pdr_in + fh->cpd; for (; pdr_in < pdr_in_end; pdr_in++) parse_procedure (pdr_in, cust, pst); - - do_cleanups (old_chain); } } else @@ -4224,21 +4215,17 @@ psymtab_to_symtab_1 (struct objfile *objfile, structures, so we swap them all first. */ if (fh->cpd > 0) { - PDR *pr_block; - struct cleanup *old_chain; char *pdr_ptr; char *pdr_end; PDR *pdr_in; PDR *pdr_in_end; - pr_block = XNEWVEC (PDR, fh->cpd); - - old_chain = make_cleanup (xfree, pr_block); + gdb::def_vector pr_block (fh->cpd); pdr_ptr = ((char *) debug_info->external_pdr + fh->ipdFirst * external_pdr_size); pdr_end = pdr_ptr + fh->cpd * external_pdr_size; - pdr_in = pr_block; + pdr_in = pr_block.data (); for (; pdr_ptr < pdr_end; pdr_ptr += external_pdr_size, pdr_in++) @@ -4247,24 +4234,22 @@ psymtab_to_symtab_1 (struct objfile *objfile, /* Determine lowest PDR address, the PDRs are not always sorted. */ - if (pdr_in == pr_block) + if (pdr_in == pr_block.data ()) lowest_pdr_addr = pdr_in->adr; else if (pdr_in->adr < lowest_pdr_addr) lowest_pdr_addr = pdr_in->adr; } - parse_lines (fh, pr_block, lines, maxlines, + parse_lines (fh, pr_block.data (), lines, maxlines, pst, lowest_pdr_addr); if (lines->nitems < fh->cline) lines = shrink_linetable (lines); /* Fill in procedure info next. */ - pdr_in = pr_block; + pdr_in = pr_block.data (); pdr_in_end = pdr_in + fh->cpd; for (; pdr_in < pdr_in_end; pdr_in++) parse_procedure (pdr_in, NULL, pst); - - do_cleanups (old_chain); } }