Fix: ust-tracepoint: make sure to expand tracepoint provider token
authorChristophe Bedard <bedard.christophe@gmail.com>
Sun, 21 Jun 2020 17:54:30 +0000 (13:54 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 10 Dec 2020 14:04:25 +0000 (09:04 -0500)
Using a #defined TRACEPOINT_PROVIDER with the
TRACEPOINT_EVENT_{CLASS,INSTANCE}() macros led to compilation errors,
e.g.:

gcc -I/home/chris/lttng-mwe/app/../lib -c myapp.c
gcc -o myapp myapp.o -L/home/chris/lttng-mwe/app/../lib -Wl,-rpath=/home/chris/lttng-mwe/app/../lib -lmytps -ldl
/usr/bin/ld: /home/chris/lttng-mwe/app/../lib/libmytps.so: undefined reference to `__tracepoint_provider_mismatch_TRACEPOINT_PROVIDER'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: myapp] Error 1

Use intermediate TRACEPOINT_EVENT_{CLASS,INSTANCE}() macros to make sure
that the tracepoint provider name token gets expanded.

Fixes: #1273
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I68550a510c809f1d5f86a7e1d966dcecc3780dda

include/lttng/ust-tracepoint-event-reset.h
include/lttng/ust-tracepoint-event.h

index 47bb5a8d38fe700f8f0eac2ca0cb669c61c00445..4467d267c72b55483a9cfb5b6082d4d2f60463b9 100644 (file)
 
 /* Define to "nothing" all macros used for TRACEPOINT_EVENT */
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)
 
-#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)
+#undef _TRACEPOINT_EVENT_INSTANCE
+#define _TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)
 
 #undef TRACEPOINT_ENUM
 #define TRACEPOINT_ENUM(_provider, _name, _values)
index 7890c247453e93c0c4b0ee9038ce6531b1a49757..63b3bd499085433552432dd9a2c396cfa6bfdf00 100644 (file)
 
 #undef TRACEPOINT_EVENT
 #define TRACEPOINT_EVENT(_provider, _name, _args, _fields)     \
-       TRACEPOINT_EVENT_CLASS(_provider, _name,                \
+       _TRACEPOINT_EVENT_CLASS(_provider, _name,               \
                         _TP_PARAMS(_args),                     \
                         _TP_PARAMS(_fields))                   \
-       TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name,      \
+       _TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name,     \
                         _TP_PARAMS(_args))
 
+#undef TRACEPOINT_EVENT_CLASS
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)               \
+       _TRACEPOINT_EVENT_CLASS(_provider, _name, _TP_PARAMS(_args), _TP_PARAMS(_fields))
+
+#undef TRACEPOINT_EVENT_INSTANCE
+#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)  \
+       _TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _TP_PARAMS(_args))
+
 /* Helpers */
 #define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
@@ -85,12 +93,12 @@ void _TP_COMBINE_TOKENS(__tracepoint_provider_mismatch_, TRACEPOINT_PROVIDER)(vo
 {
 }
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)       \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
        __tracepoint_provider_mismatch_##_provider();
 
-#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)  \
+#undef _TRACEPOINT_EVENT_INSTANCE
+#define _TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
        __tracepoint_provider_mismatch_##_provider();
 
 static inline lttng_ust_notrace
@@ -111,8 +119,8 @@ void _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(void)
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
 
-#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)  \
+#undef _TRACEPOINT_EVENT_INSTANCE
+#define _TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
 static const char                                                      \
        __tp_name_len_check##_provider##___##_name[LTTNG_UST_SYM_NAME_LEN] \
        __attribute__((unused)) =                                       \
@@ -134,12 +142,12 @@ static const char                                                 \
 #undef TP_ARGS
 #define TP_ARGS(...)   __VA_ARGS__
 
-#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
+#undef _TRACEPOINT_EVENT_INSTANCE
+#define _TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
 void __event_template_proto___##_provider##___##_template(_TP_ARGS_DATA_PROTO(_args));
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
 void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 
 #include TRACEPOINT_INCLUDE
@@ -331,8 +339,8 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
 #undef TP_FIELDS
 #define TP_FIELDS(...) __VA_ARGS__     /* Only one used in this phase */
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)                            \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)                           \
        static const struct lttng_event_field __event_fields___##_provider##___##_name[] = { \
                _fields                                                                      \
                ctf_integer(int, dummy, 0)      /* Dummy, C99 forbids 0-len array. */        \
@@ -360,8 +368,8 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
 #undef TP_ARGS
 #define TP_ARGS(...) __VA_ARGS__
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)               \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)              \
 static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 
 #include TRACEPOINT_INCLUDE
@@ -417,8 +425,8 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 #undef TP_FIELDS
 #define TP_FIELDS(...) __VA_ARGS__
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)            \
 static inline lttng_ust_notrace                                                      \
 size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)); \
 static inline                                                                \
@@ -577,8 +585,8 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS
 #undef TP_FIELDS
 #define TP_FIELDS(...) __VA_ARGS__
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)            \
 static inline                                                                \
 void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
                                                 _TP_ARGS_DATA_PROTO(_args))  \
@@ -630,8 +638,8 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
 #undef TP_FIELDS
 #define TP_FIELDS(...) __VA_ARGS__
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)            \
 static inline lttng_ust_notrace                                                      \
 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args));     \
 static inline                                                                \
@@ -767,8 +775,8 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
  * 2*sizeof(unsigned long) for all supported architectures.
  * Perform UNION (||) of filter runtime list.
  */
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)            \
 static lttng_ust_notrace                                                     \
 void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));      \
 static                                                                       \
@@ -847,8 +855,8 @@ void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))           \
 
 #define _TP_EXTRACT_STRING2(...)       #__VA_ARGS__
 
-#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)       \
+#undef _TRACEPOINT_EVENT_CLASS
+#define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
 static const char __tp_event_signature___##_provider##___##_name[] =   \
                _TP_EXTRACT_STRING2(_args);
 
@@ -932,8 +940,8 @@ LTTNG_TP_EXTERN_C const char *_model_emf_uri___##__provider##___##__name   \
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
 
-#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)         \
+#undef _TRACEPOINT_EVENT_INSTANCE
+#define _TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)        \
 static const int *                                                            \
        __ref_loglevel___##_provider##___##_name                               \
        __attribute__((weakref ("_loglevel___" #_provider "___" #_name)));     \
@@ -966,8 +974,8 @@ static const struct lttng_event_desc __event_desc___##_provider##_##_name = {
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
 
-#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)         \
+#undef _TRACEPOINT_EVENT_INSTANCE
+#define _TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)        \
        &__event_desc___##_provider##_##_name,
 
 static const struct lttng_event_desc *_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)[] = {
This page took 0.030157 seconds and 4 git commands to generate.