From patchwork Sat Apr 27 14:31:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32436 Received: (qmail 24060 invoked by alias); 27 Apr 2019 14:31:40 -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 23988 invoked by uid 89); 27 Apr 2019 14:31:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.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.1 spammy=vec_safe_push X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.47.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 27 Apr 2019 14:31:38 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway23.websitewelcome.com (Postfix) with ESMTP id A9A6ECC0B for ; Sat, 27 Apr 2019 09:31:37 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id KOMbhdutMiQerKOMbhKNl0; Sat, 27 Apr 2019 09:31:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bSKie1iAhtpVIiH8kxSIPNHGdByrnfHJ99zlyCfD9Tk=; b=NNIt1rigpGC4CwUIyxhe6gvQZ/ H3w+BPni/YnoDlZGD31khp42RX8CjRCpsgNSLiwTufcQmDoM6yQn++e9Pt7g8+qX24z+Dm1ZW5Eu/ GHoKjSYzZS3Oi35oC/gTe70OO; Received: from 97-122-168-123.hlrn.qwest.net ([97.122.168.123]:49568 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hKOMb-0011yo-FS; Sat, 27 Apr 2019 09:31:37 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/2] Remove a VEC from ppc-linux-nat.c Date: Sat, 27 Apr 2019 08:31:33 -0600 Message-Id: <20190427143134.14048-2-tom@tromey.com> In-Reply-To: <20190427143134.14048-1-tom@tromey.com> References: <20190427143134.14048-1-tom@tromey.com> This replaces a VEC in ppc-linux-nat.c with a std::vector. gdb/ChangeLog 2019-04-27 Tom Tromey * ppc-linux-nat.c (thread_points_p): Remove typedef and DEF_VEC. (ppc_threads): Now a std::vector. Now static. (hwdebug_find_thread_points_by_tid) (ppc_linux_nat_target::low_new_thread, ppc_linux_thread_exit): Update. --- gdb/ChangeLog | 8 ++++++++ gdb/ppc-linux-nat.c | 30 +++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 628e3d5e8f6..45cf594ffca 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -1578,7 +1578,7 @@ struct hw_break_tuple /* This is an internal VEC created to store information about *points inserted for each thread. This is used when PowerPC HWDEBUG ptrace interface is available. */ -typedef struct thread_points +struct thread_points { /* The TID to which this *point relates. */ int tid; @@ -1589,10 +1589,9 @@ typedef struct thread_points size of these vector is MAX_SLOTS_NUMBER. If the hw_break element of the tuple is NULL, then the position in the vector is free. */ struct hw_break_tuple *hw_breaks; - } *thread_points_p; -DEF_VEC_P (thread_points_p); + }; -VEC(thread_points_p) *ppc_threads = NULL; +static std::vector ppc_threads; /* The version of the PowerPC HWDEBUG kernel interface that we will use, if available. */ @@ -1758,14 +1757,11 @@ hwdebug_point_cmp (struct ppc_hw_breakpoint *a, struct ppc_hw_breakpoint *b) static struct thread_points * hwdebug_find_thread_points_by_tid (int tid, int alloc_new) { - int i; - struct thread_points *t; - - for (i = 0; VEC_iterate (thread_points_p, ppc_threads, i, t); i++) + for (thread_points *t : ppc_threads) if (t->tid == tid) return t; - t = NULL; + struct thread_points *t = NULL; /* Do we need to allocate a new point_item if the wanted one does not exist? */ @@ -1774,7 +1770,7 @@ hwdebug_find_thread_points_by_tid (int tid, int alloc_new) t = XNEW (struct thread_points); t->hw_breaks = XCNEWVEC (struct hw_break_tuple, max_slots_number); t->tid = tid; - VEC_safe_push (thread_points_p, ppc_threads, t); + ppc_threads.push_back (t); } return t; @@ -2359,11 +2355,11 @@ ppc_linux_nat_target::low_new_thread (struct lwp_info *lp) struct thread_points *p; struct hw_break_tuple *hw_breaks; - if (VEC_empty (thread_points_p, ppc_threads)) + if (ppc_threads.empty ()) return; /* Get a list of breakpoints from any thread. */ - p = VEC_last (thread_points_p, ppc_threads); + p = ppc_threads.last (); hw_breaks = p->hw_breaks; /* Copy that thread's breakpoints and watchpoints to the new thread. */ @@ -2392,22 +2388,22 @@ ppc_linux_thread_exit (struct thread_info *tp, int silent) int i; int tid = tp->ptid.lwp (); struct hw_break_tuple *hw_breaks; - struct thread_points *t = NULL, *p; + struct thread_points *t = NULL; if (!have_ptrace_hwdebug_interface ()) return; - for (i = 0; VEC_iterate (thread_points_p, ppc_threads, i, p); i++) - if (p->tid == tid) + for (i = 0; i < ppc_threads.size (); i++) + if (ppc_threads[i].tid == tid) { - t = p; + t = &ppc_threads[i]; break; } if (t == NULL) return; - VEC_unordered_remove (thread_points_p, ppc_threads, i); + unordered_remove (ppc_threads, i); hw_breaks = t->hw_breaks;