From: Mathieu Desnoyers Date: Fri, 22 Apr 2011 18:22:44 +0000 (-0400) Subject: Tracepoints: Introduce DEFINE/DECLARE_TRACEPOINT, TRACEPOINT_EVENT... X-Git-Tag: v1.9.1~391 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8d71973c9b5596f5732741975d4334a3abb3ba2a;p=lttng-ust.git Tracepoints: Introduce DEFINE/DECLARE_TRACEPOINT, TRACEPOINT_EVENT... * Instrumentation API change * Introduce the upcoming "TRACEPOINT_EVENT" API: TRACEPOINT_EVENT TRACEPOINT_CREATE_PROBES TRACEPOINT_EVENT_LIB And move the current tracepoint declaration/definition to a more standard name (these will become internal API when we switch to TRACEPOINT_EVENT): DEFINE_TRACEPOINT DECLARE_TRACEPOINT Signed-off-by: Mathieu Desnoyers --- diff --git a/include/ust/define_trace.h b/include/ust/define_trace.h index b4a29fb2..3d295416 100644 --- a/include/ust/define_trace.h +++ b/include/ust/define_trace.h @@ -32,33 +32,33 @@ * modules must be used. */ -#ifdef CREATE_TRACE_POINTS +#ifdef TRACEPOINT_CREATE_PROBES /* Prevent recursion */ -#undef CREATE_TRACE_POINTS +#undef TRACEPOINT_CREATE_PROBES #include -#undef TRACE_EVENT -#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ - DEFINE_TRACE(name) +#undef TRACEPOINT_EVENT +#define TRACEPOINT_EVENT(name, proto, args, tstruct, assign, print) \ + DEFINE_TRACEPOINT(name) -#undef TRACE_EVENT_FN -#define TRACE_EVENT_FN(name, proto, args, tstruct, \ +#undef TRACEPOINT_EVENT_FN +#define TRACEPOINT_EVENT_FN(name, proto, args, tstruct, \ assign, print, reg, unreg) \ - DEFINE_TRACE_FN(name, reg, unreg) + DEFINE_TRACEPOINT_FN(name, reg, unreg) -#undef DEFINE_TRACE_EVENT -#define DEFINE_TRACE_EVENT(template, name, proto, args) \ - DEFINE_TRACE(name) +#undef DEFINE_TRACEPOINT_EVENT +#define DEFINE_TRACEPOINT_EVENT(template, name, proto, args) \ + DEFINE_TRACEPOINT(name) -#undef DEFINE_TRACE_EVENT_PRINT -#define DEFINE_TRACE_EVENT_PRINT(template, name, proto, args, print) \ - DEFINE_TRACE(name) +#undef DEFINE_TRACEPOINT_EVENT_PRINT +#define DEFINE_TRACEPOINT_EVENT_PRINT(template, name, proto, args, print) \ + DEFINE_TRACEPOINT(name) -#undef DECLARE_TRACE -#define DECLARE_TRACE(name, proto, args) \ - DEFINE_TRACE(name) +#undef DECLARE_TRACEPOINT +#define DECLARE_TRACEPOINT(name, proto, args) \ + DEFINE_TRACEPOINT(name) #undef TRACE_INCLUDE #undef __TRACE_INCLUDE @@ -82,21 +82,21 @@ #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) -/* Make all open coded DECLARE_TRACE nops */ -#undef DECLARE_TRACE -#define DECLARE_TRACE(name, proto, args) +/* Make all open coded DECLARE_TRACEPOINT nops */ +#undef DECLARE_TRACEPOINT +#define DECLARE_TRACEPOINT(name, proto, args) #ifndef CONFIG_NO_EVENT_TRACING #include #endif -#undef TRACE_EVENT -#undef TRACE_EVENT_FN -#undef DECLARE_TRACE_EVENT_CLASS -#undef DEFINE_TRACE_EVENT -#undef DEFINE_TRACE_EVENT_PRINT +#undef TRACEPOINT_EVENT +#undef TRACEPOINT_EVENT_FN +#undef DECLARE_TRACEPOINT_EVENT_CLASS +#undef DEFINE_TRACEPOINT_EVENT +#undef DEFINE_TRACEPOINT_EVENT_PRINT #undef TRACE_HEADER_MULTI_READ -#undef DECLARE_TRACE +#undef DECLARE_TRACEPOINT /* Only undef what we defined in this file */ #ifdef UNDEF_TRACE_INCLUDE_FILE @@ -110,6 +110,6 @@ #endif /* We may be processing more files */ -#define CREATE_TRACE_POINTS +#define TRACEPOINT_CREATE_PROBES -#endif /* CREATE_TRACE_POINTS */ +#endif /* TRACEPOINT_CREATE_PROBES */ diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h index 278a9c19..b9557d57 100644 --- a/include/ust/tracepoint.h +++ b/include/ust/tracepoint.h @@ -95,7 +95,7 @@ struct tracepoint { * 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_TRACE(name, proto, args, data_proto, data_args) \ +#define __DECLARE_TRACEPOINT(name, proto, args, data_proto, data_args) \ extern struct tracepoint __tracepoint_##name; \ static inline void __trace_##name(proto) \ { \ @@ -116,7 +116,7 @@ struct tracepoint { data); \ } -#define DEFINE_TRACE_FN(name, reg, unreg) \ +#define DEFINE_TRACEPOINT_FN(name, reg, unreg) \ static const char __tpstrtab_##name[] \ __attribute__((section("__tracepoints_strings"))) = #name; \ struct tracepoint __tracepoint_##name \ @@ -126,14 +126,14 @@ struct tracepoint { __attribute__((used, section("__tracepoints_ptrs"))) = \ &__tracepoint_##name; -#define DEFINE_TRACE(name) \ - DEFINE_TRACE_FN(name, NULL, NULL) +#define DEFINE_TRACEPOINT(name) \ + DEFINE_TRACEPOINT_FN(name, NULL, NULL) extern void tracepoint_update_probe_range(struct tracepoint * const *begin, struct tracepoint * const *end); #else /* !CONFIG_TRACEPOINTS */ -#define __DECLARE_TRACE(name, proto, args) \ +#define __DECLARE_TRACEPOINT(name, proto, args) \ static inline void trace_##name(proto) \ { } \ static inline void _trace_##name(proto) \ @@ -147,7 +147,7 @@ extern void tracepoint_update_probe_range(struct tracepoint * const *begin, return -ENOSYS; \ } -#define DEFINE_TRACE(name) +#define DEFINE_TRACEPOINT(name) #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) #define EXPORT_TRACEPOINT_SYMBOL(name) @@ -157,24 +157,24 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin, #endif /* CONFIG_TRACEPOINTS */ /* - * The need for the DECLARE_TRACE_NOARGS() is to handle the prototype + * The need for the DECLARE_TRACEPOINT_NOARGS() is to handle the prototype * (void). "void" is a special value in a function prototype and can - * not be combined with other arguments. Since the DECLARE_TRACE() + * not be combined with other arguments. Since the DECLARE_TRACEPOINT() * macro adds a data element at the beginning of the prototype, * we need a way to differentiate "(void *data, proto)" from * "(void *data, void)". The second prototype is invalid. * - * DECLARE_TRACE_NOARGS() passes "void" as the tracepoint prototype + * DECLARE_TRACEPOINT_NOARGS() passes "void" as the tracepoint prototype * and "void *__tp_cb_data" as the callback prototype. * - * DECLARE_TRACE() passes "proto" as the tracepoint protoype and + * DECLARE_TRACEPOINT() passes "proto" as the tracepoint protoype and * "void *__tp_cb_data, proto" as the callback prototype. */ -#define DECLARE_TRACE_NOARGS(name) \ - __DECLARE_TRACE(name, void, , void *__tp_cb_data, __tp_cb_data) +#define DECLARE_TRACEPOINT_NOARGS(name) \ + __DECLARE_TRACEPOINT(name, void, , void *__tp_cb_data, __tp_cb_data) -#define DECLARE_TRACE(name, proto, args) \ - __DECLARE_TRACE(name, TP_PARAMS(proto), TP_PARAMS(args),\ +#define DECLARE_TRACEPOINT(name, proto, args) \ + __DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args),\ TP_PARAMS(void *__tp_cb_data, proto), \ TP_PARAMS(__tp_cb_data, args)) @@ -246,21 +246,21 @@ extern int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_star } -#ifndef TRACE_EVENT +#ifndef TRACEPOINT_EVENT /* - * For use with the TRACE_EVENT macro: + * For use with the TRACEPOINT_EVENT macro: * * We define a tracepoint, its arguments, its printf format * and its 'fast binary record' layout. * - * Firstly, name your tracepoint via TRACE_EVENT(name : the + * Firstly, name your tracepoint via TRACEPOINT_EVENT(name : the * 'subsystem_event' notation is fine. * * Think about this whole construct as the * 'trace_sched_switch() function' from now on. * * - * TRACE_EVENT(sched_switch, + * TRACEPOINT_EVENT(sched_switch, * * * * * A function has a regular function arguments @@ -344,7 +344,7 @@ extern int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_star * tracing setup. * * A set of (un)registration functions can be passed to the variant - * TRACE_EVENT_FN to perform any (un)registration work. + * TRACEPOINT_EVENT_FN to perform any (un)registration work. */ struct trace_event { @@ -383,7 +383,7 @@ extern int trace_event_register_lib(struct trace_event * const *start_trace_even extern int trace_event_unregister_lib(struct trace_event * const *start_trace_events); -#define TRACE_EVENT_LIB \ +#define TRACEPOINT_EVENT_LIB \ extern struct trace_event * const __start___trace_events_ptrs[] \ __attribute__((weak, visibility("hidden"))); \ extern struct trace_event * const __stop___trace_events_ptrs[] \ @@ -404,19 +404,19 @@ extern int trace_event_unregister_lib(struct trace_event * const *start_trace_ev trace_event_unregister_lib(__start___trace_events_ptrs);\ } -#define DECLARE_TRACE_EVENT_CLASS(name, proto, args, tstruct, assign, print) -#define DEFINE_TRACE_EVENT(template, name, proto, args) \ - DECLARE_TRACE(name, TP_PARAMS(proto), TP_PARAMS(args)) -#define DEFINE_TRACE_EVENT_PRINT(template, name, proto, args, print) \ - DECLARE_TRACE(name, TP_PARAMS(proto), TP_PARAMS(args)) +#define DECLARE_TRACEPOINT_EVENT_CLASS(name, proto, args, tstruct, assign, print) +#define DEFINE_TRACEPOINT_EVENT(template, name, proto, args) \ + DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args)) +#define DEFINE_TRACEPOINT_EVENT_PRINT(template, name, proto, args, print)\ + DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args)) -#define TRACE_EVENT(name, proto, args, struct, assign, print) \ - DECLARE_TRACE(name, TP_PARAMS(proto), TP_PARAMS(args)) -#define TRACE_EVENT_FN(name, proto, args, struct, \ +#define TRACEPOINT_EVENT(name, proto, args, struct, assign, print) \ + DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args)) +#define TRACEPOINT_EVENT_FN(name, proto, args, struct, \ assign, print, reg, unreg) \ - DECLARE_TRACE(name, TP_PARAMS(proto), TP_PARAMS(args)) + DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args)) -#endif /* ifdef TRACE_EVENT (see note above) */ +#endif /* ifdef TRACEPOINT_EVENT (see note above) */ #endif /* _UST_TRACEPOINT_H */ diff --git a/include/ust/ust_trace.h b/include/ust/ust_trace.h index f2ccbe21..dfbe1664 100644 --- a/include/ust/ust_trace.h +++ b/include/ust/ust_trace.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2009 Steven Rostedt * Copyright (C) 2010 Nils Carlson + * Copyright (C) 2011 Mathieu Desnoyers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -15,11 +16,10 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * */ /* - * This whole file is currently a dummy, mapping a TRACE_EVENT + * This whole file is currently a dummy, mapping a TRACEPOINT_EVENT * to a printf */ @@ -29,15 +29,15 @@ * Stage 1. Create a struct and a printf calling function * that is connected to the tracepoint at load time. */ -#undef TRACE_EVENT -#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ - DECLARE_TRACE_EVENT_CLASS(name, \ +#undef TRACEPOINT_EVENT +#define TRACEPOINT_EVENT(name, proto, args, tstruct, assign, print) \ + DECLARE_TRACEPOINT_EVENT_CLASS(name, \ TP_PARAMS(proto), \ TP_PARAMS(args), \ TP_PARAMS(tstruct), \ TP_PARAMS(assign), \ TP_PARAMS(print)); \ - DEFINE_TRACE_EVENT(name, name, TP_PARAMS(proto), TP_PARAMS(args)); + DEFINE_TRACEPOINT_EVENT(name, name, TP_PARAMS(proto), TP_PARAMS(args)); #undef __field #define __field(type, item) type item; @@ -51,12 +51,12 @@ #undef TP_fast_assign #define TP_fast_assign(args...) args -#undef DEFINE_TRACE_EVENT -#define DEFINE_TRACE_EVENT(template, name, proto, args) +#undef DEFINE_TRACEPOINT_EVENT +#define DEFINE_TRACEPOINT_EVENT(template, name, proto, args) -#undef DECLARE_TRACE_EVENT_CLASS -#define DECLARE_TRACE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \ +#undef DECLARE_TRACEPOINT_EVENT_CLASS +#define DECLARE_TRACEPOINT_EVENT_CLASS(name, proto, args, tstruct, assign, print) \ struct trace_raw_##name { \ tstruct \ }; \ diff --git a/libust-initializer.c b/libust-initializer.c index 83635d64..efe707e5 100644 --- a/libust-initializer.c +++ b/libust-initializer.c @@ -13,4 +13,4 @@ UST_MARKER_LIB; TRACEPOINT_LIB; -TRACE_EVENT_LIB; +TRACEPOINT_EVENT_LIB; diff --git a/libust-initializer.h b/libust-initializer.h index b5d88acb..3c4e95bb 100644 --- a/libust-initializer.h +++ b/libust-initializer.h @@ -17,12 +17,12 @@ #undef TRACE_SYSTEM #define TRACE_SYSTEM ust_dummy -#if !defined(_TRACE_EVENT_TEST_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_EVENT_TEST_H +#if !defined(_TRACEPOINT_EVENT_TEST_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACEPOINT_EVENT_TEST_H #include -TRACE_EVENT(ust_dummy_event, +TRACEPOINT_EVENT(ust_dummy_event, TP_PROTO(int dummy_int), @@ -39,7 +39,7 @@ TRACE_EVENT(ust_dummy_event, TP_printf("dummy=%d", __entry->dummy) ); -#endif /* _TRACE_EVENT_TEST_H */ +#endif /* _TRACEPOINT_EVENT_TEST_H */ /* This part must be outside protection */ #undef TRACE_INCLUDE_PATH diff --git a/tests/hello/tp.c b/tests/hello/tp.c index 4eb7a274..05cd7a2d 100644 --- a/tests/hello/tp.c +++ b/tests/hello/tp.c @@ -27,7 +27,7 @@ struct hello_trace_struct hello_struct = { .message = "ehlo\n", }; -DEFINE_TRACE(hello_tptest); +DEFINE_TRACEPOINT(hello_tptest); void tptest_probe(void *data, int anint) { diff --git a/tests/hello/tp.h b/tests/hello/tp.h index 73819514..833cb40c 100644 --- a/tests/hello/tp.h +++ b/tests/hello/tp.h @@ -17,8 +17,8 @@ #include -DECLARE_TRACE(hello_tptest, - TP_PROTO(int anint), - TP_ARGS(anint)); +DECLARE_TRACEPOINT(hello_tptest, + TP_PROTO(int anint), + TP_ARGS(anint)); -DECLARE_TRACE_NOARGS(hello_tptest2); +DECLARE_TRACEPOINT_NOARGS(hello_tptest2); diff --git a/tests/register_test/register_test.c b/tests/register_test/register_test.c index 02225deb..8198a2c4 100644 --- a/tests/register_test/register_test.c +++ b/tests/register_test/register_test.c @@ -29,7 +29,7 @@ #include "usterr.h" #include "tp.h" -DEFINE_TRACE(hello_tptest); +DEFINE_TRACEPOINT(hello_tptest); struct hello_trace_struct { diff --git a/tests/register_test/tp.h b/tests/register_test/tp.h index f34f3054..ee5fd022 100644 --- a/tests/register_test/tp.h +++ b/tests/register_test/tp.h @@ -17,6 +17,6 @@ #include -DECLARE_TRACE(hello_tptest, - TP_PROTO(int anint), - TP_ARGS(anint)); +DECLARE_TRACEPOINT(hello_tptest, + TP_PROTO(int anint), + TP_ARGS(anint)); diff --git a/tests/trace_event/trace_event_test.c b/tests/trace_event/trace_event_test.c index b38e7ad2..8e87846e 100644 --- a/tests/trace_event/trace_event_test.c +++ b/tests/trace_event/trace_event_test.c @@ -17,7 +17,7 @@ #include #include -#define CREATE_TRACE_POINTS +#define TRACEPOINT_CREATE_PROBES #include "trace_event_test.h" int main(int argc, char * argv[]) diff --git a/tests/trace_event/trace_event_test.h b/tests/trace_event/trace_event_test.h index b9843bfe..38f0b466 100644 --- a/tests/trace_event/trace_event_test.h +++ b/tests/trace_event/trace_event_test.h @@ -17,12 +17,12 @@ #undef TRACE_SYSTEM #define TRACE_SYSTEM trace_event_test -#if !defined(_TRACE_EVENT_TEST_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_EVENT_TEST_H +#if !defined(_TRACEPOINT_EVENT_TEST_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACEPOINT_EVENT_TEST_H #include -TRACE_EVENT(test, +TRACEPOINT_EVENT(test, TP_PROTO(unsigned long time, unsigned long count), @@ -41,7 +41,7 @@ TRACE_EVENT(test, TP_printf("time=%lu count=%lu", __entry->time, __entry->count) ); -#endif /* _TRACE_EVENT_TEST_H */ +#endif /* _TRACEPOINT_EVENT_TEST_H */ /* This part must be outside protection */ #undef TRACE_INCLUDE_PATH diff --git a/tests/tracepoint/benchmark/tracepoint_benchmark.c b/tests/tracepoint/benchmark/tracepoint_benchmark.c index 5d239757..50a18470 100644 --- a/tests/tracepoint/benchmark/tracepoint_benchmark.c +++ b/tests/tracepoint/benchmark/tracepoint_benchmark.c @@ -30,7 +30,7 @@ #define NR_EVENTS 10000000 -DEFINE_TRACE(ust_event); +DEFINE_TRACEPOINT(ust_event); void tp_probe(void *data, unsigned int p1); diff --git a/tests/tracepoint/benchmark/tracepoint_benchmark.h b/tests/tracepoint/benchmark/tracepoint_benchmark.h index a9fcb192..f96f4622 100644 --- a/tests/tracepoint/benchmark/tracepoint_benchmark.h +++ b/tests/tracepoint/benchmark/tracepoint_benchmark.h @@ -1,3 +1,3 @@ #include -DECLARE_TRACE(ust_event, TP_PROTO(unsigned int v), TP_ARGS(v)); +DECLARE_TRACEPOINT(ust_event, TP_PROTO(unsigned int v), TP_ARGS(v)); diff --git a/tests/tracepoint/tracepoint_test.c b/tests/tracepoint/tracepoint_test.c index 78171b8f..34cdb115 100644 --- a/tests/tracepoint/tracepoint_test.c +++ b/tests/tracepoint/tracepoint_test.c @@ -32,8 +32,8 @@ #include #include "tracepoint_test.h" -DEFINE_TRACE(ust_event); -DEFINE_TRACE(ust_event2); +DEFINE_TRACEPOINT(ust_event); +DEFINE_TRACEPOINT(ust_event2); static struct message msg_probe3 = { .payload = "probe3", diff --git a/tests/tracepoint/tracepoint_test.h b/tests/tracepoint/tracepoint_test.h index 6b4dcdbc..1899fe4e 100644 --- a/tests/tracepoint/tracepoint_test.h +++ b/tests/tracepoint/tracepoint_test.h @@ -1,7 +1,7 @@ #include -DECLARE_TRACE(ust_event, TP_PROTO(unsigned int v), TP_ARGS(v)); -DECLARE_TRACE(ust_event2, TP_PROTO(unsigned int v), TP_ARGS(v)); +DECLARE_TRACEPOINT(ust_event, TP_PROTO(unsigned int v), TP_ARGS(v)); +DECLARE_TRACEPOINT(ust_event2, TP_PROTO(unsigned int v), TP_ARGS(v)); struct message { char *payload;