Fix: perform macro expansion on tracepoint signatures
[lttng-ust.git] / include / lttng / ust-tracepoint-event.h
index 49cac590d421a689ab33855c6ebf63e22c863e99..c2e951928ce99bab360dfa7a52f813993e90b46f 100644 (file)
@@ -1,14 +1,15 @@
 /*
- * 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>
@@ -76,7 +77,7 @@
                         _TP_PARAMS(_args),                     \
                         _TP_PARAMS(_fields))                   \
        TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name,      \
-                        _TP_PARAMS(args))
+                        _TP_PARAMS(_args))
 
 /* Helpers */
 #define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -433,6 +434,29 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
 
 #undef __get_dynamic_len
 
+/*
+ * Stage 5.1 of tracepoint event generation.
+ *
+ * Create probe signature
+ */
+
+/* Reset all macros within TRACEPOINT_EVENT */
+#include <lttng/ust-tracepoint-event-reset.h>
+
+#undef TP_ARGS
+#define TP_ARGS(args...) 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[] =          \
+               _TP_EXTRACT_STRING2(_args);
+
+#include TRACEPOINT_INCLUDE
+
+#undef _TP_EXTRACT_STRING2
+
 /*
  * Stage 6 of tracepoint event generation.
  *
@@ -446,8 +470,10 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
 #include <lttng/ust-tracepoint-event-reset.h>
 
 #undef TRACEPOINT_LOGLEVEL
-#define TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel)            \
-static const int _loglevel___##__provider##___##__name = __loglevel;
+#define TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel)               \
+static const int _loglevel_value___##__provider##___##__name = __loglevel; \
+static const int *_loglevel___##__provider##___##__name =                 \
+               &_loglevel_value___##__provider##___##__name;
 
 #include TRACEPOINT_INCLUDE
 
@@ -473,6 +499,7 @@ const struct lttng_event_desc __event_desc___##_provider##_##_name = {             \
        .probe_callback = (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,       \
 };
 
 #include TRACEPOINT_INCLUDE
@@ -512,11 +539,13 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
  * Stage 9 of tracepoint event generation.
  *
  * Register/unregister probes at module load/unload.
+ *
+ * Generate the constructor as an externally visible symbol for use when
+ * linking the probe statically.
  */
 
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
-
 static void __attribute__((constructor))
 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
@@ -531,3 +560,5 @@ _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
 {
        ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
 }
+
+int _TP_COMBINE_TOKENS(__tracepoint_provider_, TRACEPOINT_PROVIDER);
This page took 0.023785 seconds and 4 git commands to generate.