From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63225 invoked by alias); 28 Apr 2017 14:44:22 -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 62022 invoked by uid 89); 28 Apr 2017 14:44:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.5 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=**end, H*r:sk:mmetzge X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Apr 2017 14:44:20 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Apr 2017 07:44:21 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 28 Apr 2017 07:44:19 -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 v3SEiJT3026602; Fri, 28 Apr 2017 15:44:19 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id v3SEiIT5022623; Fri, 28 Apr 2017 16:44:18 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id v3SEiIcj022619; Fri, 28 Apr 2017 16:44:18 +0200 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 1/3] btrace: work directly on begin and end pointers Date: Fri, 28 Apr 2017 14:44:00 -0000 Message-Id: <1493390658-22342-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00780.txt.bz2 In ftrace_add_pt, we store copies of *PBEGIN and *PEND in local variables BEGIN and END respectively. The intent was to help the compiler figure out that BEGIN and END are not changed over external function calls. This is still true for most calls, yet if we want to allow changing *PBEGIN and *PEND inside a function, we'd have to reload BEGIN and END after that call. Stop using local copies to avoid that complication. 2017-04-28 Markus Metzger gdb/ * btrace.c (ftrace_add_pt): Rename arguments PBEGIN and PEND into BEGIN and END. Use them directly. --- gdb/btrace.c | 53 +++++++++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index 238df0a..6780e22 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1137,16 +1137,13 @@ pt_btrace_insn (const struct pt_insn &insn) static void ftrace_add_pt (struct pt_insn_decoder *decoder, - struct btrace_function **pbegin, - struct btrace_function **pend, int *plevel, + struct btrace_function **begin, + struct btrace_function **end, int *plevel, VEC (bfun_s) **gaps) { - struct btrace_function *begin, *end, *upd; uint64_t offset; int errcode; - begin = *pbegin; - end = *pend; for (;;) { struct pt_insn insn; @@ -1167,7 +1164,7 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, break; /* Look for gaps in the trace - unless we're at the beginning. */ - if (begin != NULL) + if (*begin != NULL) { /* Tracing is disabled and re-enabled each time we enter the kernel. Most times, we continue from the same instruction we @@ -1176,65 +1173,61 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, from some other instruction. Indicate this as a trace gap. */ if (insn.enabled) { - *pend = end = ftrace_new_gap (end, BDE_PT_DISABLED); + *end = ftrace_new_gap (*end, BDE_PT_DISABLED); - VEC_safe_push (bfun_s, *gaps, end); + VEC_safe_push (bfun_s, *gaps, *end); pt_insn_get_offset (decoder, &offset); warning (_("Non-contiguous trace at instruction %u (offset " "= 0x%" PRIx64 ", pc = 0x%" PRIx64 ")."), - end->insn_offset - 1, offset, insn.ip); + (*end)->insn_offset - 1, offset, insn.ip); } } /* Indicate trace overflows. */ if (insn.resynced) { - *pend = end = ftrace_new_gap (end, BDE_PT_OVERFLOW); - if (begin == NULL) - *pbegin = begin = end; + *end = ftrace_new_gap (*end, BDE_PT_OVERFLOW); + if (*begin == NULL) + *begin = *end; - VEC_safe_push (bfun_s, *gaps, end); + VEC_safe_push (bfun_s, *gaps, *end); pt_insn_get_offset (decoder, &offset); warning (_("Overflow at instruction %u (offset = 0x%" PRIx64 - ", pc = 0x%" PRIx64 ")."), end->insn_offset - 1, + ", pc = 0x%" PRIx64 ")."), (*end)->insn_offset - 1, offset, insn.ip); } - upd = ftrace_update_function (end, insn.ip); - if (upd != end) - { - *pend = end = upd; - - if (begin == NULL) - *pbegin = begin = upd; - } + *end = ftrace_update_function (*end, insn.ip); + if (*begin == NULL) + *begin = *end; /* Maintain the function level offset. */ - *plevel = std::min (*plevel, end->level); + *plevel = std::min (*plevel, (*end)->level); btrace_insn btinsn = pt_btrace_insn (insn); - ftrace_update_insns (end, &btinsn); + ftrace_update_insns (*end, &btinsn); } if (errcode == -pte_eos) break; /* Indicate the gap in the trace. */ - *pend = end = ftrace_new_gap (end, errcode); - if (begin == NULL) - *pbegin = begin = end; + *end = ftrace_new_gap (*end, errcode); + if (*begin == NULL) + *begin = *end; - VEC_safe_push (bfun_s, *gaps, end); + VEC_safe_push (bfun_s, *gaps, *end); pt_insn_get_offset (decoder, &offset); warning (_("Decode error (%d) at instruction %u (offset = 0x%" PRIx64 - ", pc = 0x%" PRIx64 "): %s."), errcode, end->insn_offset - 1, - offset, insn.ip, pt_errstr (pt_errcode (errcode))); + ", pc = 0x%" PRIx64 "): %s."), errcode, + (*end)->insn_offset - 1, offset, insn.ip, + pt_errstr (pt_errcode (errcode))); } } -- 1.8.3.1