/*
- * Copyright (c) 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*/
#include <stdio.h>
_TP_PARAMS(_args), \
_TP_PARAMS(_fields)) \
TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name, \
- _TP_PARAMS(args))
+ _TP_PARAMS(_args))
/* Helpers */
#define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#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 <lttng/ust-tracepoint-event-reset.h>
+
+#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.
*
},
#undef TP_FIELDS
-#define TP_FIELDS(args...) args /* Only one used in this phase */
+#define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */
#undef TRACEPOINT_EVENT_CLASS
#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
#include <lttng/ust-tracepoint-event-reset.h>
#undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
#undef TRACEPOINT_EVENT_CLASS
#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
/*
* Stage 3 of tracepoint event generation.
*
- * Create an array of events.
- */
-
-/* Reset all macros within TRACEPOINT_EVENT */
-#include <lttng/ust-tracepoint-event-reset.h>
-
-#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 static inline function that calculates event size.
*/
__event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
#undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
#undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
#undef TRACEPOINT_EVENT_CLASS
#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
#include TRACEPOINT_INCLUDE
/*
- * Stage 5 of tracepoint event generation.
+ * Stage 4 of tracepoint event generation.
*
* Create static inline function that calculates event payload alignment.
*/
#define ctf_string(_item, _src)
#undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
#undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
#undef TRACEPOINT_EVENT_CLASS
#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
/*
- * Stage 6 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.
#define __get_dynamic_len(field) __dynamic_len[__dynamic_len_idx++]
#undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
#undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
#undef TRACEPOINT_EVENT_CLASS
#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
#undef __get_dynamic_len
/*
- * Stage 7.1 of tracepoint event generation.
+ * Stage 5.1 of tracepoint event generation.
*
- * Tracepoint loglevel enumeration definition generation.
+ * Create probe signature
*/
/* 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_ARGS
+#define TP_ARGS(...) __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), \
- };
+#define _TP_EXTRACT_STRING2(...) #__VA_ARGS__
+
+#undef TRACEPOINT_EVENT_CLASS
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
+const char __tp_event_signature___##_provider##___##_name[] = \
+ _TP_EXTRACT_STRING2(_args);
#include TRACEPOINT_INCLUDE
+#undef _TP_EXTRACT_STRING2
+
/*
- * Stage 7.2 of tracepoint event generation.
+ * Stage 6 of tracepoint event generation.
*
- * Tracepoint loglevel enumeration array 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 <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),
+#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;
-static const struct tracepoint_loglevel_enum_entry *_TP_COMBINE_TOKENS(__tracepoint_loglevel_enum__, TRACEPOINT_PROVIDER)[] __attribute__((unused)) =
-{
#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 <lttng/ust-tracepoint-event-reset.h>
+
+#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 (*)(void)) &__event_probe__##_provider##___##_template,\
+ .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \
+ .loglevel = &__ref_loglevel___##_provider##___##_name, \
+ .signature = __tp_event_signature___##_provider##___##_template, \
};
+#include TRACEPOINT_INCLUDE
+
/*
- * Stage 8 of tracepoint event generation.
+ * Stage 7.2 of tracepoint event generation.
*
- * Tracepoint loglevel definition generation.
+ * Create array of events.
*/
/* 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), \
-},
+#undef TRACEPOINT_EVENT_INSTANCE
+#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args) \
+ &__event_desc___##_provider##_##_name,
-static struct tracepoint_loglevel _TP_COMBINE_TOKENS(__tracepoint_loglevels__, TRACEPOINT_PROVIDER)[] = {
+static const struct lttng_event_desc *_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)[] = {
#include TRACEPOINT_INCLUDE
};
+
/*
- * Stage 9 of tracepoint event generation.
+ * 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)),
- .loglevels = _TP_COMBINE_TOKENS(__tracepoint_loglevels__, TRACEPOINT_PROVIDER),
};
/*
- * Stage 10 of tracepoint event generation.
+ * Stage 9 of tracepoint event generation.
*
* Register/unregister probes at module load/unload.
+ *
+ * Generate the constructor as an externally visible symbol for use when
+ * linking the probe statically.
*/
/* Reset all macros within TRACEPOINT_EVENT */
#include <lttng/ust-tracepoint-event-reset.h>
-
static void __attribute__((constructor))
_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
{
{
ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
}
+
+int _TP_COMBINE_TOKENS(__tracepoint_provider_, TRACEPOINT_PROVIDER);