From: Mathieu Desnoyers Date: Wed, 23 Nov 2011 13:37:14 +0000 (+0100) Subject: Implement tracepoint loglevel macros X-Git-Tag: v1.9.1~59 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=05ceaafdd290220147a1faf4ca78d440f1e279b4;p=lttng-ust.git Implement tracepoint loglevel macros Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index 2753d95a..bce84e53 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -334,7 +334,7 @@ static void __attribute__((destructor)) __tracepoints__destroy(void) * provider. */ -#define TRACEPOINT_LOGLEVEL_ENUM() -#define TRACEPOINT_LOGLEVEL(name, loglevel) +#define TRACEPOINT_LOGLEVEL_ENUM(...) +#define TRACEPOINT_LOGLEVEL(provider, name, loglevel) #endif /* #ifndef TRACEPOINT_LOGLEVEL */ diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 63162948..afcc67f9 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -195,6 +195,7 @@ struct lttng_probe_desc { const struct lttng_event_desc *event_desc; unsigned int nr_events; struct cds_list_head head; /* chain registered probes */ + struct tracepoint_loglevel *loglevels; }; struct ust_pending_probe; @@ -302,6 +303,17 @@ struct ltt_transport { struct ltt_channel_ops ops; }; +struct tracepoint_loglevel_enum_entry { + const char *identifier; + long value; +}; + +/* mapping between tracepoint and loglevel */ +struct tracepoint_loglevel { + const char *name; + const struct tracepoint_loglevel_enum_entry *loglevel; +}; + struct ltt_session *ltt_session_create(void); int ltt_session_enable(struct ltt_session *session); int ltt_session_disable(struct ltt_session *session); diff --git a/include/lttng/ust-tracepoint-event-reset.h b/include/lttng/ust-tracepoint-event-reset.h index 0f40f306..43ea1342 100644 --- a/include/lttng/ust-tracepoint-event-reset.h +++ b/include/lttng/ust-tracepoint-event-reset.h @@ -40,3 +40,9 @@ #undef ctf_string #define ctf_string(_item, _src) + +#undef TRACEPOINT_LOGLEVEL_ENUM +#define TRACEPOINT_LOGLEVEL_ENUM(...) + +#undef TRACEPOINT_LOGLEVEL +#define TRACEPOINT_LOGLEVEL(provider, name, loglevel) diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 6983ef16..ac36362e 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -238,18 +238,6 @@ static const struct lttng_event_desc _TP_COMBINE_TOKENS(__event_desc___, TRACEPO /* * 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 +295,7 @@ static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic #include TRACEPOINT_INCLUDE /* - * Stage 6 of tracepoint event generation. + * Stage 5 of tracepoint event generation. * * Create static inline function that calculates event payload alignment. */ @@ -356,7 +344,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ /* - * Stage 7 of tracepoint event generation. + * Stage 6 of tracepoint event generation. * * Create the probe function. This function calls event size calculation * and writes event data into the buffer. @@ -449,9 +437,86 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\ #undef __get_dynamic_len +/* + * Stage 7.1 of tracepoint event generation. + * + * Tracepoint loglevel enumeration definition generation. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef TRACEPOINT_LOGLEVEL_ENUM +#define TRACEPOINT_LOGLEVEL_ENUM(...) __VA_ARGS__ + +#undef TP_LOGLEVEL +#define TP_LOGLEVEL(_identifier, _value) \ +static const struct tracepoint_loglevel_enum_entry \ + _TP_COMBINE_TOKENS(_TP_COMBINE_TOKENS(TRACEPOINT_PROVIDER, __tp_loglevel_enum_entry__), _identifier) = \ + { \ + .identifier = #_identifier, \ + .value = (_value), \ + }; + +#include TRACEPOINT_INCLUDE + +/* + * Stage 7.2 of tracepoint event generation. + * + * Tracepoint loglevel enumeration array generation. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef TRACEPOINT_LOGLEVEL_ENUM +#define TRACEPOINT_LOGLEVEL_ENUM(...) __VA_ARGS__ + +#undef TP_LOGLEVEL +#define TP_LOGLEVEL(_identifier, _value) \ + &_TP_COMBINE_TOKENS(_TP_COMBINE_TOKENS(TRACEPOINT_PROVIDER, __tp_loglevel_enum_entry__), _identifier), + +static const struct tracepoint_loglevel_enum_entry *_TP_COMBINE_TOKENS(__tracepoint_loglevel_enum__, TRACEPOINT_PROVIDER)[] __attribute__((unused)) = +{ +#include TRACEPOINT_INCLUDE +}; + /* * Stage 8 of tracepoint event generation. * + * Tracepoint loglevel definition generation. + */ + +/* Reset all macros within TRACEPOINT_EVENT */ +#include + +#undef TRACEPOINT_LOGLEVEL +#define TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel) \ +{ \ + .name = #__provider ":" #__name, \ + .loglevel = &_TP_COMBINE_TOKENS(_TP_COMBINE_TOKENS(TRACEPOINT_PROVIDER, __tp_loglevel_enum_entry__), __loglevel), \ +}, + +static struct tracepoint_loglevel _TP_COMBINE_TOKENS(__tracepoint_loglevels__, TRACEPOINT_PROVIDER)[] = { +#include TRACEPOINT_INCLUDE +}; + +/* + * Stage 9 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)), + .loglevels = _TP_COMBINE_TOKENS(__tracepoint_loglevels__, TRACEPOINT_PROVIDER), +}; + +/* + * Stage 10 of tracepoint event generation. + * * Register/unregister probes at module load/unload. */ diff --git a/tests/demo/ust_tests_demo.h b/tests/demo/ust_tests_demo.h index 486b3ae9..9231fb71 100644 --- a/tests/demo/ust_tests_demo.h +++ b/tests/demo/ust_tests_demo.h @@ -23,6 +23,12 @@ extern "C" { #include +TRACEPOINT_LOGLEVEL_ENUM( + TP_LOGLEVEL(critical, 0) + TP_LOGLEVEL(warning, 1) + TP_LOGLEVEL(debug, 2) +) + TRACEPOINT_EVENT(ust_tests_demo, loop, TP_ARGS(int, anint, int, netint, long *, values, char *, text, size_t, textlen, @@ -44,6 +50,7 @@ TRACEPOINT_EVENT(ust_tests_demo, loop, ctf_float(double, doublefield, doublearg) ) ) +TRACEPOINT_LOGLEVEL(ust_tests_demo, loop, debug) TRACEPOINT_EVENT(ust_tests_demo, starting, TP_ARGS(int, value), @@ -51,6 +58,7 @@ TRACEPOINT_EVENT(ust_tests_demo, starting, ctf_integer(int, value, value) ) ) +TRACEPOINT_LOGLEVEL(ust_tests_demo, starting, critical) TRACEPOINT_EVENT(ust_tests_demo, done, TP_ARGS(int, value), @@ -58,6 +66,7 @@ TRACEPOINT_EVENT(ust_tests_demo, done, ctf_integer(int, value, value) ) ) +TRACEPOINT_LOGLEVEL(ust_tests_demo, done, critical) #endif /* _TRACEPOINT_UST_TESTS_DEMO_H */