lkml.org 
[lkml]   [2009]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/4] tracing: add event trace infrastructure
a very nice infrastructure!

Two comments about format:

Steven Rostedt 写道:
> From: Steven Rostedt <srostedt@redhat.com>
> +#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.

> +#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

--------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); \
}

#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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-02-25 10:11    [W:0.429 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site