Tracepoints: add wrapper tracepoint() macro
[ust.git] / include / ust / ust_trace.h
index 098c5f8f6f0230e31b28bb157b34e7e0d4ffee68..21c941a641cb02426ef6616c6bf7135902aaa562 100644 (file)
@@ -23,6 +23,8 @@
  * to a printf
  */
 
+#include <stdio.h>
+
 /*
  * Stage 1. Create a struct and a printf calling function
  * that is connected to the tracepoint at load time.
@@ -58,7 +60,7 @@
        struct trace_raw_##name {                                       \
                tstruct                                                 \
        };                                                              \
-       static void trace_printf_##name(proto)                          \
+       static void trace_printf_##name(void *dummy, proto)             \
        {                                                               \
                struct trace_raw_##name entry_struct, *__entry;         \
                __entry = &entry_struct;                                \
                                                                        \
                printf(print);                                          \
        }                                                               \
+       static inline int register_event_##name(void *data)             \
+       {                                                               \
+               return register_tracepoint(name, trace_printf_##name, data); \
+       }                                                               \
+       static inline int unregister_event_##name(void *data)           \
+       {                                                               \
+               return unregister_tracepoint(name, trace_printf_##name, data); \
+       }                                                               \
+       struct trace_event __event_##name = {                           \
+               __tpstrtab_##name,                                      \
+               register_event_##name,                                  \
+               unregister_event_##name                                 \
+       };                                                              \
+       static struct trace_event * const __event_ptrs_##name           \
+       __attribute__((used, section("__trace_events_ptrs"))) =         \
+               &__event_##name;                                        \
+                                                                       \
        static void __attribute__((constructor)) init_##name()          \
        {                                                               \
-               printf("connecting tracepoint " #name "\n");            \
-               register_trace_##name(trace_printf_##name);             \
+               void *dummy = NULL;                                     \
+               register_tracepoint(name, trace_printf_##name, dummy);  \
        }
 
 
This page took 0.024408 seconds and 4 git commands to generate.