Merge tag 'dm-3.16-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device...
[deliverable/linux.git] / drivers / staging / sep / sep_trace_events.h
CommitLineData
ff3d9c3c
MA
1/*
2 * If TRACE_SYSTEM is defined, that will be the directory created
3 * in the ftrace directory under /sys/kernel/debug/tracing/events/<system>
4 *
5 * The define_trace.h below will also look for a file name of
6 * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here.
7 * In this case, it would look for sample.h
8 *
9 * If the header name will be different than the system name
10 * (as in this case), then you can override the header name that
11 * define_trace.h will look up by defining TRACE_INCLUDE_FILE
12 *
13 * This file is called trace-events-sample.h but we want the system
14 * to be called "sample". Therefore we must define the name of this
15 * file:
16 *
17 * #define TRACE_INCLUDE_FILE trace-events-sample
18 *
19 * As we do an the bottom of this file.
20 *
21 * Notice that TRACE_SYSTEM should be defined outside of #if
22 * protection, just like TRACE_INCLUDE_FILE.
23 */
24#undef TRACE_SYSTEM
25#define TRACE_SYSTEM sep
26
27/*
28 * Notice that this file is not protected like a normal header.
29 * We also must allow for rereading of this file. The
30 *
31 * || defined(TRACE_HEADER_MULTI_READ)
32 *
33 * serves this purpose.
34 */
35#if !defined(_TRACE_SEP_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ)
36#define _TRACE_SEP_EVENTS_H
37
38#ifdef SEP_PERF_DEBUG
39#define SEP_TRACE_FUNC_IN() trace_sep_func_start(__func__, 0)
40#define SEP_TRACE_FUNC_OUT(branch) trace_sep_func_end(__func__, branch)
41#define SEP_TRACE_EVENT(branch) trace_sep_misc_event(__func__, branch)
42#else
43#define SEP_TRACE_FUNC_IN()
44#define SEP_TRACE_FUNC_OUT(branch)
45#define SEP_TRACE_EVENT(branch)
46#endif
47
48
49/*
50 * All trace headers should include tracepoint.h, until we finally
51 * make it into a standard header.
52 */
53#include <linux/tracepoint.h>
54
6d8a94e6
CG
55/*
56 * Since use str*cpy in header file, better to include string.h, directly.
57 */
58#include <linux/string.h>
59
ff3d9c3c
MA
60/*
61 * The TRACE_EVENT macro is broken up into 5 parts.
62 *
63 * name: name of the trace point. This is also how to enable the tracepoint.
64 * A function called trace_foo_bar() will be created.
65 *
66 * proto: the prototype of the function trace_foo_bar()
67 * Here it is trace_foo_bar(char *foo, int bar).
68 *
69 * args: must match the arguments in the prototype.
70 * Here it is simply "foo, bar".
71 *
72 * struct: This defines the way the data will be stored in the ring buffer.
73 * There are currently two types of elements. __field and __array.
74 * a __field is broken up into (type, name). Where type can be any
75 * type but an array.
76 * For an array. there are three fields. (type, name, size). The
77 * type of elements in the array, the name of the field and the size
78 * of the array.
79 *
80 * __array( char, foo, 10) is the same as saying char foo[10].
81 *
82 * fast_assign: This is a C like function that is used to store the items
83 * into the ring buffer.
84 *
85 * printk: This is a way to print out the data in pretty print. This is
86 * useful if the system crashes and you are logging via a serial line,
87 * the data can be printed to the console using this "printk" method.
88 *
89 * Note, that for both the assign and the printk, __entry is the handler
90 * to the data structure in the ring buffer, and is defined by the
91 * TP_STRUCT__entry.
92 */
93TRACE_EVENT(sep_func_start,
94
95 TP_PROTO(const char *name, int branch),
96
97 TP_ARGS(name, branch),
98
99 TP_STRUCT__entry(
100 __array(char, name, 20)
101 __field(int, branch)
102 ),
103
104 TP_fast_assign(
6d8a94e6 105 strlcpy(__entry->name, name, 20);
ff3d9c3c
MA
106 __entry->branch = branch;
107 ),
108
109 TP_printk("func_start %s %d", __entry->name, __entry->branch)
110);
111
112TRACE_EVENT(sep_func_end,
113
114 TP_PROTO(const char *name, int branch),
115
116 TP_ARGS(name, branch),
117
118 TP_STRUCT__entry(
119 __array(char, name, 20)
120 __field(int, branch)
121 ),
122
123 TP_fast_assign(
6d8a94e6 124 strlcpy(__entry->name, name, 20);
ff3d9c3c
MA
125 __entry->branch = branch;
126 ),
127
128 TP_printk("func_end %s %d", __entry->name, __entry->branch)
129);
130
131TRACE_EVENT(sep_misc_event,
132
133 TP_PROTO(const char *name, int branch),
134
135 TP_ARGS(name, branch),
136
137 TP_STRUCT__entry(
138 __array(char, name, 20)
139 __field(int, branch)
140 ),
141
142 TP_fast_assign(
6d8a94e6 143 strlcpy(__entry->name, name, 20);
ff3d9c3c
MA
144 __entry->branch = branch;
145 ),
146
147 TP_printk("misc_event %s %d", __entry->name, __entry->branch)
148);
149
150
151#endif
152
153/***** NOTICE! The #if protection ends here. *****/
154
155
156/*
157 * There are several ways I could have done this. If I left out the
158 * TRACE_INCLUDE_PATH, then it would default to the kernel source
159 * include/trace/events directory.
160 *
161 * I could specify a path from the define_trace.h file back to this
162 * file.
163 *
164 * #define TRACE_INCLUDE_PATH ../../samples/trace_events
165 *
166 * But the safest and easiest way to simply make it use the directory
167 * that the file is in is to add in the Makefile:
168 *
169 * CFLAGS_trace-events-sample.o := -I$(src)
170 *
171 * This will make sure the current path is part of the include
172 * structure for our file so that define_trace.h can find it.
173 *
174 * I could have made only the top level directory the include:
175 *
176 * CFLAGS_trace-events-sample.o := -I$(PWD)
177 *
178 * And then let the path to this directory be the TRACE_INCLUDE_PATH:
179 *
180 * #define TRACE_INCLUDE_PATH samples/trace_events
181 *
182 * But then if something defines "samples" or "trace_events" as a macro
183 * then we could risk that being converted too, and give us an unexpected
184 * result.
185 */
186#undef TRACE_INCLUDE_PATH
187#undef TRACE_INCLUDE_FILE
188#define TRACE_INCLUDE_PATH .
189/*
190 * TRACE_INCLUDE_FILE is not needed if the filename and TRACE_SYSTEM are equal
191 */
192#define TRACE_INCLUDE_FILE sep_trace_events
193#include <trace/define_trace.h>
This page took 0.190674 seconds and 5 git commands to generate.