From: Markus Metzger <markus.t.metzger@intel.com>
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 [thread overview]
Message-ID: <1493390658-22342-1-git-send-email-markus.t.metzger@intel.com> (raw)
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 <markus.t.metzger@intel.com>
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
next reply other threads:[~2017-04-28 14:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-28 14:44 Markus Metzger [this message]
2017-04-28 14:44 ` [PATCH 3/3] btrace: support decoder events Markus Metzger
2017-05-23 14:11 ` Metzger, Markus T
2017-05-23 21:56 ` Pedro Alves
2017-04-28 14:44 ` [PATCH 2/3] config, btrace: check for pt_insn_event in libipt Markus Metzger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493390658-22342-1-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox