Import TRACE_EVENT macro from the kernel v3
[ust.git] / include / ust / ust_trace.h
diff --git a/include/ust/ust_trace.h b/include/ust/ust_trace.h
new file mode 100644 (file)
index 0000000..098c5f8
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2009     Steven Rostedt <srostedt@redhat.com>
+ * Copyright (C) 2010     Nils Carlson <nils.carlson@ericsson.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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
+ */
+
+/*
+ * 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,                                 \
+                                 PARAMS(proto),                        \
+                                 PARAMS(args),                         \
+                                 PARAMS(tstruct),                      \
+                                 PARAMS(assign),                       \
+                                 PARAMS(print));                       \
+       DEFINE_TRACE_EVENT(name, name, PARAMS(proto), PARAMS(args));
+
+#undef __field
+#define __field(type, item)            type    item;
+
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args
+
+#undef TP_printf
+#define TP_printf(fmt, args...) fmt "\n", args
+
+#undef TP_fast_assign
+#define TP_fast_assign(args...) args
+
+#undef DEFINE_TRACE_EVENT
+#define DEFINE_TRACE_EVENT(template, name, proto, args)
+
+
+#undef DECLARE_TRACE_EVENT_CLASS
+#define DECLARE_TRACE_EVENT_CLASS(name, proto, args, tstruct, assign, print)   \
+       struct trace_raw_##name {                                       \
+               tstruct                                                 \
+       };                                                              \
+       static void trace_printf_##name(proto)                          \
+       {                                                               \
+               struct trace_raw_##name entry_struct, *__entry;         \
+               __entry = &entry_struct;                                \
+               { assign };                                     \
+                                                                       \
+               printf(print);                                          \
+       }                                                               \
+       static void __attribute__((constructor)) init_##name()          \
+       {                                                               \
+               printf("connecting tracepoint " #name "\n");            \
+               register_trace_##name(trace_printf_##name);             \
+       }
+
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
This page took 0.023318 seconds and 4 git commands to generate.