X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=include%2Fust%2Fust_trace.h;h=fe27da2b11e1c44aad99c10c0d8d22e89810bf13;hb=8161463975e218e0833d31ab1577a7ceb9e8e9f3;hp=f2ccbe21e868fbbc579b871f3026f1a6a9283ff9;hpb=f37142a4e245fd3d5d0014877c568f626dbfbbde;p=ust.git diff --git a/include/ust/ust_trace.h b/include/ust/ust_trace.h index f2ccbe2..fe27da2 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,71 +16,72 @@ * 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 - * to a printf + * This whole file is currently a dummy. */ #include -/* - * 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, \ - 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)); +#undef TRACEPOINT_EVENT +#define TRACEPOINT_EVENT(name, proto, args, fields) \ + TRACEPOINT_EVENT_CLASS(name, \ + TP_PARAMS(proto), \ + TP_PARAMS(args), \ + TP_PARAMS(fields)); \ + TRACEPOINT_EVENT_INSTANCE(name, name, TP_PARAMS(proto), \ + TP_PARAMS(args)); -#undef __field -#define __field(type, item) type item; +#undef TRACEPOINT_EVENT_NOARGS +#define TRACEPOINT_EVENT_NOARGS(name, fields) \ + TRACEPOINT_EVENT_CLASS_NOARGS(name, \ + TP_PARAMS(fields)); \ + TRACEPOINT_EVENT_INSTANCE_NOARGS(name, name); -#undef TP_STRUCT__entry -#define TP_STRUCT__entry(args...) args +#undef tp_field +#define tp_field(type, item, src) type item; -#undef TP_printf -#define TP_printf(fmt, args...) fmt "\n", args +#undef TP_FIELDS +#define TP_FIELDS(args...) args -#undef TP_fast_assign -#define TP_fast_assign(args...) args +#undef TRACEPOINT_EVENT_INSTANCE +#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) -#undef DEFINE_TRACE_EVENT -#define DEFINE_TRACE_EVENT(template, name, proto, args) +#undef TRACEPOINT_EVENT_INSTANCE_NOARGS +#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) - -#undef DECLARE_TRACE_EVENT_CLASS -#define DECLARE_TRACE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \ +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(name, proto, args, fields) \ struct trace_raw_##name { \ - tstruct \ + fields \ }; \ static void trace_printf_##name(void *dummy, proto) \ { \ - struct trace_raw_##name entry_struct, *__entry; \ - __entry = &entry_struct; \ - { assign }; \ - \ - printf(print); \ } \ - static inline int register_event_##name(void *data) \ + struct trace_event __event_##name = { \ + __tpstrtab_##name, \ + }; \ + static struct trace_event * const __event_ptrs_##name \ + __attribute__((used, section("__trace_events_ptrs"))) = \ + &__event_##name; \ + \ + static void __attribute__((constructor)) init_##name() \ { \ - return register_tracepoint(name, trace_printf_##name, data); \ - } \ - static inline int unregister_event_##name(void *data) \ + void *dummy = NULL; \ + __register_tracepoint(name, trace_printf_##name, dummy);\ + } + +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#define TRACEPOINT_EVENT_CLASS_NOARGS(name, fields) \ + struct trace_raw_##name { \ + fields \ + }; \ + static void trace_printf_##name(void *dummy) \ { \ - return unregister_tracepoint(name, trace_printf_##name, data); \ } \ struct trace_event __event_##name = { \ __tpstrtab_##name, \ - register_event_##name, \ - unregister_event_##name \ }; \ static struct trace_event * const __event_ptrs_##name \ __attribute__((used, section("__trace_events_ptrs"))) = \ @@ -88,8 +90,7 @@ static void __attribute__((constructor)) init_##name() \ { \ void *dummy = NULL; \ - register_tracepoint(name, trace_printf_##name, dummy); \ + __register_tracepoint(name, trace_printf_##name, dummy);\ } - #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)