Tracepoints: Introduce DEFINE/DECLARE_TRACEPOINT, TRACEPOINT_EVENT...
[ust.git] / include / ust / ust_trace.h
CommitLineData
22d72948
NC
1/*
2 * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com>
3 * Copyright (C) 2010 Nils Carlson <nils.carlson@ericsson.com>
8d71973c 4 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
22d72948
NC
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
f37142a4
MD
8 * License as published by the Free Software Foundation;
9 * version 2.1 of the License.
22d72948
NC
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22d72948
NC
19 */
20
21/*
8d71973c 22 * This whole file is currently a dummy, mapping a TRACEPOINT_EVENT
22d72948
NC
23 * to a printf
24 */
25
0c0686ee
NC
26#include <stdio.h>
27
22d72948
NC
28/*
29 * Stage 1. Create a struct and a printf calling function
30 * that is connected to the tracepoint at load time.
31 */
8d71973c
MD
32#undef TRACEPOINT_EVENT
33#define TRACEPOINT_EVENT(name, proto, args, tstruct, assign, print) \
34 DECLARE_TRACEPOINT_EVENT_CLASS(name, \
b979b346
MD
35 TP_PARAMS(proto), \
36 TP_PARAMS(args), \
37 TP_PARAMS(tstruct), \
38 TP_PARAMS(assign), \
39 TP_PARAMS(print)); \
8d71973c 40 DEFINE_TRACEPOINT_EVENT(name, name, TP_PARAMS(proto), TP_PARAMS(args));
22d72948
NC
41
42#undef __field
43#define __field(type, item) type item;
44
45#undef TP_STRUCT__entry
46#define TP_STRUCT__entry(args...) args
47
48#undef TP_printf
49#define TP_printf(fmt, args...) fmt "\n", args
50
51#undef TP_fast_assign
52#define TP_fast_assign(args...) args
53
8d71973c
MD
54#undef DEFINE_TRACEPOINT_EVENT
55#define DEFINE_TRACEPOINT_EVENT(template, name, proto, args)
22d72948
NC
56
57
8d71973c
MD
58#undef DECLARE_TRACEPOINT_EVENT_CLASS
59#define DECLARE_TRACEPOINT_EVENT_CLASS(name, proto, args, tstruct, assign, print) \
22d72948
NC
60 struct trace_raw_##name { \
61 tstruct \
62 }; \
9dec086e 63 static void trace_printf_##name(void *dummy, proto) \
22d72948
NC
64 { \
65 struct trace_raw_##name entry_struct, *__entry; \
66 __entry = &entry_struct; \
67 { assign }; \
68 \
69 printf(print); \
70 } \
0c0686ee
NC
71 static inline int register_event_##name(void *data) \
72 { \
cc7b66ba 73 return register_tracepoint(name, trace_printf_##name, data); \
0c0686ee
NC
74 } \
75 static inline int unregister_event_##name(void *data) \
76 { \
cc7b66ba 77 return unregister_tracepoint(name, trace_printf_##name, data); \
0c0686ee 78 } \
fc1caebc 79 struct trace_event __event_##name = { \
0c0686ee
NC
80 __tpstrtab_##name, \
81 register_event_##name, \
82 unregister_event_##name \
83 }; \
fc1caebc
MD
84 static struct trace_event * const __event_ptrs_##name \
85 __attribute__((used, section("__trace_events_ptrs"))) = \
86 &__event_##name; \
87 \
22d72948
NC
88 static void __attribute__((constructor)) init_##name() \
89 { \
fbae86d6 90 void *dummy = NULL; \
cc7b66ba 91 register_tracepoint(name, trace_printf_##name, dummy); \
22d72948
NC
92 }
93
94
95#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
This page took 0.031633 seconds and 4 git commands to generate.