* [PATCH] libtraceevent: Use BTF_INT_BITS/OFFSET() when parsing int parameters
@ 2025-11-14 19:09 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2025-11-14 19:09 UTC (permalink / raw)
To: Linux Trace Devel; +Cc: Douglas Raillard
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-14 19:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 19:09 [PATCH] libtraceevent: Use BTF_INT_BITS/OFFSET() when parsing int parameters Steven Rostedt
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).