From patchwork Tue Apr 11 15:01:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 19967 Received: (qmail 128343 invoked by alias); 11 Apr 2017 15:02:23 -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 128114 invoked by uid 89); 11 Apr 2017 15:02:22 -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, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gproxy3.mail.unifiedlayer.com Received: from gproxy3-pub.mail.unifiedlayer.com (HELO gproxy3.mail.unifiedlayer.com) (69.89.30.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Apr 2017 15:02:14 +0000 Received: from cmgw4 (unknown [10.0.90.85]) by gproxy3.mail.unifiedlayer.com (Postfix) with ESMTP id 061A34075A for ; Tue, 11 Apr 2017 09:01:26 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id 731N1v0282f2jeq0131Rva; Tue, 11 Apr 2017 09:01:25 -0600 X-Authority-Analysis: v=2.2 cv=QdwWhoTv c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=AzvcPWV-tVgA:10 a=zstS-IiYAAAA:8 a=0vH4ELPB3GjkEUWU2-0A:9 a=7CKCtixtG6aYSI-F:21 a=yo-V_6OTpyKXg9wd:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-65-226.hlrn.qwest.net ([75.166.65.226]:50042 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cxxII-0007Ml-Ld; Tue, 11 Apr 2017 09:01:22 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 13/17] Use std::vector in find_instruction_backward Date: Tue, 11 Apr 2017 09:01:08 -0600 Message-Id: <20170411150112.23207-14-tom@tromey.com> In-Reply-To: <20170411150112.23207-1-tom@tromey.com> References: <20170411150112.23207-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1cxxII-0007Ml-Ld X-Source-Sender: 75-166-65-226.hlrn.qwest.net (bapiya.Home) [75.166.65.226]:50042 X-Source-Auth: tom+tromey.com X-Email-Count: 14 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This changes find_instruction_backward to use std::vector, removing a cleanup. gdb/ChangeLog 2017-04-11 Tom Tromey * printcmd.c (find_instruction_backward): Use std::vector. --- gdb/ChangeLog | 4 ++++ gdb/printcmd.c | 16 ++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ca92e86..f9e4a83 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2017-04-11 Tom Tromey + * printcmd.c (find_instruction_backward): Use std::vector. + +2017-04-11 Tom Tromey + * symfile.c (objfilep): Remove typedef. (reread_symbols): Use a std::vector. diff --git a/gdb/printcmd.c b/gdb/printcmd.c index f09f18a..02d6e1c 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -806,9 +806,8 @@ find_instruction_backward (struct gdbarch *gdbarch, CORE_ADDR addr, /* The vector PCS is used to store instruction addresses within a pc range. */ CORE_ADDR loop_start, loop_end, p; - VEC (CORE_ADDR) *pcs = NULL; + std::vector pcs; struct symtab_and_line sal; - struct cleanup *cleanup = make_cleanup (VEC_cleanup (CORE_ADDR), &pcs); *inst_read = 0; loop_start = loop_end = addr; @@ -822,7 +821,7 @@ find_instruction_backward (struct gdbarch *gdbarch, CORE_ADDR addr, instructions from INST_COUNT, and go to the next iteration. */ do { - VEC_truncate (CORE_ADDR, pcs, 0); + pcs.clear (); sal = find_pc_sect_line (loop_start, NULL, 1); if (sal.line <= 0) { @@ -844,12 +843,12 @@ find_instruction_backward (struct gdbarch *gdbarch, CORE_ADDR addr, LOOP_START to LOOP_END. */ for (p = loop_start; p < loop_end;) { - VEC_safe_push (CORE_ADDR, pcs, p); + pcs.push_back (p); p += gdb_insn_length (gdbarch, p); } - inst_count -= VEC_length (CORE_ADDR, pcs); - *inst_read += VEC_length (CORE_ADDR, pcs); + inst_count -= pcs.size (); + *inst_read += pcs.size (); } while (inst_count > 0); @@ -875,9 +874,7 @@ find_instruction_backward (struct gdbarch *gdbarch, CORE_ADDR addr, The case when the length of PCS is 0 means that we reached an area for which line info is not available. In such case, we return LOOP_START, which was the lowest instruction address that had line info. */ - p = VEC_length (CORE_ADDR, pcs) > 0 - ? VEC_index (CORE_ADDR, pcs, -inst_count) - : loop_start; + p = pcs.size () > 0 ? pcs[-inst_count] : loop_start; /* INST_READ includes all instruction addresses in a pc range. Need to exclude the beginning part up to the address we're returning. That @@ -885,7 +882,6 @@ find_instruction_backward (struct gdbarch *gdbarch, CORE_ADDR addr, if (inst_count < 0) *inst_read += inst_count; - do_cleanups (cleanup); return p; }