Fix bug introduced by backport of "Clarify probe registration documentation/errors"
[lttng-ust.git] / include / lttng / ust-tracepoint-event.h
index 1dffd94635364f84a5f7b9bdd9a28036403aa1fa..679faf645fb9a531a18964d90dd7591fd9c72dad 100644 (file)
@@ -1,17 +1,19 @@
 /*
- * Copyright (c) 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Permission is hereby granted to use or copy this program
- * for any purpose,  provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <urcu/compiler.h>
 #include <lttng/ust-events.h>
 #include <lttng/ringbuffer-config.h>
@@ -111,7 +113,7 @@ void _TP_COMBINE_TOKENS(__tracepoint_provider_mismatch_, TRACEPOINT_PROVIDER)(vo
 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)  \
        __tracepoint_provider_mismatch_##_provider();
 
-static __attribute__((unused))
+static inline
 void _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(void)
 {
 #include TRACEPOINT_INCLUDE
@@ -203,7 +205,7 @@ static const char                                                   \
        },
 
 #undef TP_FIELDS
-#define TP_FIELDS(args...) args        /* Only one used in this phase */
+#define TP_FIELDS(...) __VA_ARGS__     /* Only one used in this phase */
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)                            \
@@ -223,7 +225,7 @@ static const char                                                   \
 #include <lttng/ust-tracepoint-event-reset.h>
 
 #undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)               \
@@ -270,10 +272,10 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
        __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
 
 #undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
 
 #undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
@@ -321,10 +323,10 @@ static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic
 #define ctf_string(_item, _src)
 
 #undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
 
 #undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
@@ -392,10 +394,10 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 #define __get_dynamic_len(field)       __dynamic_len[__dynamic_len_idx++]
 
 #undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
 
 #undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
@@ -443,15 +445,19 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
 #include <lttng/ust-tracepoint-event-reset.h>
 
 #undef TP_ARGS
-#define TP_ARGS(args...) #args
+#define TP_ARGS(...) __VA_ARGS__
+
+#define _TP_EXTRACT_STRING2(...)       #__VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)       \
 const char __tp_event_signature___##_provider##___##_name[] =          \
-               _args;
+               _TP_EXTRACT_STRING2(_args);
 
 #include TRACEPOINT_INCLUDE
 
+#undef _TP_EXTRACT_STRING2
+
 /*
  * Stage 6 of tracepoint event generation.
  *
@@ -491,7 +497,7 @@ static const int *                                                         \
 const struct lttng_event_desc __event_desc___##_provider##_##_name = {        \
        .fields = __event_fields___##_provider##___##_template,                \
        .name = #_provider ":" #_name,                                         \
-       .probe_callback = (void *) &__event_probe__##_provider##___##_template,\
+       .probe_callback = (void (*)(void)) &__event_probe__##_provider##___##_template,\
        .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \
        .loglevel = &__ref_loglevel___##_provider##___##_name,                 \
        .signature = __tp_event_signature___##_provider##___##_template,       \
@@ -546,8 +552,20 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
        int ret;
 
+       /*
+        * __tracepoint_provider_check_ ## TRACEPOINT_PROVIDER() is a
+        * static inline function that ensures every probe PROVIDER
+        * argument match the provider within which they appear. It
+        * calls empty static inline functions, and therefore has no
+        * runtime effect. However, if it detects an error, a linker
+        * error will appear.
+        */
+       _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)();
        ret = ltt_probe_register(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
-       assert(!ret);
+       if (ret) {
+               fprintf(stderr, "LTTng-UST: Error (%d) while registering tracepoint probe. Duplicate registration of tracepoint probes having the same name is not allowed.\n", ret);
+               abort();
+       }
 }
 
 static void __attribute__((destructor))
This page took 0.025946 seconds and 4 git commands to generate.