Implement tracepoint loglevel macros
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 23 Nov 2011 13:37:14 +0000 (14:37 +0100)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 23 Nov 2011 13:37:14 +0000 (14:37 +0100)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/tracepoint.h
include/lttng/ust-events.h
include/lttng/ust-tracepoint-event-reset.h
include/lttng/ust-tracepoint-event.h
tests/demo/ust_tests_demo.h

index 2753d95a6f7b44c39ac6e71796c8970303248b92..bce84e53670c7e623a8d838d7e7a21b48eec3525 100644 (file)
@@ -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 */
index 63162948d67563028a130ba1c833075f6b5b9d21..afcc67f910795aaf10cfa63a2be3e0fa58f34741 100644 (file)
@@ -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);
index 0f40f30678023a3d880a5c37e0169b681d9a697c..43ea1342aa89090b5bed454a67600cae17e6fe19 100644 (file)
@@ -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)
index 6983ef1691d39949e3a72fe11cedf7030cf1d050..ac36362e1787062ec6fcc6488e38f2fc8e8ac3ac 100644 (file)
@@ -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 <lttng/ust-tracepoint-event-reset.h>
+
+#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 <lttng/ust-tracepoint-event-reset.h>
+
+#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 <lttng/ust-tracepoint-event-reset.h>
+
+#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.
  */
 
index 486b3ae9459d00e498301909b7826bf483eca321..9231fb71e0bd767ac43d93fee84be564e8e7d22d 100644 (file)
@@ -23,6 +23,12 @@ extern "C" {
 
 #include <lttng/tracepoint.h>
 
+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 */
 
This page took 0.035133 seconds and 4 git commands to generate.