[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141208160451.GC4956@e103592.cambridge.arm.com>
Date: Mon, 8 Dec 2014 16:04:52 +0000
From: Dave P Martin <Dave.Martin@....com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Javi Merino <Javi.Merino@....com>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Punit Agrawal <Punit.Agrawal@....com>,
"broonie@...nel.org" <broonie@...nel.org>,
Ingo Molnar <mingo@...hat.com>
Subject: Re: [RFC PATCH v6 1/9] tracing: Add array printing helpers
On Mon, Dec 08, 2014 at 03:42:10PM +0000, Steven Rostedt wrote:
> On Fri, 5 Dec 2014 19:04:12 +0000
> "Javi Merino" <javi.merino@....com> wrote:
[...]
> > +
> > +DEFINE_PRINT_ARRAY(u8, unsigned int, "0x%x");
> > +DEFINE_PRINT_ARRAY(u16, unsigned int, "0x%x");
> > +DEFINE_PRINT_ARRAY(u32, unsigned int, "0x%x");
> > +DEFINE_PRINT_ARRAY(u64, unsigned long long, "0x%llx");
> > +
>
> I would really like to avoid adding a bunch of macros for each type.
> Can't we have something like this:
> ftrace_print_array(struct trace_seq *p, void *buf, int buf_len,
> int size)
> {
> char *prefix = "";
> void *ptr = buf;
>
> while (ptr < buf + buf_len) {
> switch(size) {
> case 8:
> trace_seq_printf("%s0x%x", prefix,
> *(unsigned char *)ptr);
I think this should be *(u8 *) etc.
Otherwise, I don't have a problem with this approach. It's less
ugly than my original.
> break;
> case 16:
> trace_seq_printf("%s0x%x", prefix,
> *(unsigned short *)ptr);
> break;
> case 32:
> trace_seq_printf("%s0x%x", prefix,
> *(unsigned int *)ptr);
> break;
> case 64:
> trace_seq_printf("%s0x%llx", prefix,
> *(unsigned long long *)ptr);
> break;
> default:
> BUG();
> }
> prefix = ",";
> ptr += size;
> }
>
> }
>
> We probably could even make the "BUG()" into a build bug, with a little
> work.
That sounds possible.
Javi?
Cheers
---Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists