From patchwork Fri Jun 8 02:56:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27705 Received: (qmail 57779 invoked by alias); 8 Jun 2018 02:56:44 -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 57764 invoked by uid 89); 8 Jun 2018 02:56:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 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=def_vec_p, DEF_VEC_P X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.146.7) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Jun 2018 02:56:40 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 1D233847D for ; Thu, 7 Jun 2018 21:56:39 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id R7Zvfk8zIkBj6R7ZvfDSG2; Thu, 07 Jun 2018 21:56:39 -0500 X-Authority-Reason: nr=8 Received: from 75-166-19-45.hlrn.qwest.net ([75.166.19.45]:34924 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fR7Zu-002GcT-Qn; Thu, 07 Jun 2018 21:56:38 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove a VEC from record-full.c Date: Thu, 7 Jun 2018 20:56:36 -0600 Message-Id: <20180608025636.14640-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fR7Zu-002GcT-Qn X-Source-Sender: 75-166-19-45.hlrn.qwest.net (bapiya.Home) [75.166.19.45]:34924 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This replaces a VEC in record-full.c with a std::vector. This patch is somewhat simplisitic and may affect the performance of record_full_target::remove_breakpoint. I suspect this does not matter but your comments are appreciated. Tested by the buildbot. gdb/ChangeLog 2018-06-07 Tom Tromey * record-full.c (record_full_breakpoint_p): Remove typedef. Don't declare VEC. (record_full_breakpoints): Now a std::vector, static. (record_full_sync_record_breakpoints) (record_full_init_record_breakpoints) (record_full_target::insert_breakpoint) (record_full_target::remove_breakpoint): Update. --- gdb/ChangeLog | 10 ++++++++++ gdb/record-full.c | 37 ++++++++++++------------------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/gdb/record-full.c b/gdb/record-full.c index 87c77e06ea9..e997ef2171b 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -1710,12 +1710,9 @@ struct record_full_breakpoint int in_target_beneath; }; -typedef struct record_full_breakpoint *record_full_breakpoint_p; -DEF_VEC_P(record_full_breakpoint_p); - /* The list of breakpoints inserted while the record target is active. */ -VEC(record_full_breakpoint_p) *record_full_breakpoints = NULL; +static std::vector record_full_breakpoints; static void record_full_sync_record_breakpoints (struct bp_location *loc, void *data) @@ -1732,7 +1729,7 @@ record_full_sync_record_breakpoints (struct bp_location *loc, void *data) bp->in_target_beneath = 1; - VEC_safe_push (record_full_breakpoint_p, record_full_breakpoints, bp); + record_full_breakpoints.push_back (bp); } } @@ -1741,7 +1738,7 @@ record_full_sync_record_breakpoints (struct bp_location *loc, void *data) static void record_full_init_record_breakpoints (void) { - VEC_free (record_full_breakpoint_p, record_full_breakpoints); + record_full_breakpoints.clear (); iterate_over_bp_locations (record_full_sync_record_breakpoints); } @@ -1754,9 +1751,7 @@ int record_full_target::insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { - struct record_full_breakpoint *bp; int in_target_beneath = 0; - int ix; if (!RECORD_FULL_IS_REPLAY) { @@ -1779,10 +1774,7 @@ record_full_target::insert_breakpoint (struct gdbarch *gdbarch, /* Use the existing entries if found in order to avoid duplication in record_full_breakpoints. */ - for (ix = 0; - VEC_iterate (record_full_breakpoint_p, - record_full_breakpoints, ix, bp); - ++ix) + for (struct record_full_breakpoint *bp : record_full_breakpoints) { if (bp->addr == bp_tgt->placed_address && bp->address_space == bp_tgt->placed_address_space) @@ -1792,11 +1784,11 @@ record_full_target::insert_breakpoint (struct gdbarch *gdbarch, } } - bp = XNEW (struct record_full_breakpoint); + struct record_full_breakpoint *bp = XNEW (struct record_full_breakpoint); bp->addr = bp_tgt->placed_address; bp->address_space = bp_tgt->placed_address_space; bp->in_target_beneath = in_target_beneath; - VEC_safe_push (record_full_breakpoint_p, record_full_breakpoints, bp); + record_full_breakpoints.push_back (bp); return 0; } @@ -1807,14 +1799,12 @@ record_full_target::remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, enum remove_bp_reason reason) { - struct record_full_breakpoint *bp; - int ix; - - for (ix = 0; - VEC_iterate (record_full_breakpoint_p, - record_full_breakpoints, ix, bp); - ++ix) + for (auto iter = record_full_breakpoints.begin (); + iter != record_full_breakpoints.end (); + ++iter) { + struct record_full_breakpoint *bp = *iter; + if (bp->addr == bp_tgt->placed_address && bp->address_space == bp_tgt->placed_address_space) { @@ -1830,10 +1820,7 @@ record_full_target::remove_breakpoint (struct gdbarch *gdbarch, } if (reason == REMOVE_BREAKPOINT) - { - VEC_unordered_remove (record_full_breakpoint_p, - record_full_breakpoints, ix); - } + record_full_breakpoints.erase (iter); return 0; } }