From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4966 invoked by alias); 3 Jul 2018 14:46:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 4620 invoked by uid 89); 3 Jul 2018 14:46:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=embedded X-HELO: mail-wr0-f177.google.com Received: from mail-wr0-f177.google.com (HELO mail-wr0-f177.google.com) (209.85.128.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Jul 2018 14:46:30 +0000 Received: by mail-wr0-f177.google.com with SMTP id u7-v6so2250802wrn.12 for ; Tue, 03 Jul 2018 07:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GPWVjsZklDFu1iqRxxjKdAGt+0NFKzI0lBkdmiARNwY=; b=Nk6ovLbIfoXQfPjWGmWtPS60tjrKHV+atafvm59EW8Mk7HAusX5QhXrusUuCE0PQl3 qW73/BJXVw5Rq1CGgb5p03gEZ70tYX7i5OwC+VOOaYitKU5V3CPilsdToc9TgIFZ01R7 3MD1wTi9QrurDQx0xXwU86PYDhqmE+bDtJDHh+x3/MxaKWBGg1yNjmPOd4/MEKMEGSBZ p/a+lCfNbLeoId/1SHkdYHvbvTADmSwWVQmmGngyiNtF6YsM72p29EVblsv8jNkCOsPU e0wx0wHGWx0QAtvtVdEirG0q7YJd+aDumtJTF35wAIRpcU7JjUHwVa8XrZq9J7+0ncBz ffiw== Return-Path: Received: from localhost (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by smtp.gmail.com with ESMTPSA id m17-v6sm2347860wrg.65.2018.07.03.07.46.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jul 2018 07:46:27 -0700 (PDT) Date: Tue, 03 Jul 2018 14:46:00 -0000 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Use std::vector for moribund_locations Message-ID: <20180703144626.GB2675@embecosm.com> References: <20180605192346.5509-1-tom@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180605192346.5509-1-tom@tromey.com> X-Fortune: You scratch my tape, and I'll scratch yours. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00052.txt.bz2 * Tom Tromey [2018-06-05 13:23:46 -0600]: > This changes moribund_locations to use a std::vector rather than VEC. > I also noticed that moribund_locations is only used in breakpoint.c, > so now it is static as well. > > It might be possible to make this code a bit simpler by using a > ref_ptr in moribund_locations; however, I have not done this. > > Tested by the buildbot. > > gdb/ChangeLog > 2018-06-05 Tom Tromey > > * breakpoint.c (moribund_locations): Now static and a > std::vector. > (breakpoint_init_inferior, moribund_breakpoint_here_p) > (build_bpstat_chain, update_global_location_list) > (breakpoint_retire_moribund): Update. > * breakpoint.h (bp_location_p): Remove typedef. Don't declare > VEC. FWIW this looks fine to me. Thanks, Andrew > --- > gdb/ChangeLog | 10 ++++++++++ > gdb/breakpoint.c | 42 ++++++++++++++++++------------------------ > gdb/breakpoint.h | 3 --- > 3 files changed, 28 insertions(+), 27 deletions(-) > > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c > index 00c538e989e..36d1a6735e6 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -560,7 +560,7 @@ static CORE_ADDR bp_locations_shadow_len_after_address_max; > /* The locations that no longer correspond to any breakpoint, unlinked > from the bp_locations array, but for which a hit may still be > reported by a target. */ > -VEC(bp_location_p) *moribund_locations = NULL; > +static std::vector moribund_locations; > > /* Number of last breakpoint made. */ > > @@ -3860,8 +3860,6 @@ void > breakpoint_init_inferior (enum inf_context context) > { > struct breakpoint *b, *b_tmp; > - struct bp_location *bl; > - int ix; > struct program_space *pspace = current_program_space; > > /* If breakpoint locations are shared across processes, then there's > @@ -3951,9 +3949,9 @@ breakpoint_init_inferior (enum inf_context context) > } > > /* Get rid of the moribund locations. */ > - for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, bl); ++ix) > + for (bp_location *bl : moribund_locations) > decref_bp_location (&bl); > - VEC_free (bp_location_p, moribund_locations); > + moribund_locations.clear (); > } > > /* These functions concern about actual breakpoints inserted in the > @@ -4041,10 +4039,7 @@ breakpoint_in_range_p (const address_space *aspace, > int > moribund_breakpoint_here_p (const address_space *aspace, CORE_ADDR pc) > { > - struct bp_location *loc; > - int ix; > - > - for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix) > + for (bp_location *loc : moribund_locations) > if (breakpoint_location_address_match (loc, aspace, pc)) > return 1; > > @@ -5362,10 +5357,7 @@ build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr, > if (!target_supports_stopped_by_sw_breakpoint () > || !target_supports_stopped_by_hw_breakpoint ()) > { > - bp_location *loc; > - > - for (int ix = 0; > - VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix) > + for (bp_location *loc : moribund_locations) > { > if (breakpoint_location_address_match (loc, aspace, bp_addr) > && need_moribund_for_location_type (loc)) > @@ -12009,7 +12001,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode) > old_loc->events_till_retirement = 3 * (thread_count () + 1); > old_loc->owner = NULL; > > - VEC_safe_push (bp_location_p, moribund_locations, old_loc); > + moribund_locations.push_back (old_loc); > } > else > { > @@ -12112,16 +12104,18 @@ update_global_location_list (enum ugll_insert_mode insert_mode) > void > breakpoint_retire_moribund (void) > { > - struct bp_location *loc; > - int ix; > - > - for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix) > - if (--(loc->events_till_retirement) == 0) > - { > - decref_bp_location (&loc); > - VEC_unordered_remove (bp_location_p, moribund_locations, ix); > - --ix; > - } > + auto it = std::remove_if (moribund_locations.begin (), > + moribund_locations.end (), > + [] (bp_location *loc) > + { > + if (--(loc->events_till_retirement) == 0) > + { > + decref_bp_location (&loc); > + return true; > + } > + return false; > + }); > + moribund_locations.erase (it, moribund_locations.end ()); > } > > static void > diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h > index 4223158fbc0..6c9326fb8a9 100644 > --- a/gdb/breakpoint.h > +++ b/gdb/breakpoint.h > @@ -666,9 +666,6 @@ enum watchpoint_triggered > watch_triggered_yes > }; > > -typedef struct bp_location *bp_location_p; > -DEF_VEC_P(bp_location_p); > - > /* Some targets (e.g., embedded PowerPC) need two debug registers to set > a watchpoint over a memory region. If this flag is true, GDB will use > only one register per watchpoint, thus assuming that all acesses that > -- > 2.13.6 >