#endif
#undef TRACEPOINT_EVENT
-#define TRACEPOINT_EVENT(name, proto, args, fields) \
- _DEFINE_TRACEPOINT(name)
+#define TRACEPOINT_EVENT(provider, name, proto, args, fields) \
+ _DEFINE_TRACEPOINT(provider, name)
#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
- _DEFINE_TRACEPOINT(name)
+#define TRACEPOINT_EVENT_INSTANCE(provider, template, name, proto, args) \
+ _DEFINE_TRACEPOINT(provider, name)
#undef TRACEPOINT_EVENT_NOARGS
-#define TRACEPOINT_EVENT_NOARGS(name, fields) \
- _DEFINE_TRACEPOINT(name)
+#define TRACEPOINT_EVENT_NOARGS(provider, name, fields) \
+ _DEFINE_TRACEPOINT(provider, name)
#undef TRACEPOINT_EVENT_INSTANCE_NOARGS
-#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \
- _DEFINE_TRACEPOINT(name)
+#define TRACEPOINT_EVENT_INSTANCE_NOARGS(provider, template, name) \
+ _DEFINE_TRACEPOINT(provider, name)
#undef TRACEPOINT_INCLUDE
#undef __TRACEPOINT_INCLUDE
* Tracepoints should be added to the instrumented code using the
* "tracepoint()" macro.
*/
-#define tracepoint(name, args...) __trace_##name(args)
+#define tracepoint(provider, name, args...) \
+ __trace_##provider##___##name(args)
/*
* it_func[0] is never NULL because there is at least one element in the array
#define TP_PROTO(args...) args
#define TP_ARGS(args...) args
-#define __CHECK_TRACE(name, proto, args) \
+#define __CHECK_TRACE(provider, name, proto, args) \
do { \
- if (caa_unlikely(__tracepoint_##name.state)) \
- __DO_TRACE(&__tracepoint_##name, \
+ if (caa_unlikely(__tracepoint_##provider##___##name.state)) \
+ __DO_TRACE(&__tracepoint_##provider##___##name, \
TP_PROTO(proto), TP_ARGS(args)); \
} while (0)
* not add unwanted padding between the beginning of the section and the
* structure. Force alignment to the same alignment as the section start.
*/
-#define __DECLARE_TRACEPOINT(name, proto, args, data_proto, data_args) \
- extern struct tracepoint __tracepoint_##name; \
- static inline void __trace_##name(proto) \
+#define __DECLARE_TRACEPOINT(provider, name, proto, args, data_proto, data_args) \
+ extern struct tracepoint __tracepoint_##provider##___##name; \
+ static inline void __trace_##provider##___##name(proto) \
{ \
- __CHECK_TRACE(name, TP_PROTO(data_proto), \
+ __CHECK_TRACE(provider, name, TP_PROTO(data_proto), \
TP_ARGS(data_args)); \
} \
static inline int \
- __register_trace_##name(void (*probe)(data_proto), void *data) \
+ __register_trace_##provider##___##name(void (*probe)(data_proto), void *data) \
{ \
- return __tracepoint_probe_register(#name, (void *)probe,\
+ return __tracepoint_probe_register(#provider ":" #name, (void *) probe, \
data); \
} \
static inline int \
- __unregister_trace_##name(void (*probe)(data_proto), void *data)\
+ __unregister_trace_##provider##___##name(void (*probe)(data_proto), void *data) \
{ \
- return __tracepoint_probe_unregister(#name, (void *)probe, \
+ return __tracepoint_probe_unregister(#provider ":" #name, (void *) probe, \
data); \
}
* DECLARE_TRACEPOINT() passes "proto" as the tracepoint protoype and
* "void *__tp_cb_data, proto" as the callback prototype.
*/
-#define _DECLARE_TRACEPOINT_NOARGS(name) \
- __DECLARE_TRACEPOINT(name, void, , void *__tp_cb_data, __tp_cb_data)
+#define _DECLARE_TRACEPOINT_NOARGS(provider, name) \
+ __DECLARE_TRACEPOINT(provider, name, void, , void *__tp_cb_data, __tp_cb_data)
-#define _DECLARE_TRACEPOINT(name, proto, args) \
- __DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args), \
+#define _DECLARE_TRACEPOINT(provider, name, proto, args) \
+ __DECLARE_TRACEPOINT(provider, name, TP_PARAMS(proto), TP_PARAMS(args), \
TP_PARAMS(void *__tp_cb_data, proto), \
TP_PARAMS(__tp_cb_data, args))
* __tracepoints_ptrs section is not const (read-only) to let the linker update
* the pointer, allowing PIC code.
*/
-#define _DEFINE_TRACEPOINT(name) \
- static const char __tpstrtab_##name[] \
- __attribute__((section("__tracepoints_strings"))) = #name; \
- struct tracepoint __tracepoint_##name \
+#define _DEFINE_TRACEPOINT(provider, name) \
+ static const char __tpstrtab_##provider##___##name[] \
+ __attribute__((section("__tracepoints_strings"))) = \
+ #provider ":" #name; \
+ struct tracepoint __tracepoint_##provider##___##name \
__attribute__((section("__tracepoints"))) = \
- { __tpstrtab_##name, 0, NULL }; \
- static struct tracepoint * __tracepoint_ptr_##name \
+ { __tpstrtab_##provider##___##name, 0, NULL }; \
+ static struct tracepoint * __tracepoint_ptr_##provider##___##name \
__attribute__((used, section("__tracepoints_ptrs"))) = \
- &__tracepoint_##name;
+ &__tracepoint_##provider##___##name;
-#define __register_tracepoint(name, probe, data) \
- __register_trace_##name(probe, data)
-#define __unregister_tracepoint(name, probe, data) \
- __unregister_trace_##name(probe, data)
+#define __register_tracepoint(provider, name, probe, data) \
+ __register_trace_##provider##___##name(probe, data)
+#define __unregister_tracepoint(provider, name, probe, data) \
+ __unregister_trace_##provider##___##name(probe, data)
/*
* Connect a probe to a tracepoint.
*
* In short, an example:
*
- * TRACEPOINT_EVENT(< [com_company_]project_[component_]event >,
+ * TRACEPOINT_EVENT(< [com_company_]project[_component] >, < event >,
* TP_PROTO(int arg0, void *arg1, char *string, size_t strlen,
* long *arg4, size_t arg4_len),
* TP_ARGS(arg0, arg1, string, strlen, arg4, arg4_len),
* We define a tracepoint, its arguments, and its 'fast binary record'
* layout.
*
- * Firstly, name your tracepoint via TRACEPOINT_EVENT(name,
+ * Firstly, name your tracepoint via TRACEPOINT_EVENT(provider, name,
*
- * The name should be a proper C99 identifier.
- * The "name" MUST follow these rules to ensure no namespace clash
- * occurs:
+ * The provider and name should be a proper C99 identifier.
+ * The "provider" and "name" MUST follow these rules to ensure no
+ * namespace clash occurs:
*
* For projects (applications and libraries) for which an entity
* specific to the project controls the source code and thus its
* tracepoints (typically with a scope larger than a single company):
*
* either:
- * project_component_event
+ * project_component, event
* or:
- * project_event
+ * project, event
*
* Where "project" is the name of the project,
* "component" is the name of the project component (which may
* "com_" prefix should be used:
*
* either:
- * com_company_project_component_event
+ * com_company_project_component, event
* or:
- * com_company_project_event
+ * com_company_project, event
*
* Where "company" is the name of the company,
* "project" is the name of the project,
* (optional),
* "event" is the name of the tracepoint event.
*
+ * the provider identifier is limited to 127 characters.
+ * the "event" identifier is limited to 127 characters.
*
* As an example, let's consider a user-space application "someproject"
* that would have an internal thread scheduler:
*
- * TRACEPOINT_EVENT(someproject_sched_switch,
+ * TRACEPOINT_EVENT(someproject_sched, switch,
*
* *
* * A function has a regular function arguments
* usage of other macros controlling TRACEPOINT_EVENT.
*/
-#define TRACEPOINT_EVENT(name, proto, args, fields) \
- _DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args))
+#define TRACEPOINT_EVENT(provider, name, proto, args, fields) \
+ _DECLARE_TRACEPOINT(provider, name, TP_PARAMS(proto), TP_PARAMS(args))
-#define TRACEPOINT_EVENT_CLASS(name, proto, args, fields)
-#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \
- _DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args))
+#define TRACEPOINT_EVENT_CLASS(provider, name, proto, args, fields)
+#define TRACEPOINT_EVENT_INSTANCE(provider, template, name, proto, args)\
+ _DECLARE_TRACEPOINT(provider, name, TP_PARAMS(proto), TP_PARAMS(args))
/*
* Declaration of tracepoints that take 0 argument.
*/
-#define TRACEPOINT_EVENT_NOARGS(name, fields) \
- _DECLARE_TRACEPOINT_NOARGS(name)
+#define TRACEPOINT_EVENT_NOARGS(provider, name, fields) \
+ _DECLARE_TRACEPOINT_NOARGS(provider, name)
-#define TRACEPOINT_EVENT_CLASS_NOARGS(name, fields)
-#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \
- _DECLARE_TRACEPOINT_NOARGS(name)
+#define TRACEPOINT_EVENT_CLASS_NOARGS(provider, name, fields)
+#define TRACEPOINT_EVENT_INSTANCE_NOARGS(provider, template, name) \
+ _DECLARE_TRACEPOINT_NOARGS(provider, name)
#endif /* #ifndef TRACEPOINT_EVENT */
* is the name of the tracepoint, the second field is the loglevel
* name.
*
- * TRACEPOINT_LOGLEVEL(< [com_company_]project_[component_]event >,
+ * TRACEPOINT_LOGLEVEL(< [com_company_]project[_component] >, < event >,
* < loglevel_name >)
*
* The TRACEPOINT_SYSTEM must be defined when declaring a
#define TP_FIELDS(args...)
#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields)
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _proto, _args, _fields)
#undef TRACEPOINT_EVENT_CLASS_NOARGS
-#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields)
+#define TRACEPOINT_EVENT_CLASS_NOARGS(_provider, _name, _fields)
#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_template, _name, _proto, _args)
+#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _proto, _args)
#undef TRACEPOINT_EVENT_INSTANCE_NOARGS
-#define TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)
+#define TRACEPOINT_EVENT_INSTANCE_NOARGS(_provider, _template, _name)
*/
#undef TRACEPOINT_EVENT
-#define TRACEPOINT_EVENT(name, proto, args, fields) \
- TRACEPOINT_EVENT_CLASS(name, \
+#define TRACEPOINT_EVENT(provider, name, proto, args, fields) \
+ TRACEPOINT_EVENT_CLASS(provider, name, \
TP_PARAMS(proto), \
TP_PARAMS(args), \
TP_PARAMS(fields)) \
- TRACEPOINT_EVENT_INSTANCE(name, name, TP_PARAMS(proto), TP_PARAMS(args))
+ TRACEPOINT_EVENT_INSTANCE(provider, name, name, TP_PARAMS(proto), TP_PARAMS(args))
#undef TRACEPOINT_EVENT_NOARGS
-#define TRACEPOINT_EVENT_NOARGS(name, fields) \
- TRACEPOINT_EVENT_CLASS_NOARGS(name, \
+#define TRACEPOINT_EVENT_NOARGS(provider, name, fields) \
+ TRACEPOINT_EVENT_CLASS_NOARGS(provider, name, \
TP_PARAMS(fields)) \
- TRACEPOINT_EVENT_INSTANCE_NOARGS(name, name)
+ TRACEPOINT_EVENT_INSTANCE_NOARGS(provider, name, name)
/* Helpers */
#define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define TP_FIELDS(args...) args /* Only one used in this phase */
#undef TRACEPOINT_EVENT_CLASS_NOARGS
-#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
- static const struct lttng_event_field __event_fields___##_name[] = { \
+#define TRACEPOINT_EVENT_CLASS_NOARGS(_provider, _name, _fields) \
+ static const struct lttng_event_field __event_fields___##_provider##___##_name[] = { \
_fields \
};
#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
- TRACEPOINT_EVENT_CLASS_NOARGS(_name, TP_PARAMS(_fields))
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _proto, _args, _fields) \
+ TRACEPOINT_EVENT_CLASS_NOARGS(_provider, _name, TP_PARAMS(_fields))
#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE)
#define TP_PROTO(args...) args
#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
-static void __event_probe__##_name(void *__data, _proto);
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _proto, _args, _fields) \
+static void __event_probe__##_provider##___##_name(void *__data, _proto);
#undef TRACEPOINT_EVENT_CLASS_NOARGS
-#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
-static void __event_probe__##_name(void *__data);
+#define TRACEPOINT_EVENT_CLASS_NOARGS(_provider, _name, _fields) \
+static void __event_probe__##_provider##___##_name(void *__data);
#include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE)
#include <lttng/ust-tracepoint-event-reset.h>
#undef TRACEPOINT_EVENT_INSTANCE_NOARGS
-#define TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) \
+#define TRACEPOINT_EVENT_INSTANCE_NOARGS(_provider, _template, _name) \
{ \
- .fields = __event_fields___##_template, \
- .name = #_name, \
- .probe_callback = (void *) &__event_probe__##_template,\
- .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_template), \
+ .fields = __event_fields___##_provider##___##_template,\
+ .name = #_provider ":" #_name, \
+ .probe_callback = (void *) &__event_probe__##_provider##___##_template,\
+ .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \
},
#undef TRACEPOINT_EVENT_INSTANCE
-#define TRACEPOINT_EVENT_INSTANCE(_template, _name, _proto, _args) \
- TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)
+#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _proto, _args) \
+ TRACEPOINT_EVENT_INSTANCE_NOARGS(_provider, _template, _name)
#define TP_ID1(_token, _system) _token##_system
#define TP_ID(_token, _system) TP_ID1(_token, _system)
#define TP_FIELDS(args...) args
#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
-static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _proto, _args, _fields) \
+static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _proto) \
{ \
size_t __event_len = 0; \
unsigned int __dynamic_len_idx = 0; \
#define TP_FIELDS(args...) args
#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
-static inline size_t __event_get_align__##_name(_proto) \
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _proto, _args, _fields) \
+static inline size_t __event_get_align__##_provider##___##_name(_proto) \
{ \
size_t __event_align = 1; \
_fields \
#define TP_FIELDS(args...) args
#undef TRACEPOINT_EVENT_CLASS
-#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \
-static void __event_probe__##_name(void *__data, _proto) \
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _proto, _args, _fields) \
+static void __event_probe__##_provider##___##_name(void *__data, _proto) \
{ \
struct ltt_event *__event = __data; \
struct ltt_channel *__chan = __event->chan; \
struct lttng_ust_lib_ring_buffer_ctx __ctx; \
size_t __event_len, __event_align; \
size_t __dynamic_len_idx = 0; \
- size_t __dynamic_len[_TP_ARRAY_SIZE(__event_fields___##_name)]; \
+ size_t __dynamic_len[_TP_ARRAY_SIZE(__event_fields___##_provider##___##_name)]; \
int __ret; \
\
if (0) \
return; \
if (caa_unlikely(!CMM_ACCESS_ONCE(__event->enabled))) \
return; \
- __event_len = __event_get_size__##_name(__dynamic_len, _args); \
- __event_align = __event_get_align__##_name(_args); \
+ __event_len = __event_get_size__##_provider##___##_name(__dynamic_len, _args); \
+ __event_align = __event_get_align__##_provider##___##_name(_args); \
lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \
__event_align, -1, __chan->handle); \
__ret = __chan->ops->event_reserve(&__ctx, __event->id); \
}
#undef TRACEPOINT_EVENT_CLASS_NOARGS
-#define TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
-static void __event_probe__##_name(void *__data) \
+#define TRACEPOINT_EVENT_CLASS_NOARGS(_provider, _name, _fields) \
+static void __event_probe__##_provider##___##_name(void *__data) \
{ \
struct ltt_event *__event = __data; \
struct ltt_channel *__chan = __event->chan; \
ret = lttng_metadata_printf(session,
"event {\n"
- " name = %s;\n"
+ " name = \"%s\";\n"
" id = %u;\n"
" stream_id = %u;\n",
event->desc->name,
#include <lttng/tracepoint.h>
-TRACEPOINT_EVENT(lttng_metadata,
+TRACEPOINT_EVENT(lttng, metadata,
TP_PROTO(const char *str),
}
printf("Fork test program, parent pid is %d\n", getpid());
- tracepoint(ust_tests_fork_before_fork);
+ tracepoint(ust_tests_fork, before_fork);
result = fork();
if (result == -1) {
printf("Child pid is %d\n", getpid());
- tracepoint(ust_tests_fork_after_fork_child, getpid());
+ tracepoint(ust_tests_fork, after_fork_child, getpid());
result = execve(argv[1], args, env);
if (result == -1) {
return 1;
}
} else {
- tracepoint(ust_tests_fork_after_fork_parent);
+ tracepoint(ust_tests_fork, after_fork_parent);
}
return 0;
{
printf("IN FORK2\n");
- tracepoint(ust_tests_fork_after_exec);
+ tracepoint(ust_tests_fork, after_exec);
return 0;
}
#include <lttng/tracepoint.h>
#include <sys/types.h>
-TRACEPOINT_EVENT_NOARGS(ust_tests_fork_before_fork,
+TRACEPOINT_EVENT_NOARGS(ust_tests_fork, before_fork,
TP_FIELDS()
)
-TRACEPOINT_EVENT(ust_tests_fork_after_fork_child,
+TRACEPOINT_EVENT(ust_tests_fork, after_fork_child,
TP_PROTO(pid_t pid),
TP_ARGS(pid),
TP_FIELDS(
)
)
-TRACEPOINT_EVENT_NOARGS(ust_tests_fork_after_fork_parent,
+TRACEPOINT_EVENT_NOARGS(ust_tests_fork, after_fork_parent,
TP_FIELDS()
)
-TRACEPOINT_EVENT_NOARGS(ust_tests_fork_after_exec,
+TRACEPOINT_EVENT_NOARGS(ust_tests_fork, after_exec,
TP_FIELDS()
)
void inthandler(int sig)
{
printf("in SIGUSR1 handler\n");
- tracepoint(ust_tests_hello_tptest_sighandler);
+ tracepoint(ust_tests_hello, tptest_sighandler);
}
int init_int_handler(void)
//for (i = 0; i < 50; i++) {
for (i = 0; i < 1000000; i++) {
netint = htonl(i);
- tracepoint(ust_tests_hello_tptest, i, netint, values,
+ tracepoint(ust_tests_hello, tptest, i, netint, values,
text, strlen(text), dbl, flt);
//usleep(100000);
}
#include <lttng/tracepoint.h>
-TRACEPOINT_EVENT(ust_tests_hello_tptest,
+TRACEPOINT_EVENT(ust_tests_hello, tptest,
TP_PROTO(int anint, int netint, long *values,
char *text, size_t textlen,
double doublearg, float floatarg),
)
)
-TRACEPOINT_EVENT_NOARGS(ust_tests_hello_tptest_sighandler,
+TRACEPOINT_EVENT_NOARGS(ust_tests_hello, tptest_sighandler,
TP_FIELDS()
)