Re: [PATCH 2/4] tracing: add event trace infrastructure

From: Steven Rostedt
Date: Wed Feb 25 2009 - 08:50:44 EST



On Wed, 25 Feb 2009, Lai Jiangshan wrote:

> a very nice infrastructure!
>
> Two comments about format:
>
> Steven Rostedt ??:
> > From: Steven Rostedt <srostedt@xxxxxxxxxx>
> > +#undef TPFMT
> > +#define TPFMT(fmt, args...) fmt "\n", ##args
>
> Where is other TPFMT's definition?
> I think TPFMT should be defined in tracepoint.h, because trace/<type>.h
> uses it.

I was thinking that. But in may just end up being a nop.

#define TPFMT(fmt, args) /* define me */


>
> > +#define DEFINE_TRACE_FMT(call, proto, args, fmt) \
> > +static void ftrace_event_##call(proto) \
> > +{ \
> > + event_trace_printk(_RET_IP_, "(" #call ") " fmt); \
> > +} \
> > + \
> > +static int ftrace_reg_event_##call(void) \
> > +{ \
> > + int ret; \
> > + \
> > + ret = register_trace_##call(ftrace_event_##call); \
> > + if (!ret) \
> > + pr_info("event trace: Could not activate trace point " \
> > + "probe to " #call); \
> > + return ret; \
> > +} \
> > + \
> > +static void ftrace_unreg_event_##call(void) \
> > +{ \
> > + unregister_trace_##call(ftrace_event_##call); \
> > +} \
> > + \
> > +static struct ftrace_event_call __used \
> > +__attribute__((section("_ftrace_events"))) event_##call = { \
> > + .name = #call, \
> > + .regfunc = ftrace_reg_event_##call, \
> > + .unregfunc = ftrace_unreg_event_##call, \
> > +}
> > +
> > +void event_trace_printk(unsigned long ip, const char *fmt, ...);
>
> add format checking here:
> __attribute__ ((format (printf, 2, 3)))
>
> If user does not use this infrastructure(he uses trace/<type>.h only),
> this checking is not work, so I think we can add format checking
> in DEFINE_TRACE_FMT in tracepoint.h

Darn! You are correct. That was what I forgot to fix since the RFC
announcement. I had that on my TODO list and simply forgot.

Thanks!

>
> --------example:
>
> static inline void __tp_check_format(const char *fmt, ...)
> __attribute__ ((format (printf, 1, 2)));
> static inline void __tp_check_format(const char *fmt, ...) {}
>
> #define DECLARE_TRACE_FORMAT_CHECK(name, proto, fmt, fmt_args...) \
> static inline void ftrace_event_check_format_##name(proto) \
> { \
> __tp_check_format(fmt, ##fmt_args); \

Cool, thanks, I'll add that.

-- Steve

> }
>
> #define DEFINE_TRACE_FMT(name, proto, args, fmt) \
> DECLARE_TRACE_FORMAT_CHECK(name, TPPROTO(proto), fmt) \
> DECLARE_TRACE(name, TPPROTO(proto), TPARGS(args))
>
> ---------
>
> Thanks, Lai
>
>
>
--
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/