X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Flttng%2Fust-tracepoint-event.h;h=dbd0485565cfd18e2d920811d5dbbb3cb4c79f93;hb=457a6b5879a7dd8cdd1b5b22b20d028a59489159;hp=23c2e384fad1d4b152062ccafab7c2cbbc52cf20;hpb=f280cb51b6f0c84f7248c9857cfc66d45aed413e;p=lttng-ust.git diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 23c2e384..dbd04855 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include /* * Macro declarations used for all stages. @@ -117,6 +117,25 @@ void _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(void) #include TRACEPOINT_INCLUDE } +/* + * Stage 0.1 of tracepoint event generation. + * + * Check that each TRACEPOINT_EVENT provider:name does not exceed the + * tracepoint name length limit. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#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)) = \ + #_provider ":" #_name; + +#include TRACEPOINT_INCLUDE + /* * Stage 1 of tracepoint event generation. * @@ -215,41 +234,6 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); /* * Stage 3 of tracepoint event generation. * - * Create an array of events. - */ - -/* Reset all macros within TRACEPOINT_EVENT */ -#include - -#undef TRACEPOINT_EVENT_INSTANCE -#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ - { \ - .fields = __event_fields___##_provider##___##_template,\ - .name = #_provider ":" #_name, \ - .probe_callback = (void *) &__event_probe__##_provider##___##_template,\ - .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \ - }, - -static const struct lttng_event_desc _TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)[] = { -#include TRACEPOINT_INCLUDE -}; - - -/* - * Stage 4 of tracepoint event generation. - * - * Create a toplevel descriptor for the whole probe. - */ - -/* non-const because list head will be modified when registered. */ -static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER) = { - .event_desc = _TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER), - .nr_events = _TP_ARRAY_SIZE(_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)), -}; - -/* - * Stage 5 of tracepoint event generation. - * * Create static inline function that calculates event size. */ @@ -307,7 +291,7 @@ static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic #include TRACEPOINT_INCLUDE /* - * Stage 6 of tracepoint event generation. + * Stage 4 of tracepoint event generation. * * Create static inline function that calculates event payload alignment. */ @@ -356,7 +340,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ /* - * Stage 7 of tracepoint event generation. + * Stage 5 of tracepoint event generation. * * Create the probe function. This function calls event size calculation * and writes event data into the buffer. @@ -449,9 +433,86 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\ #undef __get_dynamic_len +/* + * Stage 6 of tracepoint event generation. + * + * Tracepoint loglevel mapping definition generation. We generate a + * symbol for each mapping for a provider/event to ensure at most a 1 to + * 1 mapping between events and loglevels. If the symbol is repeated, + * the compiler will complain. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef TRACEPOINT_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 + +/* + * Stage 7.1 of tracepoint event generation. + * + * Create events description structures. We use a weakref because + * loglevels are optional. If not declared, the event will point to the + * a loglevel that contains NULL. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef TRACEPOINT_EVENT_INSTANCE +#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \ +static const int * \ + __ref_loglevel___##_provider##___##_name \ + __attribute__((weakref ("_loglevel___" #_provider "___" #_name))); \ +const struct lttng_event_desc __event_desc___##_provider##_##_name = { \ + .fields = __event_fields___##_provider##___##_template, \ + .name = #_provider ":" #_name, \ + .probe_callback = (void *) &__event_probe__##_provider##___##_template,\ + .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \ + .loglevel = &__ref_loglevel___##_provider##___##_name, \ +}; + +#include TRACEPOINT_INCLUDE + +/* + * Stage 7.2 of tracepoint event generation. + * + * Create array of events. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#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)[] = { +#include TRACEPOINT_INCLUDE +}; + + /* * Stage 8 of tracepoint event generation. * + * Create a toplevel descriptor for the whole probe. + */ + +/* non-const because list head will be modified when registered. */ +static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER) = { + .provider = __tp_stringify(TRACEPOINT_PROVIDER), + .event_desc = _TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER), + .nr_events = _TP_ARRAY_SIZE(_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)), +}; + +/* + * Stage 9 of tracepoint event generation. + * * Register/unregister probes at module load/unload. */