From: Mathieu Desnoyers Date: Sat, 30 Mar 2013 00:38:18 +0000 (-0400) Subject: Introduce API to remap event names exposed by LTTng X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=76e4f0175e477c9ad0368523e3c0dd2cbbfd3678;p=deliverable%2Flttng-modules.git Introduce API to remap event names exposed by LTTng Some kernel event providers don't follow naming hierarchy. Rename them internally within LTTng. Signed-off-by: Mathieu Desnoyers --- diff --git a/probes/define_trace.h b/probes/define_trace.h index a518390b..96d80a58 100644 --- a/probes/define_trace.h +++ b/probes/define_trace.h @@ -53,6 +53,37 @@ */ #include +#undef TRACE_EVENT_MAP +#define TRACE_EVENT_MAP(name, map, proto, args, tstruct, assign, print) \ + DEFINE_TRACE(name) + +#undef TRACE_EVENT_CONDITION_MAP +#define TRACE_EVENT_CONDITION_MAP(name, map, proto, args, cond, tstruct, assign, print) \ + TRACE_EVENT(name, \ + PARAMS(proto), \ + PARAMS(args), \ + PARAMS(tstruct), \ + PARAMS(assign), \ + PARAMS(print)) + +#undef TRACE_EVENT_FN_MAP +#define TRACE_EVENT_FN_MAP(name, map, proto, args, tstruct, \ + assign, print, reg, unreg) \ + DEFINE_TRACE_FN(name, reg, unreg) + +#undef DEFINE_EVENT_MAP +#define DEFINE_EVENT_MAP(template, name, map, proto, args) \ + DEFINE_TRACE(name) + +#undef DEFINE_EVENT_PRINT_MAP +#define DEFINE_EVENT_PRINT_MAP(template, name, map, proto, args, print) \ + DEFINE_TRACE(name) + +#undef DEFINE_EVENT_CONDITION_MAP +#define DEFINE_EVENT_CONDITION_MAP(template, name, map, proto, args, cond) \ + DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) + + #undef TRACE_EVENT #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ DEFINE_TRACE(name) @@ -120,10 +151,16 @@ #undef TRACE_EVENT #undef TRACE_EVENT_FN #undef TRACE_EVENT_CONDITION -#undef DECLARE_EVENT_CLASS #undef DEFINE_EVENT #undef DEFINE_EVENT_PRINT #undef DEFINE_EVENT_CONDITION +#undef TRACE_EVENT_MAP +#undef TRACE_EVENT_FN_MAP +#undef TRACE_EVENT_CONDITION_MAP +#undef DECLARE_EVENT_CLASS +#undef DEFINE_EVENT_MAP +#undef DEFINE_EVENT_PRINT_MAP +#undef DEFINE_EVENT_CONDITION_MAP #undef TRACE_HEADER_MULTI_READ /* Only undef what we defined in this file */ diff --git a/probes/lttng-events-reset.h b/probes/lttng-events-reset.h index 7355e183..44e8ba59 100644 --- a/probes/lttng-events-reset.h +++ b/probes/lttng-events-reset.h @@ -86,11 +86,11 @@ #undef DECLARE_EVENT_CLASS_NOARGS #define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print) -#undef DEFINE_EVENT -#define DEFINE_EVENT(_template, _name, _proto, _args) +#undef DEFINE_EVENT_MAP +#define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args) -#undef DEFINE_EVENT_NOARGS -#define DEFINE_EVENT_NOARGS(_template, _name) +#undef DEFINE_EVENT_MAP_NOARGS +#define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) #undef TRACE_EVENT_FLAGS #define TRACE_EVENT_FLAGS(name, value) diff --git a/probes/lttng-events.h b/probes/lttng-events.h index 33cabcf9..8a3a886b 100644 --- a/probes/lttng-events.h +++ b/probes/lttng-events.h @@ -32,6 +32,48 @@ * Macro declarations used for all stages. */ +/* + * LTTng name mapping macros. LTTng remaps some of the kernel events to + * enforce name-spacing. + */ +#undef TRACE_EVENT_MAP +#define TRACE_EVENT_MAP(name, map, proto, args, tstruct, assign, print) \ + DECLARE_EVENT_CLASS(map, \ + PARAMS(proto), \ + PARAMS(args), \ + PARAMS(tstruct), \ + PARAMS(assign), \ + PARAMS(print)) \ + DEFINE_EVENT_MAP(map, name, map, PARAMS(proto), PARAMS(args)) + +#undef TRACE_EVENT_MAP_NOARGS +#define TRACE_EVENT_MAP_NOARGS(name, map, tstruct, assign, print) \ + DECLARE_EVENT_CLASS_NOARGS(map, \ + PARAMS(tstruct), \ + PARAMS(assign), \ + PARAMS(print)) \ + DEFINE_EVENT_MAP_NOARGS(map, name, map) + +#undef DEFINE_EVENT_PRINT_MAP +#define DEFINE_EVENT_PRINT_MAP(template, name, map, proto, args, print) \ + DEFINE_EVENT_MAP(template, name, map, PARAMS(proto), PARAMS(args)) + +/* Callbacks are meaningless to LTTng. */ +#undef TRACE_EVENT_FN_MAP +#define TRACE_EVENT_FN_MAP(name, map, proto, args, tstruct, \ + assign, print, reg, unreg) \ + TRACE_EVENT_MAP(name, map, PARAMS(proto), PARAMS(args), \ + PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \ + +#undef TRACE_EVENT_CONDITION_MAP +#define TRACE_EVENT_CONDITION_MAP(name, map, proto, args, cond, tstruct, assign, print) \ + TRACE_EVENT_MAP(name, map, \ + PARAMS(proto), \ + PARAMS(args), \ + PARAMS(tstruct), \ + PARAMS(assign), \ + PARAMS(print)) + /* * DECLARE_EVENT_CLASS can be used to add a generic function * handlers for events. That is, if all events have the same @@ -43,34 +85,50 @@ */ #undef TRACE_EVENT -#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ - DECLARE_EVENT_CLASS(name, \ - PARAMS(proto), \ - PARAMS(args), \ - PARAMS(tstruct), \ - PARAMS(assign), \ - PARAMS(print)) \ - DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args)) +#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ + TRACE_EVENT_MAP(name, name, \ + PARAMS(proto), \ + PARAMS(args), \ + PARAMS(tstruct), \ + PARAMS(assign), \ + PARAMS(print)) #undef TRACE_EVENT_NOARGS -#define TRACE_EVENT_NOARGS(name, tstruct, assign, print) \ - DECLARE_EVENT_CLASS_NOARGS(name, \ - PARAMS(tstruct), \ - PARAMS(assign), \ - PARAMS(print)) \ - DEFINE_EVENT_NOARGS(name, name) - +#define TRACE_EVENT_NOARGS(name, tstruct, assign, print) \ + TRACE_EVENT_MAP_NOARGS(name, name, \ + PARAMS(tstruct), \ + PARAMS(assign), \ + PARAMS(print)) #undef DEFINE_EVENT_PRINT #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ - DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) + DEFINE_EVENT_PRINT_MAP(template, name, name, \ + PARAMS(proto), PARAMS(args), PARAMS(print_)) -/* Callbacks are meaningless to LTTng. */ #undef TRACE_EVENT_FN #define TRACE_EVENT_FN(name, proto, args, tstruct, \ assign, print, reg, unreg) \ - TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \ - PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \ + TRACE_EVENT_FN_MAP(name, name, PARAMS(proto), PARAMS(args), \ + PARAMS(tstruct), PARAMS(assign), PARAMS(print), \ + PARAMS(reg), PARAMS(unreg)) \ + +#undef DEFINE_EVENT +#define DEFINE_EVENT(template, name, proto, args) \ + DEFINE_EVENT_MAP(template, name, name, PARAMS(proto), PARAMS(args)) + +#undef DEFINE_EVENT_NOARGS +#define DEFINE_EVENT_NOARGS(template, name) \ + DEFINE_EVENT_MAP_NOARGS(template, name, name) + +#undef TRACE_EVENT_CONDITION +#define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \ + TRACE_EVENT_CONDITION_MAP(name, name, \ + PARAMS(proto), \ + PARAMS(args), \ + PARAMS(cond), \ + PARAMS(tstruct), \ + PARAMS(assign), \ + PARAMS(print)) /* * Stage 1 of the trace events. @@ -88,12 +146,12 @@ #undef TP_ARGS #define TP_ARGS(args...) args -#undef DEFINE_EVENT -#define DEFINE_EVENT(_template, _name, _proto, _args) \ +#undef DEFINE_EVENT_MAP +#define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args) \ void trace_##_name(_proto); -#undef DEFINE_EVENT_NOARGS -#define DEFINE_EVENT_NOARGS(_template, _name) \ +#undef DEFINE_EVENT_MAP_NOARGS +#define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) \ void trace_##_name(void *__data); #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) @@ -256,19 +314,19 @@ static void __event_probe__##_name(void *__data); #define TP_PROBE_CB(_template) &__event_probe__##_template #endif -#undef DEFINE_EVENT_NOARGS -#define DEFINE_EVENT_NOARGS(_template, _name) \ -static const struct lttng_event_desc __event_desc___##_name = { \ +#undef DEFINE_EVENT_MAP_NOARGS +#define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) \ +static const struct lttng_event_desc __event_desc___##_map = { \ .fields = __event_fields___##_template, \ - .name = #_name, \ + .name = #_map, \ .probe_callback = (void *) TP_PROBE_CB(_template), \ .nr_fields = ARRAY_SIZE(__event_fields___##_template), \ .owner = THIS_MODULE, \ }; -#undef DEFINE_EVENT -#define DEFINE_EVENT(_template, _name, _proto, _args) \ - DEFINE_EVENT_NOARGS(_template, _name) +#undef DEFINE_EVENT_MAP +#define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args) \ + DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) @@ -283,13 +341,13 @@ static const struct lttng_event_desc __event_desc___##_name = { \ #include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */ -#undef DEFINE_EVENT_NOARGS -#define DEFINE_EVENT_NOARGS(_template, _name) \ - &__event_desc___##_name, +#undef DEFINE_EVENT_MAP_NOARGS +#define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) \ + &__event_desc___##_map, -#undef DEFINE_EVENT -#define DEFINE_EVENT(_template, _name, _proto, _args) \ - DEFINE_EVENT_NOARGS(_template, _name) +#undef DEFINE_EVENT_MAP +#define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args) \ + DEFINE_EVENT_MAP_NOARGS(_template, _name, _map) #define TP_ID1(_token, _system) _token##_system #define TP_ID(_token, _system) TP_ID1(_token, _system)