X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=include%2Flttng%2Fust-tracepoint-event.h;h=86098a9847f8cc0dc83d9f0b0dbcda219c29e79b;hb=0997899b47dda080f4f9346b5d4f66ad60bee700;hp=c68f7d98cb1748b5e540946ea87cb7bdffdaf160;hpb=2e7160d2113f6f0c5af599963a59ebaab0751320;p=lttng-ust.git diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index c68f7d98..86098a98 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -1136,7 +1136,7 @@ static const struct lttng_ust_event_desc lttng_ust__event_desc___##_provider##_# #define LTTNG_UST__TRACEPOINT_EVENT_INSTANCE(_template_provider, _template_name, _provider, _name, _args) \ <tng_ust__event_desc___##_provider##_##_name, -static const struct lttng_ust_event_desc * const LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER)[] = { +static const struct lttng_ust_event_desc * const LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__provider_event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER)[] = { #include LTTNG_UST_TRACEPOINT_INCLUDE NULL, /* Dummy, C99 forbids 0-len array. */ }; @@ -1151,8 +1151,8 @@ static const struct lttng_ust_event_desc * const LTTNG_UST__TP_COMBINE_TOKENS(lt const struct lttng_ust_probe_desc LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_desc___, LTTNG_UST_TRACEPOINT_PROVIDER) = { .struct_size = sizeof(struct lttng_ust_probe_desc), .provider_name = lttng_ust__tp_stringify(LTTNG_UST_TRACEPOINT_PROVIDER), - .event_desc = LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER), - .nr_events = LTTNG_UST__TP_ARRAY_SIZE(LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER)) - 1, + .event_desc = LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__provider_event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER), + .nr_events = LTTNG_UST__TP_ARRAY_SIZE(LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__provider_event_desc___, LTTNG_UST_TRACEPOINT_PROVIDER)) - 1, .major = LTTNG_UST_PROVIDER_MAJOR, .minor = LTTNG_UST_PROVIDER_MINOR, }; @@ -1169,13 +1169,24 @@ static struct lttng_ust_registered_probe *LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust * linking the probe statically. * * Register refcount is protected by libc dynamic loader mutex. + * + * Note that when building this code as C++, the definition of constructors + * and destructors invoking the registration and unregistration functions + * must be performed _after_ the initialization of the probes. + * + * This is because we rely on the order of initialization of static variables + * and anonymous namespaces (their order of declaration) to ensure probes are + * fully initialized, see + * https://en.cppreference.com/w/cpp/language/initialization. This is especially + * important when LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP is defined as + * compound literals are then dynamically initialized. */ /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ #include + static void -LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) - lttng_ust_notrace __attribute__((constructor)); +LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) lttng_ust_notrace; static void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) { @@ -1204,8 +1215,7 @@ LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__, LTTNG_UST_TRACEPOINT_PROV } static void -LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) - lttng_ust_notrace __attribute__((destructor)); +LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) lttng_ust_notrace; static void LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__, LTTNG_UST_TRACEPOINT_PROVIDER)(void) { @@ -1217,6 +1227,12 @@ LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__, LTTNG_UST_TRACEPOINT_PROV LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___, LTTNG_UST_TRACEPOINT_PROVIDER) = NULL; } +LTTNG_UST_DECLARE_CONSTRUCTOR_DESTRUCTOR( + LTTNG_UST_TRACEPOINT_PROVIDER, + LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_init__, LTTNG_UST_TRACEPOINT_PROVIDER), + LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__, LTTNG_UST_TRACEPOINT_PROVIDER), + lttng_ust_notrace) + /* * LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION: Define this before * including a tracepoint instrumentation header to hide symbols