From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Cc: Douglas Raillard <douglas.raillard@arm.com>
Subject: [PATCH] libtraceevent: Use BTF_INT_BITS/OFFSET() when parsing int parameters
Date: Fri, 14 Nov 2025 14:09:25 -0500 [thread overview]
Message-ID: <20251114140925.3df4f3ff@gandalf.local.home> (raw)
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
The BTF_KIND_INT can be less than 64 bits in size and the
BTF_INT_BITS(encode) will express that.
Also process BTF_INT_OFFSET() even though it is likely to be zero every
time, but it follows the specification.
Link: https://lore.kernel.org/all/82376535-30a5-4602-aac7-1bd3abcd271a@arm.com/
Suggested-by: Douglas Raillard <douglas.raillard@arm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
src/trace-btf.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/trace-btf.c b/src/trace-btf.c
index 742cffd35edc..d0231b49d144 100644
--- a/src/trace-btf.c
+++ b/src/trace-btf.c
@@ -413,6 +413,8 @@ int tep_btf_print_args(struct tep_handle *tep, struct trace_seq *s, void *args,
for (a = 0, p = 0; p < nr; a++, p++) {
struct btf_type *t;
+ int offset;
+ int bits;
if (p)
trace_seq_puts(s, ", ");
@@ -440,6 +442,11 @@ int tep_btf_print_args(struct tep_handle *tep, struct trace_seq *s, void *args,
break;
case BTF_KIND_INT:
encode = *(int *)((void *)t + sizeof(*t));
+ bits = BTF_INT_BITS(encode);
+ offset = BTF_INT_OFFSET(encode);
+ arg >>= offset;
+ if (bits < 64)
+ arg &= (1ULL << bits) - 1;
/* Print unsigned ints as hex */
if (BTF_INT_ENCODING(encode) & BTF_INT_SIGNED)
trace_seq_printf(s, "%lld", arg);
--
2.51.0
reply other threads:[~2025-11-14 19:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20251114140925.3df4f3ff@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=douglas.raillard@arm.com \
--cc=linux-trace-devel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).