Clarify probe registration documentation/errors
[lttng-ust.git] / include / lttng / ust-tracepoint-event.h
index 28ac8d8075dc71a7518a43148d0bc746a5bd3715..f52ae961d12a3c9187a66d39f56f8c4212f976d1 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <urcu/compiler.h>
 #include <lttng/ust-events.h>
 #include <lttng/ringbuffer-config.h>
@@ -112,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
@@ -496,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,       \
@@ -551,8 +552,19 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
        int ret;
 
-       ret = ltt_probe_register(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
-       assert(!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)();
+       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.024091 seconds and 4 git commands to generate.