From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97447 invoked by alias); 10 May 2017 11:47:58 -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 97410 invoked by uid 89); 10 May 2017 11:47:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga06.intel.com Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 May 2017 11:47:55 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP; 10 May 2017 04:47:56 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 10 May 2017 04:47:55 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id v4ABltcC018123; Wed, 10 May 2017 12:47:55 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id v4ABlsBZ019855; Wed, 10 May 2017 13:47:54 +0200 Received: (from twiederh@localhost) by ulvlx001.iul.intel.com with œ id v4ABlsAB019851; Wed, 10 May 2017 13:47:54 +0200 From: Tim Wiederhake To: gdb-patches@sourceware.org Cc: markus.t.metzger@intel.com, simon.marchi@polymtl.ca Subject: [PATCH v4 01/12] btrace: Use std::vector in struct btrace_thread_information. Date: Wed, 10 May 2017 11:48:00 -0000 Message-Id: <1494416867-19612-2-git-send-email-tim.wiederhake@intel.com> In-Reply-To: <1494416867-19612-1-git-send-email-tim.wiederhake@intel.com> References: <1494416867-19612-1-git-send-email-tim.wiederhake@intel.com> X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00263.txt.bz2 2017-05-10 Tim Wiederhake gdb/ChangeLog: * btrace.c (btrace_fetch, btrace_clear, btrace_find_insn_by_number): Replace VEC_* with std::vector functions. * btrace.h: Add include: vector. Remove typedef for DEF_VEC_P. (struct btrace_thread_info): Change type to std::vector. --- gdb/btrace.c | 17 ++++++++--------- gdb/btrace.h | 7 +++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index 20c977a..46a4d8d 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1857,12 +1857,12 @@ btrace_fetch (struct thread_info *tp) btrace_data_append (&btinfo->data, &btrace); btrace_maint_clear (btinfo); - VEC_truncate (btrace_fun_p, btinfo->functions, 0); + btinfo->functions.clear (); btrace_clear_history (btinfo); btrace_compute_ftrace (tp, &btrace); for (bfun = btinfo->begin; bfun != NULL; bfun = bfun->flow.next) - VEC_safe_push (btrace_fun_p, btinfo->functions, bfun); + btinfo->functions.push_back (bfun); } do_cleanups (cleanup); @@ -1884,8 +1884,7 @@ btrace_clear (struct thread_info *tp) reinit_frame_cache (); btinfo = &tp->btrace; - - VEC_free (btrace_fun_p, btinfo->functions); + btinfo->functions.clear (); it = btinfo->begin; while (it != NULL) @@ -2480,16 +2479,16 @@ btrace_find_insn_by_number (struct btrace_insn_iterator *it, const struct btrace_function *bfun; unsigned int upper, lower; - if (VEC_empty (btrace_fun_p, btinfo->functions)) + if (btinfo->functions.empty ()) return 0; lower = 0; - bfun = VEC_index (btrace_fun_p, btinfo->functions, lower); + bfun = btinfo->functions[lower]; if (number < bfun->insn_offset) return 0; - upper = VEC_length (btrace_fun_p, btinfo->functions) - 1; - bfun = VEC_index (btrace_fun_p, btinfo->functions, upper); + upper = btinfo->functions.size () - 1; + bfun = btinfo->functions[upper]; if (number >= bfun->insn_offset + ftrace_call_num_insn (bfun)) return 0; @@ -2498,7 +2497,7 @@ btrace_find_insn_by_number (struct btrace_insn_iterator *it, { const unsigned int average = lower + (upper - lower) / 2; - bfun = VEC_index (btrace_fun_p, btinfo->functions, average); + bfun = btinfo->functions[average]; if (number < bfun->insn_offset) { diff --git a/gdb/btrace.h b/gdb/btrace.h index 07ed10c..ab739ec 100644 --- a/gdb/btrace.h +++ b/gdb/btrace.h @@ -34,6 +34,8 @@ # include #endif +#include + struct thread_info; struct btrace_function; @@ -187,9 +189,6 @@ struct btrace_function btrace_function_flags flags; }; -typedef struct btrace_function *btrace_fun_p; -DEF_VEC_P (btrace_fun_p); - /* A branch trace instruction iterator. */ struct btrace_insn_iterator { @@ -342,7 +341,7 @@ struct btrace_thread_info /* Vector of pointer to decoded function segments. These are in execution order with the first element == BEGIN and the last element == END. */ - VEC (btrace_fun_p) *functions; + std::vector functions; /* The function level offset. When added to each function's LEVEL, this normalizes the function levels such that the smallest level -- 2.7.4