Fix: add tracepoint signature at tracepoint definition site
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 1 Mar 2012 20:26:19 +0000 (15:26 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 1 Mar 2012 20:26:19 +0000 (15:26 -0500)
Will enable type-checking between call site and handler.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/tracepoint-types.h
include/lttng/tracepoint.h

index 77e2e25d1621bce2d4dacf2582a47d0f5e18c7a2..9b104b07be6698e927dc4362b200eb99b16d86d7 100644 (file)
@@ -25,6 +25,7 @@ struct tracepoint {
        int state;
        struct tracepoint_probe *probes;
        int *tracepoint_provider_ref;
+       const char *signature;
        char padding[TRACEPOINT_PADDING];
 };
 
index 5fda51f43bb0aa1f1390f8dc6d00f2bf34b5373d..b43f8f98458932e3f0c745e73f246a65717df54a 100644 (file)
@@ -191,10 +191,9 @@ extern struct tracepoint_dlopen tracepoint_dlopen;
  * object from the executable.
  */
 #ifdef TRACEPOINT_PROBE_DYNAMIC_LINKAGE
-#define _TRACEPOINT_UNDEFINED_REF(provider)
+#define _TRACEPOINT_UNDEFINED_REF(provider)    NULL
 #else  /* TRACEPOINT_PROBE_DYNAMIC_LINKAGE */
-#define _TRACEPOINT_UNDEFINED_REF(provider)    \
-       &__tracepoint_provider_##provider,
+#define _TRACEPOINT_UNDEFINED_REF(provider)    &__tracepoint_provider_##provider
 #endif /* TRACEPOINT_PROBE_DYNAMIC_LINKAGE */
 
 /*
@@ -202,17 +201,25 @@ extern struct tracepoint_dlopen tracepoint_dlopen;
  * in the __tracepoints_ptrs section.
  * Therefore, this section is _not_ const (read-only).
  */
-#define _DEFINE_TRACEPOINT(provider, name)                                     \
-       extern int __tracepoint_provider_##provider;                            \
-       static const char __tp_strtab_##provider##___##name[]                   \
+#define _TP_EXTRACT_STRING(...)        #__VA_ARGS__
+
+#define _DEFINE_TRACEPOINT(_provider, _name, _args)                            \
+       extern int __tracepoint_provider_##_provider;                           \
+       static const char __tp_strtab_##_provider##___##_name[]                 \
                __attribute__((section("__tracepoints_strings"))) =             \
-                       #provider ":" #name;                                    \
-       struct tracepoint __tracepoint_##provider##___##name                    \
+                       #_provider ":" #_name;                                  \
+       struct tracepoint __tracepoint_##_provider##___##_name                  \
                __attribute__((section("__tracepoints"))) =                     \
-                       { __tp_strtab_##provider##___##name, 0, NULL, _TRACEPOINT_UNDEFINED_REF(provider) };            \
-       static struct tracepoint * __tracepoint_ptr_##provider##___##name       \
+               {                                                               \
+                       __tp_strtab_##_provider##___##_name,                    \
+                       0,                                                      \
+                       NULL,                                                   \
+                       _TRACEPOINT_UNDEFINED_REF(_provider),                   \
+                       _TP_EXTRACT_STRING(_args),                              \
+               };                                                              \
+       static struct tracepoint * __tracepoint_ptr_##_provider##___##_name     \
                __attribute__((used, section("__tracepoints_ptrs"))) =          \
-                       &__tracepoint_##provider##___##name;
+                       &__tracepoint_##_provider##___##_name;
 
 /*
  * These weak symbols, the constructor, and destructor take care of
@@ -281,7 +288,7 @@ static void __attribute__((destructor)) __tracepoints__destroy(void)
 
 #else /* TRACEPOINT_DEFINE */
 
-#define _DEFINE_TRACEPOINT(provider, name)
+#define _DEFINE_TRACEPOINT(_provider, _name, _args)
 
 #endif /* #else TRACEPOINT_DEFINE */
 
@@ -376,13 +383,13 @@ static void __attribute__((destructor)) __tracepoints__destroy(void)
 
 #define TRACEPOINT_EVENT(provider, name, args, fields)                 \
        _DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args))           \
-       _DEFINE_TRACEPOINT(provider, name)
+       _DEFINE_TRACEPOINT(provider, name, _TP_PARAMS(args))
 
 #define TRACEPOINT_EVENT_CLASS(provider, name, args, fields)
 
 #define TRACEPOINT_EVENT_INSTANCE(provider, _template, name, args)     \
        _DECLARE_TRACEPOINT(provider, name, _TP_PARAMS(args))           \
-       _DEFINE_TRACEPOINT(provider, name)
+       _DEFINE_TRACEPOINT(provider, name, _TP_PARAMS(args))
 
 #endif /* #ifndef TRACEPOINT_EVENT */
 
This page took 0.026666 seconds and 4 git commands to generate.