serial: fix NULL pointer dereference
[safe/jmp/linux-2.6] / include / linux / tracepoint.h
index 119ece2..f59604e 100644 (file)
@@ -4,7 +4,7 @@
 /*
  * Kernel Tracepoint API.
  *
- * See Documentation/tracepoint.txt.
+ * See Documentation/trace/tracepoints.txt.
  *
  * (C) Copyright 2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
  *
@@ -23,6 +23,8 @@ struct tracepoint;
 struct tracepoint {
        const char *name;               /* Tracepoint name */
        int state;                      /* State. */
+       void (*regfunc)(void);
+       void (*unregfunc)(void);
        void **funcs;
 } __attribute__((aligned(32)));                /*
                                         * Aligned on 32 bytes because it is
@@ -31,8 +33,10 @@ struct tracepoint {
                                         * Keep in sync with vmlinux.lds.h.
                                         */
 
+#ifndef DECLARE_TRACE
+
 #define TP_PROTO(args...)      args
-#define TP_ARGS(args...)               args
+#define TP_ARGS(args...)       args
 
 #ifdef CONFIG_TRACEPOINTS
 
@@ -76,12 +80,16 @@ struct tracepoint {
                return tracepoint_probe_unregister(#name, (void *)probe);\
        }
 
-#define DEFINE_TRACE(name)                                             \
+
+#define DEFINE_TRACE_FN(name, reg, unreg)                              \
        static const char __tpstrtab_##name[]                           \
        __attribute__((section("__tracepoints_strings"))) = #name;      \
        struct tracepoint __tracepoint_##name                           \
        __attribute__((section("__tracepoints"), aligned(32))) =        \
-               { __tpstrtab_##name, 0, NULL }
+               { __tpstrtab_##name, 0, reg, unreg, NULL }
+
+#define DEFINE_TRACE(name)                                             \
+       DEFINE_TRACE_FN(name, NULL, NULL);
 
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)                             \
        EXPORT_SYMBOL_GPL(__tracepoint_##name)
@@ -106,6 +114,7 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
                return -ENOSYS;                                         \
        }
 
+#define DEFINE_TRACE_FN(name, reg, unreg)
 #define DEFINE_TRACE(name)
 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
 #define EXPORT_TRACEPOINT_SYMBOL(name)
@@ -114,6 +123,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
        struct tracepoint *end)
 { }
 #endif /* CONFIG_TRACEPOINTS */
+#endif /* DECLARE_TRACE */
 
 /*
  * Connect a probe to a tracepoint.
@@ -154,10 +164,17 @@ static inline void tracepoint_synchronize_unregister(void)
 }
 
 #define PARAMS(args...) args
-#define TRACE_FORMAT(name, proto, args, fmt)           \
-       DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 
+#endif /* _LINUX_TRACEPOINT_H */
+
+/*
+ * Note: we keep the TRACE_EVENT outside the include file ifdef protection.
+ *  This is due to the way trace events work. If a file includes two
+ *  trace event headers under one "CREATE_TRACE_POINTS" the first include
+ *  will override the TRACE_EVENT and break the second include.
+ */
 
+#ifndef TRACE_EVENT
 /*
  * For use with the TRACE_EVENT macro:
  *
@@ -178,8 +195,8 @@ static inline void tracepoint_synchronize_unregister(void)
  *     * prototype, declare it via TP_PROTO():
  *     *
  *
- *     TP_PROTO(struct rq *rq, struct task_struct *prev,
- *              struct task_struct *next),
+ *     TP_PROTO(struct rq *rq, struct task_struct *prev,
+ *              struct task_struct *next),
  *
  *     *
  *     * Define the call signature of the 'function'.
@@ -187,7 +204,7 @@ static inline void tracepoint_synchronize_unregister(void)
  *     *  TP_PROTO1/TP_PROTO2/TP_PROTO3 ugliness.)
  *     *
  *
- *     TP_ARGS(rq, prev, next),
+ *     TP_ARGS(rq, prev, next),
  *
  *     *
  *     * Fast binary tracing: define the trace record via
@@ -197,7 +214,7 @@ static inline void tracepoint_synchronize_unregister(void)
  *     * This is how the trace record is structured and will
  *     * be saved into the ring buffer. These are the fields
  *     * that will be exposed to user-space in
- *     * /debug/tracing/events/<*>/format.
+ *     * /sys/kernel/debug/tracing/events/<*>/format.
  *     *
  *     * The declared 'local variable' is called '__entry'
  *     *
@@ -229,13 +246,13 @@ static inline void tracepoint_synchronize_unregister(void)
  *     * happens, on an active tracepoint.
  *     *
  *
- *     TP_fast_assign(
- *             memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
- *             __entry->prev_pid       = prev->pid;
- *             __entry->prev_prio      = prev->prio;
+ *     TP_fast_assign(
+ *             memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
+ *             __entry->prev_pid       = prev->pid;
+ *             __entry->prev_prio      = prev->prio;
  *             memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
  *             __entry->next_pid       = next->pid;
- *             __entry->next_prio      = next->prio;
+ *             __entry->next_prio      = next->prio;
  *     )
  *
  *     *
@@ -257,10 +274,22 @@ static inline void tracepoint_synchronize_unregister(void)
  * tracepoint callback (this is used by programmatic plugins and
  * can also by used by generic instrumentation like SystemTap), and
  * it is also used to expose a structured trace record in
- * /debug/tracing/events/.
+ * /sys/kernel/debug/tracing/events/.
+ *
+ * A set of (un)registration functions can be passed to the variant
+ * TRACE_EVENT_FN to perform any (un)registration work.
  */
 
+#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
+#define DEFINE_EVENT(template, name, proto, args)              \
+       DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
+       DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+
 #define TRACE_EVENT(name, proto, args, struct, assign, print)  \
        DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_FN(name, proto, args, struct,              \
+               assign, print, reg, unreg)                      \
+       DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 
-#endif
+#endif /* ifdef TRACE_EVENT (see note above) */