* [PATCH] Print arrays like Linux does
@ 2024-08-26 21:00 Sean Anderson
2025-10-20 16:17 ` Sean Anderson
0 siblings, 1 reply; 4+ messages in thread
From: Sean Anderson @ 2024-08-26 21:00 UTC (permalink / raw)
To: linux-trace-devel, Steven Rostedt; +Cc: Sean Anderson
In Linux, trace_print_array_seq prints array elements as hexadecimal
numbers, separates them with commas, and surrounds the whole thing with
curly braces. Modify print_str_arg to use the same formatting.
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---
src/event-parse.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/event-parse.c b/src/event-parse.c
index ba4a153..3c6f6f2 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -4938,18 +4938,19 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
len = eval_num_arg(data, size, event, arg->int_array.count);
el_size = eval_num_arg(data, size, event,
arg->int_array.el_size);
+ trace_seq_putc(s, '{');
for (i = 0; i < len; i++) {
if (i)
- trace_seq_putc(s, ' ');
+ trace_seq_putc(s, ',');
if (el_size == 1) {
- trace_seq_printf(s, "%u", *(uint8_t *)num);
+ trace_seq_printf(s, "0x%x", *(uint8_t *)num);
} else if (el_size == 2) {
- trace_seq_printf(s, "%u", *(uint16_t *)num);
+ trace_seq_printf(s, "0x%x", *(uint16_t *)num);
} else if (el_size == 4) {
- trace_seq_printf(s, "%u", *(uint32_t *)num);
+ trace_seq_printf(s, "0x%x", *(uint32_t *)num);
} else if (el_size == 8) {
- trace_seq_printf(s, "%"PRIu64, *(uint64_t *)num);
+ trace_seq_printf(s, "0x%"PRIx64, *(uint64_t *)num);
} else {
trace_seq_printf(s, "BAD SIZE:%d 0x%x",
el_size, *(uint8_t *)num);
@@ -4958,6 +4959,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
num += el_size;
}
+ trace_seq_putc(s, '}');
break;
}
case TEP_PRINT_TYPE:
--
2.35.1.1320.gc452695387.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] Print arrays like Linux does
2024-08-26 21:00 [PATCH] Print arrays like Linux does Sean Anderson
@ 2025-10-20 16:17 ` Sean Anderson
2025-10-20 17:35 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Sean Anderson @ 2025-10-20 16:17 UTC (permalink / raw)
To: linux-trace-devel, Steven Rostedt
On 8/26/24 17:00, Sean Anderson wrote:
> In Linux, trace_print_array_seq prints array elements as hexadecimal
> numbers, separates them with commas, and surrounds the whole thing with
> curly braces. Modify print_str_arg to use the same formatting.
>
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> ---
>
> src/event-parse.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/src/event-parse.c b/src/event-parse.c
> index ba4a153..3c6f6f2 100644
> --- a/src/event-parse.c
> +++ b/src/event-parse.c
> @@ -4938,18 +4938,19 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
> len = eval_num_arg(data, size, event, arg->int_array.count);
> el_size = eval_num_arg(data, size, event,
> arg->int_array.el_size);
> + trace_seq_putc(s, '{');
> for (i = 0; i < len; i++) {
> if (i)
> - trace_seq_putc(s, ' ');
> + trace_seq_putc(s, ',');
>
> if (el_size == 1) {
> - trace_seq_printf(s, "%u", *(uint8_t *)num);
> + trace_seq_printf(s, "0x%x", *(uint8_t *)num);
> } else if (el_size == 2) {
> - trace_seq_printf(s, "%u", *(uint16_t *)num);
> + trace_seq_printf(s, "0x%x", *(uint16_t *)num);
> } else if (el_size == 4) {
> - trace_seq_printf(s, "%u", *(uint32_t *)num);
> + trace_seq_printf(s, "0x%x", *(uint32_t *)num);
> } else if (el_size == 8) {
> - trace_seq_printf(s, "%"PRIu64, *(uint64_t *)num);
> + trace_seq_printf(s, "0x%"PRIx64, *(uint64_t *)num);
> } else {
> trace_seq_printf(s, "BAD SIZE:%d 0x%x",
> el_size, *(uint8_t *)num);
> @@ -4958,6 +4959,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
>
> num += el_size;
> }
> + trace_seq_putc(s, '}');
> break;
> }
> case TEP_PRINT_TYPE:
ping
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Print arrays like Linux does
2025-10-20 16:17 ` Sean Anderson
@ 2025-10-20 17:35 ` Steven Rostedt
2025-10-20 17:38 ` Sean Anderson
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2025-10-20 17:35 UTC (permalink / raw)
To: Sean Anderson; +Cc: linux-trace-devel
On Mon, 20 Oct 2025 12:17:05 -0400
Sean Anderson <sean.anderson@linux.dev> wrote:
> On 8/26/24 17:00, Sean Anderson wrote:
> > In Linux, trace_print_array_seq prints array elements as hexadecimal
> > numbers, separates them with commas, and surrounds the whole thing with
> > curly braces. Modify print_str_arg to use the same formatting.
> >
> > Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> > ---
> >
> > src/event-parse.c | 12 +++++++-----
> > 1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/event-parse.c b/src/event-parse.c
> > index ba4a153..3c6f6f2 100644
> > --- a/src/event-parse.c
> > +++ b/src/event-parse.c
> > @@ -4938,18 +4938,19 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
> > len = eval_num_arg(data, size, event, arg->int_array.count);
> > el_size = eval_num_arg(data, size, event,
> > arg->int_array.el_size);
> > + trace_seq_putc(s, '{');
> > for (i = 0; i < len; i++) {
> > if (i)
> > - trace_seq_putc(s, ' ');
> > + trace_seq_putc(s, ',');
> >
> > if (el_size == 1) {
> > - trace_seq_printf(s, "%u", *(uint8_t *)num);
> > + trace_seq_printf(s, "0x%x", *(uint8_t *)num);
> > } else if (el_size == 2) {
> > - trace_seq_printf(s, "%u", *(uint16_t *)num);
> > + trace_seq_printf(s, "0x%x", *(uint16_t *)num);
> > } else if (el_size == 4) {
> > - trace_seq_printf(s, "%u", *(uint32_t *)num);
> > + trace_seq_printf(s, "0x%x", *(uint32_t *)num);
> > } else if (el_size == 8) {
> > - trace_seq_printf(s, "%"PRIu64, *(uint64_t *)num);
> > + trace_seq_printf(s, "0x%"PRIx64, *(uint64_t *)num);
> > } else {
> > trace_seq_printf(s, "BAD SIZE:%d 0x%x",
> > el_size, *(uint8_t *)num);
> > @@ -4958,6 +4959,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
> >
> > num += el_size;
> > }
> > + trace_seq_putc(s, '}');
> > break;
> > }
> > case TEP_PRINT_TYPE:
>
> ping
It's been accepted:
https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/commit/?id=5f570de85c6b6a391c5e7ffea0b9a54fd8c4b043
I just haven't had time to make a new official release.
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Print arrays like Linux does
2025-10-20 17:35 ` Steven Rostedt
@ 2025-10-20 17:38 ` Sean Anderson
0 siblings, 0 replies; 4+ messages in thread
From: Sean Anderson @ 2025-10-20 17:38 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-trace-devel
On 10/20/25 13:35, Steven Rostedt wrote:
> On Mon, 20 Oct 2025 12:17:05 -0400
> Sean Anderson <sean.anderson@linux.dev> wrote:
>
>> On 8/26/24 17:00, Sean Anderson wrote:
>> > In Linux, trace_print_array_seq prints array elements as hexadecimal
>> > numbers, separates them with commas, and surrounds the whole thing with
>> > curly braces. Modify print_str_arg to use the same formatting.
>> >
>> > Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
>> > ---
>> >
>> > src/event-parse.c | 12 +++++++-----
>> > 1 file changed, 7 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/src/event-parse.c b/src/event-parse.c
>> > index ba4a153..3c6f6f2 100644
>> > --- a/src/event-parse.c
>> > +++ b/src/event-parse.c
>> > @@ -4938,18 +4938,19 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
>> > len = eval_num_arg(data, size, event, arg->int_array.count);
>> > el_size = eval_num_arg(data, size, event,
>> > arg->int_array.el_size);
>> > + trace_seq_putc(s, '{');
>> > for (i = 0; i < len; i++) {
>> > if (i)
>> > - trace_seq_putc(s, ' ');
>> > + trace_seq_putc(s, ',');
>> >
>> > if (el_size == 1) {
>> > - trace_seq_printf(s, "%u", *(uint8_t *)num);
>> > + trace_seq_printf(s, "0x%x", *(uint8_t *)num);
>> > } else if (el_size == 2) {
>> > - trace_seq_printf(s, "%u", *(uint16_t *)num);
>> > + trace_seq_printf(s, "0x%x", *(uint16_t *)num);
>> > } else if (el_size == 4) {
>> > - trace_seq_printf(s, "%u", *(uint32_t *)num);
>> > + trace_seq_printf(s, "0x%x", *(uint32_t *)num);
>> > } else if (el_size == 8) {
>> > - trace_seq_printf(s, "%"PRIu64, *(uint64_t *)num);
>> > + trace_seq_printf(s, "0x%"PRIx64, *(uint64_t *)num);
>> > } else {
>> > trace_seq_printf(s, "BAD SIZE:%d 0x%x",
>> > el_size, *(uint8_t *)num);
>> > @@ -4958,6 +4959,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
>> >
>> > num += el_size;
>> > }
>> > + trace_seq_putc(s, '}');
>> > break;
>> > }
>> > case TEP_PRINT_TYPE:
>>
>> ping
>
> It's been accepted:
>
> https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/commit/?id=5f570de85c6b6a391c5e7ffea0b9a54fd8c4b043
>
> I just haven't had time to make a new official release.
>
> -- Steve
Great thanks. Just wanted to make sure this didn't get lost.
--Sean
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-20 17:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26 21:00 [PATCH] Print arrays like Linux does Sean Anderson
2025-10-20 16:17 ` Sean Anderson
2025-10-20 17:35 ` Steven Rostedt
2025-10-20 17:38 ` Sean Anderson
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).