xref: /linux/include/trace/define_custom_trace.h (revision dec1c62e91ba268ab2a6e339d4d7a59287d5eba1)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Trace files that want to automate creation of all tracepoints defined
4  * in their file should include this file. The following are macros that the
5  * trace file may define:
6  *
7  * TRACE_SYSTEM defines the system the tracepoint is for
8  *
9  * TRACE_INCLUDE_FILE if the file name is something other than TRACE_SYSTEM.h
10  *     This macro may be defined to tell define_trace.h what file to include.
11  *     Note, leave off the ".h".
12  *
13  * TRACE_INCLUDE_PATH if the path is something other than core kernel include/trace
14  *     then this macro can define the path to use. Note, the path is relative to
15  *     define_trace.h, not the file including it. Full path names for out of tree
16  *     modules must be used.
17  */
18 
19 #ifdef CREATE_CUSTOM_TRACE_EVENTS
20 
21 /* Prevent recursion */
22 #undef CREATE_CUSTOM_TRACE_EVENTS
23 
24 #include <linux/stringify.h>
25 
26 #undef TRACE_CUSTOM_EVENT
27 #define TRACE_CUSTOM_EVENT(name, proto, args, tstruct, assign, print)
28 
29 #undef DEFINE_CUSTOM_EVENT
30 #define DEFINE_CUSTOM_EVENT(template, name, proto, args)
31 
32 #undef TRACE_INCLUDE
33 #undef __TRACE_INCLUDE
34 
35 #ifndef TRACE_INCLUDE_FILE
36 # define TRACE_INCLUDE_FILE TRACE_SYSTEM
37 # define UNDEF_TRACE_INCLUDE_FILE
38 #endif
39 
40 #ifndef TRACE_INCLUDE_PATH
41 # define __TRACE_INCLUDE(system) <trace/events/system.h>
42 # define UNDEF_TRACE_INCLUDE_PATH
43 #else
44 # define __TRACE_INCLUDE(system) __stringify(TRACE_INCLUDE_PATH/system.h)
45 #endif
46 
47 # define TRACE_INCLUDE(system) __TRACE_INCLUDE(system)
48 
49 /* Let the trace headers be reread */
50 #define TRACE_CUSTOM_MULTI_READ
51 
52 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
53 
54 #ifdef TRACEPOINTS_ENABLED
55 #include <trace/trace_custom_events.h>
56 #endif
57 
58 #undef TRACE_CUSTOM_EVENT
59 #undef DECLARE_CUSTOM_EVENT_CLASS
60 #undef DEFINE_CUSTOM_EVENT
61 #undef TRACE_CUSTOM_MULTI_READ
62 
63 /* Only undef what we defined in this file */
64 #ifdef UNDEF_TRACE_INCLUDE_FILE
65 # undef TRACE_INCLUDE_FILE
66 # undef UNDEF_TRACE_INCLUDE_FILE
67 #endif
68 
69 #ifdef UNDEF_TRACE_INCLUDE_PATH
70 # undef TRACE_INCLUDE_PATH
71 # undef UNDEF_TRACE_INCLUDE_PATH
72 #endif
73 
74 /* We may be processing more files */
75 #define CREATE_CUSTOM_TRACE_POINTS
76 
77 #endif /* CREATE_CUSTOM_TRACE_POINTS */
78