From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2032 invoked by alias); 17 Feb 2017 13:27:30 -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 1948 invoked by uid 89); 17 Feb 2017 13:27:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 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: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Feb 2017 13:27:19 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2017 05:27:12 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 17 Feb 2017 05:27:11 -0800 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 v1HDRA7q001633; Fri, 17 Feb 2017 13:27:11 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id v1HDRAMd006701; Fri, 17 Feb 2017 14:27:10 +0100 Received: (from twiederh@localhost) by ulvlx001.iul.intel.com with œ id v1HDRAri006697; Fri, 17 Feb 2017 14:27:10 +0100 From: Tim Wiederhake To: gdb-patches@sourceware.org Cc: markus.t.metzger@intel.com Subject: [PATCH 11/11] [SQUASH] btrace: Cleanup. Date: Fri, 17 Feb 2017 13:27:00 -0000 Message-Id: <1487337989-6367-12-git-send-email-tim.wiederhake@intel.com> In-Reply-To: <1487337989-6367-1-git-send-email-tim.wiederhake@intel.com> References: <1487337989-6367-1-git-send-email-tim.wiederhake@intel.com> X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00491.txt.bz2 This patch stands alone for easier review and is meant to be squashed together for committing. ChangeLog will be added to the squashed commit. 2017-02-17 Tim Wiederhake --- gdb/btrace.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index 859c87f..aa6959d 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -218,31 +218,28 @@ ftrace_new_function (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, struct symbol *fun) { - struct btrace_function *prev = NULL, *bfun; + struct btrace_function bfun; - if (!VEC_empty (btrace_fun_s, btinfo->functions)) - prev = VEC_last (btrace_fun_s, btinfo->functions); - - bfun = VEC_safe_push (btrace_fun_s, btinfo->functions, NULL); - memset (bfun, 0, sizeof (*bfun)); + memset (&bfun, 0, sizeof (bfun)); + bfun.msym = mfun; + bfun.sym = fun; - bfun->msym = mfun; - bfun->sym = fun; - - if (prev == NULL) + if (VEC_empty (btrace_fun_s, btinfo->functions)) { /* Start counting at one. */ - bfun->number = 1; - bfun->insn_offset = 1; + bfun.number = 1; + bfun.insn_offset = 1; } else { - bfun->number = prev->number + 1; - bfun->insn_offset = prev->insn_offset + ftrace_call_num_insn (prev); - bfun->level = prev->level; + struct btrace_function *prev = VEC_last (btrace_fun_s, btinfo->functions); + + bfun.number = prev->number + 1; + bfun.insn_offset = prev->insn_offset + ftrace_call_num_insn (prev); + bfun.level = prev->level; } - return bfun; + return VEC_safe_push (btrace_fun_s, btinfo->functions, &bfun); } /* Update the UP field of a function segment. */ @@ -1496,10 +1493,6 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf) DEBUG ("enable thread %s (%s)", print_thread_id (tp), target_pid_to_str (tp->ptid)); - /* Temporarily prevent resizing the vector until reworking struct - btrace_function is complete. */ - VEC_reserve (btrace_fun_s, tp->btrace.functions, 1000000); - tp->btrace.target = target_enable_btrace (tp->ptid, conf); /* We're done if we failed to enable tracing. */ @@ -1816,11 +1809,6 @@ btrace_fetch (struct thread_info *tp) /* We should not be called on running or exited threads. */ gdb_assert (can_access_registers_ptid (tp->ptid)); - /* Temporarily prevent resizing the vector until reworking struct - btrace_function is complete. */ - if (btinfo->functions == NULL) - VEC_reserve (btrace_fun_s, btinfo->functions, 1000000); - btrace_data_init (&btrace); cleanup = make_cleanup_btrace_data (&btrace); -- 2.7.4