Re: [RFC PATCH 0/2] libtraceevent/perf: Add support for trace-cmdplugins

From: Steven Rostedt
Date: Tue Jun 19 2012 - 07:54:38 EST


On Tue, 2012-06-19 at 14:41 +0900, Namhyung Kim wrote:
> On Mon, 18 Jun 2012 22:16:11 -0400, Steven Rostedt wrote:
> > We can be a bit better at the raw print, sure. Here's the format that's
> > there:
> >
> > field:__u64 rip; offset:16; size:8; signed:0;
> > field:__u32 csbase; offset:24; size:4; signed:0;
> > field:__u8 len; offset:28; size:1; signed:0;
> > field:__u8 insn[15]; offset:29; size:15; signed:0;
> > field:__u8 flags; offset:44; size:1; signed:0;
> > field:__u8 failed; offset:45; size:1; signed:0;
> >
> > It treated __u* as decimal numbers, but it also saw that insn[15] was an
> > array, and with single bytes at that. So it thought it was a string, and
> > tried to print it out as such.
> >
> > We can change the heuristics of this to make it more readable.
> >
>
> Right. The current heuristic treats an u8 array as a string:
>
> static int field_is_string(struct format_field *field)
> {
> if ((field->flags & FIELD_IS_ARRAY) &&
> (strstr(field->type, "char") || strstr(field->type, "u8") ||
> strstr(field->type, "s8")))
> return 1;
>
> return 0;
> }
>
> Do you want to get rid of u8 from the function? Or is there a
> better way?
>

We could simply check if all the characters in the array passes
'isprint()' and if it does then print the string, otherwise print the
hex. Do this for all events, and if it one fails, then mark it always to
print hex.

-- Steve


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/