From: Christophe Bedard Date: Sun, 21 Jun 2020 17:54:30 +0000 (-0400) Subject: Fix: ust-tracepoint: make sure to expand tracepoint provider token X-Git-Tag: v2.13.0-rc1~412 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f8021d088ed27ede5af620702468a8cf4647b7fc;p=lttng-ust.git Fix: ust-tracepoint: make sure to expand tracepoint provider token 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. [ Mathieu: Adapt event notifier probes as well. ] Fixes: #1273 Signed-off-by: Christophe Bedard Signed-off-by: Mathieu Desnoyers Change-Id: I68550a510c809f1d5f86a7e1d966dcecc3780dda --- diff --git a/include/lttng/ust-tracepoint-event-reset.h b/include/lttng/ust-tracepoint-event-reset.h index 47bb5a8d..4467d267 100644 --- a/include/lttng/ust-tracepoint-event-reset.h +++ b/include/lttng/ust-tracepoint-event-reset.h @@ -22,11 +22,11 @@ /* 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) diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 11025204..ad159b0d 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -53,12 +53,20 @@ #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])) @@ -86,12 +94,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 @@ -112,8 +120,8 @@ void _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(void) /* Reset all macros within TRACEPOINT_EVENT */ #include -#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)) = \ @@ -135,12 +143,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 @@ -243,8 +251,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) \ _fields #include TRACEPOINT_INCLUDE @@ -398,8 +406,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. */ \ @@ -427,8 +435,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 @@ -445,8 +453,8 @@ static void __event_probe__##_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_notifier_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); #include TRACEPOINT_INCLUDE @@ -502,8 +510,8 @@ static void __event_notifier_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO( #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 \ @@ -662,8 +670,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_interpreter_stack__##_provider##___##_name(char *__stack_data,\ _TP_ARGS_DATA_PROTO(_args)) \ @@ -715,8 +723,8 @@ void __event_prepare_interpreter_stack__##_provider##___##_name(char *__stack_da #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 \ @@ -839,8 +847,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 \ @@ -922,8 +930,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); @@ -936,8 +944,8 @@ static const char __tp_event_signature___##_provider##___##_name[] = \ * * Create the event notifier probe function. */ -#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_notifier_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); \ static \ @@ -1053,8 +1061,8 @@ LTTNG_TP_EXTERN_C const char *_model_emf_uri___##__provider##___##__name \ /* Reset all macros within TRACEPOINT_EVENT */ #include -#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))); \ @@ -1088,8 +1096,8 @@ static const struct lttng_event_desc __event_desc___##_provider##_##_name = { /* Reset all macros within TRACEPOINT_EVENT */ #include -#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)[] = {