Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Stage 1 of the trace events. |
| 4 | * |
Hou Pengyang | eba12ab | 2015-03-03 21:48:18 +0000 | [diff] [blame] | 5 | * Override the macros in the event tracepoint header <trace/events/XXX.h> |
| 6 | * to include the following: |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 7 | * |
Steven Rostedt (Red Hat) | a723776 | 2015-05-13 15:27:47 -0400 | [diff] [blame] | 8 | * struct trace_event_raw_<call> { |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 9 | * struct trace_entry ent; |
| 10 | * <type> <item>; |
| 11 | * <type2> <item2>[<len>]; |
| 12 | * [...] |
| 13 | * }; |
| 14 | * |
| 15 | * The <type> <item> is created by the __field(type, item) macro or |
| 16 | * the __array(type2, item2, len) macro. |
| 17 | * We simply do "type item;", and that will create the fields |
| 18 | * in the structure. |
| 19 | */ |
| 20 | |
Steven Rostedt (Red Hat) | af658dc | 2015-04-29 14:36:05 -0400 | [diff] [blame] | 21 | #include <linux/trace_events.h> |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 22 | |
Steven Rostedt (Red Hat) | acd388f | 2015-03-31 14:37:12 -0400 | [diff] [blame] | 23 | #ifndef TRACE_SYSTEM_VAR |
| 24 | #define TRACE_SYSTEM_VAR TRACE_SYSTEM |
| 25 | #endif |
| 26 | |
| 27 | #define __app__(x, y) str__##x##y |
| 28 | #define __app(x, y) __app__(x, y) |
| 29 | |
| 30 | #define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name) |
| 31 | |
| 32 | #define TRACE_MAKE_SYSTEM_STR() \ |
| 33 | static const char TRACE_SYSTEM_STRING[] = \ |
| 34 | __stringify(TRACE_SYSTEM) |
| 35 | |
| 36 | TRACE_MAKE_SYSTEM_STR(); |
| 37 | |
Steven Rostedt (Red Hat) | 0c564a5 | 2015-03-24 17:58:09 -0400 | [diff] [blame] | 38 | #undef TRACE_DEFINE_ENUM |
| 39 | #define TRACE_DEFINE_ENUM(a) \ |
Jeremy Linton | 00f4b65 | 2017-05-31 16:56:43 -0500 | [diff] [blame] | 40 | static struct trace_eval_map __used __initdata \ |
Steven Rostedt (Red Hat) | 0c564a5 | 2015-03-24 17:58:09 -0400 | [diff] [blame] | 41 | __##TRACE_SYSTEM##_##a = \ |
| 42 | { \ |
| 43 | .system = TRACE_SYSTEM_STRING, \ |
Jeremy Linton | 00f4b65 | 2017-05-31 16:56:43 -0500 | [diff] [blame] | 44 | .eval_string = #a, \ |
| 45 | .eval_value = a \ |
Steven Rostedt (Red Hat) | 0c564a5 | 2015-03-24 17:58:09 -0400 | [diff] [blame] | 46 | }; \ |
Jeremy Linton | 00f4b65 | 2017-05-31 16:56:43 -0500 | [diff] [blame] | 47 | static struct trace_eval_map __used \ |
Joe Perches | 33def84 | 2020-10-21 19:36:07 -0700 | [diff] [blame] | 48 | __section("_ftrace_eval_map") \ |
Steven Rostedt (Red Hat) | 0c564a5 | 2015-03-24 17:58:09 -0400 | [diff] [blame] | 49 | *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a |
| 50 | |
Jeremy Linton | 4f0dfd7 | 2017-05-31 16:56:50 -0500 | [diff] [blame] | 51 | #undef TRACE_DEFINE_SIZEOF |
| 52 | #define TRACE_DEFINE_SIZEOF(a) \ |
| 53 | static struct trace_eval_map __used __initdata \ |
| 54 | __##TRACE_SYSTEM##_##a = \ |
| 55 | { \ |
| 56 | .system = TRACE_SYSTEM_STRING, \ |
| 57 | .eval_string = "sizeof(" #a ")", \ |
| 58 | .eval_value = sizeof(a) \ |
| 59 | }; \ |
| 60 | static struct trace_eval_map __used \ |
Joe Perches | 33def84 | 2020-10-21 19:36:07 -0700 | [diff] [blame] | 61 | __section("_ftrace_eval_map") \ |
Jeremy Linton | 4f0dfd7 | 2017-05-31 16:56:50 -0500 | [diff] [blame] | 62 | *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a |
| 63 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 64 | /* |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 65 | * DECLARE_EVENT_CLASS can be used to add a generic function |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 66 | * handlers for events. That is, if all events have the same |
| 67 | * parameters and just have distinct trace points. |
| 68 | * Each tracepoint can be defined with DEFINE_EVENT and that |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 69 | * will map the DECLARE_EVENT_CLASS to the tracepoint. |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 70 | * |
| 71 | * TRACE_EVENT is a one to one mapping between tracepoint and template. |
| 72 | */ |
| 73 | #undef TRACE_EVENT |
| 74 | #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 75 | DECLARE_EVENT_CLASS(name, \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 76 | PARAMS(proto), \ |
| 77 | PARAMS(args), \ |
| 78 | PARAMS(tstruct), \ |
| 79 | PARAMS(assign), \ |
| 80 | PARAMS(print)); \ |
| 81 | DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args)); |
| 82 | |
| 83 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 84 | #undef __field |
| 85 | #define __field(type, item) type item; |
| 86 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 87 | #undef __field_ext |
| 88 | #define __field_ext(type, item, filter_type) type item; |
| 89 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 90 | #undef __field_struct |
| 91 | #define __field_struct(type, item) type item; |
| 92 | |
| 93 | #undef __field_struct_ext |
| 94 | #define __field_struct_ext(type, item, filter_type) type item; |
| 95 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 96 | #undef __array |
| 97 | #define __array(type, item, len) type item[len]; |
| 98 | |
| 99 | #undef __dynamic_array |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 100 | #define __dynamic_array(type, item, len) u32 __data_loc_##item; |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 101 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 102 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 103 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 104 | |
Steven Rostedt (VMware) | 883b4ae | 2021-07-16 20:55:10 -0400 | [diff] [blame] | 105 | #undef __string_len |
| 106 | #define __string_len(item, src, len) __dynamic_array(char, item, -1) |
| 107 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 108 | #undef __bitmask |
| 109 | #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1) |
| 110 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 111 | #undef __rel_dynamic_array |
| 112 | #define __rel_dynamic_array(type, item, len) u32 __rel_loc_##item; |
| 113 | |
| 114 | #undef __rel_string |
| 115 | #define __rel_string(item, src) __rel_dynamic_array(char, item, -1) |
| 116 | |
| 117 | #undef __rel_string_len |
| 118 | #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1) |
| 119 | |
| 120 | #undef __rel_bitmask |
| 121 | #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1) |
| 122 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 123 | #undef TP_STRUCT__entry |
| 124 | #define TP_STRUCT__entry(args...) args |
| 125 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 126 | #undef DECLARE_EVENT_CLASS |
| 127 | #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) \ |
Steven Rostedt (Red Hat) | a723776 | 2015-05-13 15:27:47 -0400 | [diff] [blame] | 128 | struct trace_event_raw_##name { \ |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 129 | struct trace_entry ent; \ |
| 130 | tstruct \ |
Kees Cook | c6d777a | 2022-01-25 14:00:37 -0800 | [diff] [blame] | 131 | char __data[]; \ |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 132 | }; \ |
| 133 | \ |
Steven Rostedt (Red Hat) | 2425bcb | 2015-05-05 11:45:27 -0400 | [diff] [blame] | 134 | static struct trace_event_class event_class_##name; |
Steven Rostedt | 8f08201 | 2010-04-20 10:47:33 -0400 | [diff] [blame] | 135 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 136 | #undef DEFINE_EVENT |
| 137 | #define DEFINE_EVENT(template, name, proto, args) \ |
Steven Rostedt (Red Hat) | 2425bcb | 2015-05-05 11:45:27 -0400 | [diff] [blame] | 138 | static struct trace_event_call __used \ |
Jeff Mahoney | 86c38a3 | 2010-02-24 13:59:23 -0500 | [diff] [blame] | 139 | __attribute__((__aligned__(4))) event_##name |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 140 | |
Steven Rostedt | f5abaa1 | 2013-06-20 11:44:44 -0400 | [diff] [blame] | 141 | #undef DEFINE_EVENT_FN |
| 142 | #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \ |
| 143 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 144 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 145 | #undef DEFINE_EVENT_PRINT |
| 146 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ |
| 147 | DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) |
| 148 | |
Josh Stone | 9741987 | 2009-08-24 14:43:13 -0700 | [diff] [blame] | 149 | /* Callbacks are meaningless to ftrace. */ |
| 150 | #undef TRACE_EVENT_FN |
Frederic Weisbecker | 0dd7b74 | 2009-08-28 00:50:06 +0200 | [diff] [blame] | 151 | #define TRACE_EVENT_FN(name, proto, args, tstruct, \ |
| 152 | assign, print, reg, unreg) \ |
Frederic Weisbecker | 819ce45 | 2010-07-20 18:41:24 +0200 | [diff] [blame] | 153 | TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \ |
| 154 | PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \ |
Josh Stone | 9741987 | 2009-08-24 14:43:13 -0700 | [diff] [blame] | 155 | |
Denis Kirjanov | 2701121 | 2015-12-14 23:18:05 +0300 | [diff] [blame] | 156 | #undef TRACE_EVENT_FN_COND |
| 157 | #define TRACE_EVENT_FN_COND(name, proto, args, cond, tstruct, \ |
| 158 | assign, print, reg, unreg) \ |
| 159 | TRACE_EVENT_CONDITION(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \ |
| 160 | PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \ |
| 161 | |
Frederic Weisbecker | 1ed0c59 | 2010-11-18 01:46:57 +0100 | [diff] [blame] | 162 | #undef TRACE_EVENT_FLAGS |
| 163 | #define TRACE_EVENT_FLAGS(name, value) \ |
Frederic Weisbecker | 53cf810b | 2010-11-18 02:11:42 +0100 | [diff] [blame] | 164 | __TRACE_EVENT_FLAGS(name, value) |
Frederic Weisbecker | 1ed0c59 | 2010-11-18 01:46:57 +0100 | [diff] [blame] | 165 | |
Peter Zijlstra | d5b5f39 | 2013-11-14 16:23:04 +0100 | [diff] [blame] | 166 | #undef TRACE_EVENT_PERF_PERM |
| 167 | #define TRACE_EVENT_PERF_PERM(name, expr...) \ |
| 168 | __TRACE_EVENT_PERF_PERM(name, expr) |
| 169 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 170 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 171 | |
| 172 | /* |
| 173 | * Stage 2 of the trace events. |
| 174 | * |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 175 | * Include the following: |
| 176 | * |
Steven Rostedt (Red Hat) | 62323a1 | 2015-05-13 15:33:52 -0400 | [diff] [blame] | 177 | * struct trace_event_data_offsets_<call> { |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 178 | * u32 <item1>; |
| 179 | * u32 <item2>; |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 180 | * [...] |
| 181 | * }; |
| 182 | * |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 183 | * The __dynamic_array() macro will create each u32 <item>, this is |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 184 | * to keep the offset of each array from the beginning of the event. |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 185 | * The size of an array is also encoded, in the higher 16 bits of <item>. |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 186 | */ |
| 187 | |
Steven Rostedt (Red Hat) | 0c564a5 | 2015-03-24 17:58:09 -0400 | [diff] [blame] | 188 | #undef TRACE_DEFINE_ENUM |
| 189 | #define TRACE_DEFINE_ENUM(a) |
| 190 | |
Jeremy Linton | 4f0dfd7 | 2017-05-31 16:56:50 -0500 | [diff] [blame] | 191 | #undef TRACE_DEFINE_SIZEOF |
| 192 | #define TRACE_DEFINE_SIZEOF(a) |
| 193 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 194 | #undef __field |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 195 | #define __field(type, item) |
| 196 | |
| 197 | #undef __field_ext |
| 198 | #define __field_ext(type, item, filter_type) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 199 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 200 | #undef __field_struct |
| 201 | #define __field_struct(type, item) |
| 202 | |
| 203 | #undef __field_struct_ext |
| 204 | #define __field_struct_ext(type, item, filter_type) |
| 205 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 206 | #undef __array |
| 207 | #define __array(type, item, len) |
| 208 | |
| 209 | #undef __dynamic_array |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 210 | #define __dynamic_array(type, item, len) u32 item; |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 211 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 212 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 213 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 214 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 215 | #undef __bitmask |
| 216 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) |
| 217 | |
Steven Rostedt (VMware) | 883b4ae | 2021-07-16 20:55:10 -0400 | [diff] [blame] | 218 | #undef __string_len |
| 219 | #define __string_len(item, src, len) __dynamic_array(char, item, -1) |
| 220 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 221 | #undef __rel_dynamic_array |
| 222 | #define __rel_dynamic_array(type, item, len) u32 item; |
| 223 | |
| 224 | #undef __rel_string |
| 225 | #define __rel_string(item, src) __rel_dynamic_array(char, item, -1) |
| 226 | |
| 227 | #undef __rel_string_len |
| 228 | #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1) |
| 229 | |
| 230 | #undef __rel_bitmask |
| 231 | #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 232 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 233 | #undef DECLARE_EVENT_CLASS |
| 234 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt (Red Hat) | 62323a1 | 2015-05-13 15:33:52 -0400 | [diff] [blame] | 235 | struct trace_event_data_offsets_##call { \ |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 236 | tstruct; \ |
| 237 | }; |
| 238 | |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 239 | #undef DEFINE_EVENT |
| 240 | #define DEFINE_EVENT(template, name, proto, args) |
| 241 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 242 | #undef DEFINE_EVENT_PRINT |
Wei Yang | 61df16f | 2020-06-12 17:28:43 +0800 | [diff] [blame] | 243 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 244 | |
Frederic Weisbecker | 1ed0c59 | 2010-11-18 01:46:57 +0100 | [diff] [blame] | 245 | #undef TRACE_EVENT_FLAGS |
| 246 | #define TRACE_EVENT_FLAGS(event, flag) |
| 247 | |
Peter Zijlstra | d5b5f39 | 2013-11-14 16:23:04 +0100 | [diff] [blame] | 248 | #undef TRACE_EVENT_PERF_PERM |
| 249 | #define TRACE_EVENT_PERF_PERM(event, expr...) |
| 250 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 251 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 252 | |
| 253 | /* |
| 254 | * Stage 3 of the trace events. |
| 255 | * |
Hou Pengyang | eba12ab | 2015-03-03 21:48:18 +0000 | [diff] [blame] | 256 | * Override the macros in the event tracepoint header <trace/events/XXX.h> |
| 257 | * to include the following: |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 258 | * |
| 259 | * enum print_line_t |
Steven Rostedt (Red Hat) | 892c505 | 2015-05-05 14:18:11 -0400 | [diff] [blame] | 260 | * trace_raw_output_<call>(struct trace_iterator *iter, int flags) |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 261 | * { |
| 262 | * struct trace_seq *s = &iter->seq; |
Steven Rostedt (Red Hat) | a723776 | 2015-05-13 15:27:47 -0400 | [diff] [blame] | 263 | * struct trace_event_raw_<call> *field; <-- defined in stage 1 |
Lai Jiangshan | bc289ae | 2010-06-03 18:26:24 +0800 | [diff] [blame] | 264 | * struct trace_seq *p = &iter->tmp_seq; |
Masami Hiramatsu | 1600cbc | 2020-10-15 23:55:16 +0900 | [diff] [blame] | 265 | * |
| 266 | * -------(for event)------- |
| 267 | * |
| 268 | * struct trace_entry *entry; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 269 | * |
| 270 | * entry = iter->ent; |
| 271 | * |
Steven Rostedt | 32c0eda | 2010-04-23 10:38:03 -0400 | [diff] [blame] | 272 | * if (entry->type != event_<call>->event.type) { |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 273 | * WARN_ON_ONCE(1); |
| 274 | * return TRACE_TYPE_UNHANDLED; |
| 275 | * } |
| 276 | * |
| 277 | * field = (typeof(field))entry; |
| 278 | * |
Steven Whitehouse | 56d8bd3 | 2009-06-03 14:52:03 +0100 | [diff] [blame] | 279 | * trace_seq_init(p); |
Masami Hiramatsu | 1600cbc | 2020-10-15 23:55:16 +0900 | [diff] [blame] | 280 | * return trace_output_call(iter, <call>, <TP_printk> "\n"); |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 281 | * |
Masami Hiramatsu | 1600cbc | 2020-10-15 23:55:16 +0900 | [diff] [blame] | 282 | * ------(or, for event class)------ |
| 283 | * |
| 284 | * int ret; |
| 285 | * |
| 286 | * field = (typeof(field))iter->ent; |
| 287 | * |
| 288 | * ret = trace_raw_output_prep(iter, trace_event); |
| 289 | * if (ret != TRACE_TYPE_HANDLED) |
| 290 | * return ret; |
| 291 | * |
| 292 | * trace_event_printf(iter, <TP_printk> "\n"); |
| 293 | * |
| 294 | * return trace_handle_return(s); |
| 295 | * ------- |
| 296 | * } |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 297 | * |
| 298 | * This is the method used to print the raw event to the trace |
| 299 | * output format. Note, this is not needed if the data is read |
| 300 | * in binary. |
| 301 | */ |
| 302 | |
| 303 | #undef __entry |
| 304 | #define __entry field |
| 305 | |
| 306 | #undef TP_printk |
| 307 | #define TP_printk(fmt, args...) fmt "\n", args |
| 308 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 309 | #undef __get_dynamic_array |
| 310 | #define __get_dynamic_array(field) \ |
Li Zefan | 7d536cb | 2009-07-16 10:54:02 +0800 | [diff] [blame] | 311 | ((void *)__entry + (__entry->__data_loc_##field & 0xffff)) |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 312 | |
Steven Rostedt (Red Hat) | beba4bb | 2014-06-04 14:29:33 -0400 | [diff] [blame] | 313 | #undef __get_dynamic_array_len |
| 314 | #define __get_dynamic_array_len(field) \ |
| 315 | ((__entry->__data_loc_##field >> 16) & 0xffff) |
| 316 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 317 | #undef __get_str |
Daniel Bristot de Oliveira | 934de5f | 2016-07-01 20:44:34 -0300 | [diff] [blame] | 318 | #define __get_str(field) ((char *)__get_dynamic_array(field)) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 319 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 320 | #undef __get_rel_dynamic_array |
Masami Hiramatsu | 58c5724 | 2022-01-25 23:19:30 +0900 | [diff] [blame] | 321 | #define __get_rel_dynamic_array(field) \ |
| 322 | ((void *)__entry + \ |
| 323 | offsetof(typeof(*__entry), __rel_loc_##field) + \ |
| 324 | sizeof(__entry->__rel_loc_##field) + \ |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 325 | (__entry->__rel_loc_##field & 0xffff)) |
| 326 | |
| 327 | #undef __get_rel_dynamic_array_len |
| 328 | #define __get_rel_dynamic_array_len(field) \ |
| 329 | ((__entry->__rel_loc_##field >> 16) & 0xffff) |
| 330 | |
| 331 | #undef __get_rel_str |
| 332 | #define __get_rel_str(field) ((char *)__get_rel_dynamic_array(field)) |
| 333 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 334 | #undef __get_bitmask |
| 335 | #define __get_bitmask(field) \ |
| 336 | ({ \ |
| 337 | void *__bitmask = __get_dynamic_array(field); \ |
| 338 | unsigned int __bitmask_size; \ |
Steven Rostedt (Red Hat) | beba4bb | 2014-06-04 14:29:33 -0400 | [diff] [blame] | 339 | __bitmask_size = __get_dynamic_array_len(field); \ |
Steven Rostedt (Red Hat) | 645df98 | 2015-05-04 18:12:44 -0400 | [diff] [blame] | 340 | trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 341 | }) |
| 342 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 343 | #undef __get_rel_bitmask |
| 344 | #define __get_rel_bitmask(field) \ |
| 345 | ({ \ |
| 346 | void *__bitmask = __get_rel_dynamic_array(field); \ |
| 347 | unsigned int __bitmask_size; \ |
| 348 | __bitmask_size = __get_rel_dynamic_array_len(field); \ |
| 349 | trace_print_bitmask_seq(p, __bitmask, __bitmask_size); \ |
| 350 | }) |
| 351 | |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 352 | #undef __print_flags |
| 353 | #define __print_flags(flag, delim, flag_array...) \ |
| 354 | ({ \ |
Steven Rostedt | a48f494 | 2009-09-14 11:18:02 -0400 | [diff] [blame] | 355 | static const struct trace_print_flags __flags[] = \ |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 356 | { flag_array, { -1, NULL }}; \ |
Steven Rostedt (Red Hat) | 645df98 | 2015-05-04 18:12:44 -0400 | [diff] [blame] | 357 | trace_print_flags_seq(p, delim, flag, __flags); \ |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 358 | }) |
| 359 | |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 360 | #undef __print_symbolic |
| 361 | #define __print_symbolic(value, symbol_array...) \ |
| 362 | ({ \ |
| 363 | static const struct trace_print_flags symbols[] = \ |
| 364 | { symbol_array, { -1, NULL }}; \ |
Steven Rostedt (Red Hat) | 645df98 | 2015-05-04 18:12:44 -0400 | [diff] [blame] | 365 | trace_print_symbols_seq(p, value, symbols); \ |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 366 | }) |
| 367 | |
Ross Zwisler | d3213e8 | 2017-02-22 15:39:47 -0800 | [diff] [blame] | 368 | #undef __print_flags_u64 |
liubo | 2fc1b6f | 2011-04-19 09:35:28 +0800 | [diff] [blame] | 369 | #undef __print_symbolic_u64 |
| 370 | #if BITS_PER_LONG == 32 |
Ross Zwisler | d3213e8 | 2017-02-22 15:39:47 -0800 | [diff] [blame] | 371 | #define __print_flags_u64(flag, delim, flag_array...) \ |
| 372 | ({ \ |
| 373 | static const struct trace_print_flags_u64 __flags[] = \ |
| 374 | { flag_array, { -1, NULL } }; \ |
| 375 | trace_print_flags_seq_u64(p, delim, flag, __flags); \ |
| 376 | }) |
| 377 | |
liubo | 2fc1b6f | 2011-04-19 09:35:28 +0800 | [diff] [blame] | 378 | #define __print_symbolic_u64(value, symbol_array...) \ |
| 379 | ({ \ |
| 380 | static const struct trace_print_flags_u64 symbols[] = \ |
| 381 | { symbol_array, { -1, NULL } }; \ |
Steven Rostedt (Red Hat) | 645df98 | 2015-05-04 18:12:44 -0400 | [diff] [blame] | 382 | trace_print_symbols_seq_u64(p, value, symbols); \ |
liubo | 2fc1b6f | 2011-04-19 09:35:28 +0800 | [diff] [blame] | 383 | }) |
| 384 | #else |
Ross Zwisler | d3213e8 | 2017-02-22 15:39:47 -0800 | [diff] [blame] | 385 | #define __print_flags_u64(flag, delim, flag_array...) \ |
| 386 | __print_flags(flag, delim, flag_array) |
| 387 | |
liubo | 2fc1b6f | 2011-04-19 09:35:28 +0800 | [diff] [blame] | 388 | #define __print_symbolic_u64(value, symbol_array...) \ |
| 389 | __print_symbolic(value, symbol_array) |
| 390 | #endif |
| 391 | |
Kei Tokunaga | 5a2e399 | 2010-04-01 20:40:58 +0900 | [diff] [blame] | 392 | #undef __print_hex |
Daniel Borkmann | 2acae0d | 2017-01-25 02:28:16 +0100 | [diff] [blame] | 393 | #define __print_hex(buf, buf_len) \ |
Daniel Borkmann | 3898fac | 2017-02-02 17:09:54 +0100 | [diff] [blame] | 394 | trace_print_hex_seq(p, buf, buf_len, false) |
Daniel Borkmann | 2acae0d | 2017-01-25 02:28:16 +0100 | [diff] [blame] | 395 | |
| 396 | #undef __print_hex_str |
| 397 | #define __print_hex_str(buf, buf_len) \ |
Daniel Borkmann | 3898fac | 2017-02-02 17:09:54 +0100 | [diff] [blame] | 398 | trace_print_hex_seq(p, buf, buf_len, true) |
Kei Tokunaga | 5a2e399 | 2010-04-01 20:40:58 +0900 | [diff] [blame] | 399 | |
Dave Martin | 6ea2248 | 2015-01-28 12:48:53 +0000 | [diff] [blame] | 400 | #undef __print_array |
| 401 | #define __print_array(array, count, el_size) \ |
| 402 | ({ \ |
| 403 | BUILD_BUG_ON(el_size != 1 && el_size != 2 && \ |
| 404 | el_size != 4 && el_size != 8); \ |
Steven Rostedt (Red Hat) | 645df98 | 2015-05-04 18:12:44 -0400 | [diff] [blame] | 405 | trace_print_array_seq(p, array, count, el_size); \ |
Dave Martin | 6ea2248 | 2015-01-28 12:48:53 +0000 | [diff] [blame] | 406 | }) |
| 407 | |
Piotr Maziarz | ef56e04 | 2019-11-07 13:45:38 +0100 | [diff] [blame] | 408 | #undef __print_hex_dump |
| 409 | #define __print_hex_dump(prefix_str, prefix_type, \ |
| 410 | rowsize, groupsize, buf, len, ascii) \ |
| 411 | trace_print_hex_dump_seq(p, prefix_str, prefix_type, \ |
| 412 | rowsize, groupsize, buf, len, ascii) |
| 413 | |
Steven Rostedt | 62de4f2 | 2021-06-22 16:42:26 +0200 | [diff] [blame] | 414 | #undef __print_ns_to_secs |
| 415 | #define __print_ns_to_secs(value) \ |
| 416 | ({ \ |
| 417 | u64 ____val = (u64)(value); \ |
| 418 | do_div(____val, NSEC_PER_SEC); \ |
| 419 | ____val; \ |
| 420 | }) |
| 421 | |
| 422 | #undef __print_ns_without_secs |
| 423 | #define __print_ns_without_secs(value) \ |
| 424 | ({ \ |
| 425 | u64 ____val = (u64)(value); \ |
| 426 | (u32) do_div(____val, NSEC_PER_SEC); \ |
| 427 | }) |
| 428 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 429 | #undef DECLARE_EVENT_CLASS |
| 430 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt | 83f0d53 | 2010-02-16 10:38:47 -0500 | [diff] [blame] | 431 | static notrace enum print_line_t \ |
Steven Rostedt (Red Hat) | 892c505 | 2015-05-05 14:18:11 -0400 | [diff] [blame] | 432 | trace_raw_output_##call(struct trace_iterator *iter, int flags, \ |
| 433 | struct trace_event *trace_event) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 434 | { \ |
| 435 | struct trace_seq *s = &iter->seq; \ |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 436 | struct trace_seq __maybe_unused *p = &iter->tmp_seq; \ |
Steven Rostedt (Red Hat) | a723776 | 2015-05-13 15:27:47 -0400 | [diff] [blame] | 437 | struct trace_event_raw_##call *field; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 438 | int ret; \ |
| 439 | \ |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 440 | field = (typeof(field))iter->ent; \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 441 | \ |
Steven Rostedt (Red Hat) | 892c505 | 2015-05-05 14:18:11 -0400 | [diff] [blame] | 442 | ret = trace_raw_output_prep(iter, trace_event); \ |
Steven Rostedt (Red Hat) | 8e2e095 | 2014-11-14 11:42:06 -0500 | [diff] [blame] | 443 | if (ret != TRACE_TYPE_HANDLED) \ |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 444 | return ret; \ |
| 445 | \ |
Masami Hiramatsu | efbbdaa | 2020-10-15 23:55:07 +0900 | [diff] [blame] | 446 | trace_event_printf(iter, print); \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 447 | \ |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 448 | return trace_handle_return(s); \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 449 | } \ |
Steven Rostedt (Red Hat) | 3ad017b | 2015-05-13 15:35:44 -0400 | [diff] [blame] | 450 | static struct trace_event_functions trace_event_type_funcs_##call = { \ |
Steven Rostedt (Red Hat) | 892c505 | 2015-05-05 14:18:11 -0400 | [diff] [blame] | 451 | .trace = trace_raw_output_##call, \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 452 | }; |
Steven Rostedt | ff038f5 | 2009-11-18 20:27:27 -0500 | [diff] [blame] | 453 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 454 | #undef DEFINE_EVENT_PRINT |
| 455 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ |
Steven Rostedt | 83f0d53 | 2010-02-16 10:38:47 -0500 | [diff] [blame] | 456 | static notrace enum print_line_t \ |
Steven Rostedt (Red Hat) | 892c505 | 2015-05-05 14:18:11 -0400 | [diff] [blame] | 457 | trace_raw_output_##call(struct trace_iterator *iter, int flags, \ |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 458 | struct trace_event *event) \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 459 | { \ |
Steven Rostedt (Red Hat) | a723776 | 2015-05-13 15:27:47 -0400 | [diff] [blame] | 460 | struct trace_event_raw_##template *field; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 461 | struct trace_entry *entry; \ |
Lai Jiangshan | bc289ae | 2010-06-03 18:26:24 +0800 | [diff] [blame] | 462 | struct trace_seq *p = &iter->tmp_seq; \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 463 | \ |
| 464 | entry = iter->ent; \ |
| 465 | \ |
Steven Rostedt | 32c0eda | 2010-04-23 10:38:03 -0400 | [diff] [blame] | 466 | if (entry->type != event_##call.event.type) { \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 467 | WARN_ON_ONCE(1); \ |
| 468 | return TRACE_TYPE_UNHANDLED; \ |
| 469 | } \ |
| 470 | \ |
| 471 | field = (typeof(field))entry; \ |
| 472 | \ |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 473 | trace_seq_init(p); \ |
Steven Rostedt (Red Hat) | 892c505 | 2015-05-05 14:18:11 -0400 | [diff] [blame] | 474 | return trace_output_call(iter, #call, print); \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 475 | } \ |
Steven Rostedt (Red Hat) | 3ad017b | 2015-05-13 15:35:44 -0400 | [diff] [blame] | 476 | static struct trace_event_functions trace_event_type_funcs_##call = { \ |
Steven Rostedt (Red Hat) | 892c505 | 2015-05-05 14:18:11 -0400 | [diff] [blame] | 477 | .trace = trace_raw_output_##call, \ |
Steven Rostedt | 80decc7 | 2010-04-23 10:00:22 -0400 | [diff] [blame] | 478 | }; |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 479 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 480 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 481 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 482 | #undef __field_ext |
Peter Zijlstra | 04ae87a | 2019-10-24 22:26:59 +0200 | [diff] [blame] | 483 | #define __field_ext(_type, _item, _filter_type) { \ |
| 484 | .type = #_type, .name = #_item, \ |
| 485 | .size = sizeof(_type), .align = __alignof__(_type), \ |
| 486 | .is_signed = is_signed_type(_type), .filter_type = _filter_type }, |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 487 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 488 | #undef __field_struct_ext |
Peter Zijlstra | 04ae87a | 2019-10-24 22:26:59 +0200 | [diff] [blame] | 489 | #define __field_struct_ext(_type, _item, _filter_type) { \ |
| 490 | .type = #_type, .name = #_item, \ |
| 491 | .size = sizeof(_type), .align = __alignof__(_type), \ |
| 492 | 0, .filter_type = _filter_type }, |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 493 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 494 | #undef __field |
| 495 | #define __field(type, item) __field_ext(type, item, FILTER_OTHER) |
| 496 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 497 | #undef __field_struct |
| 498 | #define __field_struct(type, item) __field_struct_ext(type, item, FILTER_OTHER) |
| 499 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 500 | #undef __array |
Peter Zijlstra | 04ae87a | 2019-10-24 22:26:59 +0200 | [diff] [blame] | 501 | #define __array(_type, _item, _len) { \ |
| 502 | .type = #_type"["__stringify(_len)"]", .name = #_item, \ |
| 503 | .size = sizeof(_type[_len]), .align = __alignof__(_type), \ |
| 504 | .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER }, |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 505 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 506 | #undef __dynamic_array |
Peter Zijlstra | 04ae87a | 2019-10-24 22:26:59 +0200 | [diff] [blame] | 507 | #define __dynamic_array(_type, _item, _len) { \ |
| 508 | .type = "__data_loc " #_type "[]", .name = #_item, \ |
| 509 | .size = 4, .align = 4, \ |
| 510 | .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER }, |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 511 | |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 512 | #undef __string |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 513 | #define __string(item, src) __dynamic_array(char, item, -1) |
Frederic Weisbecker | 9cbf117 | 2009-04-19 04:51:29 +0200 | [diff] [blame] | 514 | |
Steven Rostedt (VMware) | 883b4ae | 2021-07-16 20:55:10 -0400 | [diff] [blame] | 515 | #undef __string_len |
| 516 | #define __string_len(item, src, len) __dynamic_array(char, item, -1) |
| 517 | |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 518 | #undef __bitmask |
| 519 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) |
| 520 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 521 | #undef __rel_dynamic_array |
| 522 | #define __rel_dynamic_array(_type, _item, _len) { \ |
| 523 | .type = "__rel_loc " #_type "[]", .name = #_item, \ |
| 524 | .size = 4, .align = 4, \ |
| 525 | .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER }, |
| 526 | |
| 527 | #undef __rel_string |
| 528 | #define __rel_string(item, src) __rel_dynamic_array(char, item, -1) |
| 529 | |
| 530 | #undef __rel_string_len |
| 531 | #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1) |
| 532 | |
| 533 | #undef __rel_bitmask |
| 534 | #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) |
| 535 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 536 | #undef DECLARE_EVENT_CLASS |
| 537 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \ |
Peter Zijlstra | 04ae87a | 2019-10-24 22:26:59 +0200 | [diff] [blame] | 538 | static struct trace_event_fields trace_event_fields_##call[] = { \ |
| 539 | tstruct \ |
| 540 | {} }; |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 541 | |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 542 | #undef DEFINE_EVENT_PRINT |
Wei Yang | 61df16f | 2020-06-12 17:28:43 +0800 | [diff] [blame] | 543 | #define DEFINE_EVENT_PRINT(template, name, proto, args, print) |
Steven Rostedt | e5bc972 | 2009-11-18 20:36:26 -0500 | [diff] [blame] | 544 | |
Steven Rostedt | f42c85e | 2009-04-13 12:25:37 -0400 | [diff] [blame] | 545 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 546 | |
| 547 | /* |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 548 | * remember the offset of each array from the beginning of the event. |
| 549 | */ |
| 550 | |
| 551 | #undef __entry |
| 552 | #define __entry entry |
| 553 | |
| 554 | #undef __field |
| 555 | #define __field(type, item) |
| 556 | |
Li Zefan | 43b51ea | 2009-08-07 10:33:22 +0800 | [diff] [blame] | 557 | #undef __field_ext |
| 558 | #define __field_ext(type, item, filter_type) |
| 559 | |
Steven Rostedt | 4d4c9cc | 2014-06-17 08:59:16 -0400 | [diff] [blame] | 560 | #undef __field_struct |
| 561 | #define __field_struct(type, item) |
| 562 | |
| 563 | #undef __field_struct_ext |
| 564 | #define __field_struct_ext(type, item, filter_type) |
| 565 | |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 566 | #undef __array |
| 567 | #define __array(type, item, len) |
| 568 | |
| 569 | #undef __dynamic_array |
| 570 | #define __dynamic_array(type, item, len) \ |
Filipe Brandenburger | 114e7b5 | 2014-02-28 21:32:17 -0800 | [diff] [blame] | 571 | __item_length = (len) * sizeof(type); \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 572 | __data_offsets->item = __data_size + \ |
| 573 | offsetof(typeof(*entry), __data); \ |
Filipe Brandenburger | 114e7b5 | 2014-02-28 21:32:17 -0800 | [diff] [blame] | 574 | __data_offsets->item |= __item_length << 16; \ |
| 575 | __data_size += __item_length; |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 576 | |
| 577 | #undef __string |
Steven Rostedt (Red Hat) | 4e58e54 | 2013-11-26 09:22:54 -0500 | [diff] [blame] | 578 | #define __string(item, src) __dynamic_array(char, item, \ |
| 579 | strlen((src) ? (const char *)(src) : "(null)") + 1) |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 580 | |
Steven Rostedt (VMware) | 883b4ae | 2021-07-16 20:55:10 -0400 | [diff] [blame] | 581 | #undef __string_len |
| 582 | #define __string_len(item, src, len) __dynamic_array(char, item, (len) + 1) |
| 583 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 584 | #undef __rel_dynamic_array |
| 585 | #define __rel_dynamic_array(type, item, len) \ |
| 586 | __item_length = (len) * sizeof(type); \ |
| 587 | __data_offsets->item = __data_size + \ |
| 588 | offsetof(typeof(*entry), __data) - \ |
| 589 | offsetof(typeof(*entry), __rel_loc_##item) - \ |
| 590 | sizeof(u32); \ |
| 591 | __data_offsets->item |= __item_length << 16; \ |
| 592 | __data_size += __item_length; |
| 593 | |
| 594 | #undef __rel_string |
| 595 | #define __rel_string(item, src) __rel_dynamic_array(char, item, \ |
| 596 | strlen((src) ? (const char *)(src) : "(null)") + 1) |
| 597 | |
| 598 | #undef __rel_string_len |
| 599 | #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, (len) + 1) |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 600 | /* |
| 601 | * __bitmask_size_in_bytes_raw is the number of bytes needed to hold |
| 602 | * num_possible_cpus(). |
| 603 | */ |
| 604 | #define __bitmask_size_in_bytes_raw(nr_bits) \ |
| 605 | (((nr_bits) + 7) / 8) |
| 606 | |
| 607 | #define __bitmask_size_in_longs(nr_bits) \ |
| 608 | ((__bitmask_size_in_bytes_raw(nr_bits) + \ |
| 609 | ((BITS_PER_LONG / 8) - 1)) / (BITS_PER_LONG / 8)) |
| 610 | |
| 611 | /* |
| 612 | * __bitmask_size_in_bytes is the number of bytes needed to hold |
| 613 | * num_possible_cpus() padded out to the nearest long. This is what |
| 614 | * is saved in the buffer, just to be consistent. |
| 615 | */ |
| 616 | #define __bitmask_size_in_bytes(nr_bits) \ |
| 617 | (__bitmask_size_in_longs(nr_bits) * (BITS_PER_LONG / 8)) |
| 618 | |
| 619 | #undef __bitmask |
| 620 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, \ |
| 621 | __bitmask_size_in_longs(nr_bits)) |
| 622 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 623 | #undef __rel_bitmask |
| 624 | #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, \ |
| 625 | __bitmask_size_in_longs(nr_bits)) |
| 626 | |
Ingo Molnar | 091ad36 | 2009-11-26 09:04:55 +0100 | [diff] [blame] | 627 | #undef DECLARE_EVENT_CLASS |
| 628 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
Steven Rostedt (Red Hat) | d0ee8f4 | 2015-05-13 15:40:23 -0400 | [diff] [blame] | 629 | static inline notrace int trace_event_get_offsets_##call( \ |
Steven Rostedt (Red Hat) | 62323a1 | 2015-05-13 15:33:52 -0400 | [diff] [blame] | 630 | struct trace_event_data_offsets_##call *__data_offsets, proto) \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 631 | { \ |
| 632 | int __data_size = 0; \ |
Filipe Brandenburger | 114e7b5 | 2014-02-28 21:32:17 -0800 | [diff] [blame] | 633 | int __maybe_unused __item_length; \ |
Steven Rostedt (Red Hat) | a723776 | 2015-05-13 15:27:47 -0400 | [diff] [blame] | 634 | struct trace_event_raw_##call __maybe_unused *entry; \ |
Li Zefan | 7fcb7c4 | 2009-06-01 15:35:46 +0800 | [diff] [blame] | 635 | \ |
| 636 | tstruct; \ |
| 637 | \ |
| 638 | return __data_size; \ |
| 639 | } |
| 640 | |
| 641 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 642 | |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 643 | /* |
| 644 | * Stage 4 of the trace events. |
| 645 | * |
Hou Pengyang | eba12ab | 2015-03-03 21:48:18 +0000 | [diff] [blame] | 646 | * Override the macros in the event tracepoint header <trace/events/XXX.h> |
| 647 | * to include the following: |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 648 | * |
| 649 | * For those macros defined with TRACE_EVENT: |
| 650 | * |
| 651 | * static struct trace_event_call event_<call>; |
| 652 | * |
| 653 | * static void trace_event_raw_event_<call>(void *__data, proto) |
| 654 | * { |
| 655 | * struct trace_event_file *trace_file = __data; |
| 656 | * struct trace_event_call *event_call = trace_file->event_call; |
| 657 | * struct trace_event_data_offsets_<call> __maybe_unused __data_offsets; |
| 658 | * unsigned long eflags = trace_file->flags; |
| 659 | * enum event_trigger_type __tt = ETT_NONE; |
| 660 | * struct ring_buffer_event *event; |
| 661 | * struct trace_event_raw_<call> *entry; <-- defined in stage 1 |
Steven Rostedt (VMware) | 1329249 | 2019-12-13 13:58:57 -0500 | [diff] [blame] | 662 | * struct trace_buffer *buffer; |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 663 | * unsigned long irq_flags; |
| 664 | * int __data_size; |
| 665 | * int pc; |
| 666 | * |
| 667 | * if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) { |
| 668 | * if (eflags & EVENT_FILE_FL_TRIGGER_MODE) |
| 669 | * event_triggers_call(trace_file, NULL); |
| 670 | * if (eflags & EVENT_FILE_FL_SOFT_DISABLED) |
| 671 | * return; |
| 672 | * } |
| 673 | * |
| 674 | * local_save_flags(irq_flags); |
| 675 | * pc = preempt_count(); |
| 676 | * |
| 677 | * __data_size = trace_event_get_offsets_<call>(&__data_offsets, args); |
| 678 | * |
| 679 | * event = trace_event_buffer_lock_reserve(&buffer, trace_file, |
| 680 | * event_<call>->event.type, |
| 681 | * sizeof(*entry) + __data_size, |
| 682 | * irq_flags, pc); |
| 683 | * if (!event) |
| 684 | * return; |
| 685 | * entry = ring_buffer_event_data(event); |
| 686 | * |
| 687 | * { <assign>; } <-- Here we assign the entries by the __field and |
| 688 | * __array macros. |
| 689 | * |
| 690 | * if (eflags & EVENT_FILE_FL_TRIGGER_COND) |
| 691 | * __tt = event_triggers_call(trace_file, entry); |
| 692 | * |
| 693 | * if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, |
| 694 | * &trace_file->flags)) |
| 695 | * ring_buffer_discard_commit(buffer, event); |
| 696 | * else if (!filter_check_discard(trace_file, entry, buffer, event)) |
| 697 | * trace_buffer_unlock_commit(buffer, event, irq_flags, pc); |
| 698 | * |
| 699 | * if (__tt) |
| 700 | * event_triggers_post_call(trace_file, __tt); |
| 701 | * } |
| 702 | * |
| 703 | * static struct trace_event ftrace_event_type_<call> = { |
| 704 | * .trace = trace_raw_output_<call>, <-- stage 2 |
| 705 | * }; |
| 706 | * |
| 707 | * static char print_fmt_<call>[] = <TP_printk>; |
| 708 | * |
| 709 | * static struct trace_event_class __used event_class_<template> = { |
| 710 | * .system = "<system>", |
Peter Zijlstra | 04ae87a | 2019-10-24 22:26:59 +0200 | [diff] [blame] | 711 | * .fields_array = trace_event_fields_<call>, |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 712 | * .fields = LIST_HEAD_INIT(event_class_##call.fields), |
| 713 | * .raw_init = trace_event_raw_init, |
| 714 | * .probe = trace_event_raw_event_##call, |
| 715 | * .reg = trace_event_reg, |
| 716 | * }; |
| 717 | * |
| 718 | * static struct trace_event_call event_<call> = { |
| 719 | * .class = event_class_<template>, |
| 720 | * { |
| 721 | * .tp = &__tracepoint_<call>, |
| 722 | * }, |
| 723 | * .event = &ftrace_event_type_<call>, |
| 724 | * .print_fmt = print_fmt_<call>, |
| 725 | * .flags = TRACE_EVENT_FL_TRACEPOINT, |
| 726 | * }; |
| 727 | * // its only safe to use pointers when doing linker tricks to |
| 728 | * // create an array. |
| 729 | * static struct trace_event_call __used |
Joe Perches | 33def84 | 2020-10-21 19:36:07 -0700 | [diff] [blame] | 730 | * __section("_ftrace_events") *__event_<call> = &event_<call>; |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 731 | * |
| 732 | */ |
| 733 | |
| 734 | #ifdef CONFIG_PERF_EVENTS |
| 735 | |
| 736 | #define _TRACE_PERF_PROTO(call, proto) \ |
| 737 | static notrace void \ |
| 738 | perf_trace_##call(void *__data, proto); |
| 739 | |
| 740 | #define _TRACE_PERF_INIT(call) \ |
| 741 | .perf_probe = perf_trace_##call, |
| 742 | |
| 743 | #else |
| 744 | #define _TRACE_PERF_PROTO(call, proto) |
| 745 | #define _TRACE_PERF_INIT(call) |
| 746 | #endif /* CONFIG_PERF_EVENTS */ |
| 747 | |
| 748 | #undef __entry |
| 749 | #define __entry entry |
| 750 | |
| 751 | #undef __field |
| 752 | #define __field(type, item) |
| 753 | |
| 754 | #undef __field_struct |
| 755 | #define __field_struct(type, item) |
| 756 | |
| 757 | #undef __array |
| 758 | #define __array(type, item, len) |
| 759 | |
| 760 | #undef __dynamic_array |
| 761 | #define __dynamic_array(type, item, len) \ |
| 762 | __entry->__data_loc_##item = __data_offsets.item; |
| 763 | |
| 764 | #undef __string |
| 765 | #define __string(item, src) __dynamic_array(char, item, -1) |
| 766 | |
Steven Rostedt (VMware) | 883b4ae | 2021-07-16 20:55:10 -0400 | [diff] [blame] | 767 | #undef __string_len |
| 768 | #define __string_len(item, src, len) __dynamic_array(char, item, -1) |
| 769 | |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 770 | #undef __assign_str |
| 771 | #define __assign_str(dst, src) \ |
| 772 | strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)"); |
| 773 | |
Steven Rostedt (VMware) | 883b4ae | 2021-07-16 20:55:10 -0400 | [diff] [blame] | 774 | #undef __assign_str_len |
| 775 | #define __assign_str_len(dst, src, len) \ |
| 776 | do { \ |
| 777 | memcpy(__get_str(dst), (src), (len)); \ |
| 778 | __get_str(dst)[len] = '\0'; \ |
| 779 | } while(0) |
| 780 | |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 781 | #undef __bitmask |
| 782 | #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) |
| 783 | |
| 784 | #undef __get_bitmask |
| 785 | #define __get_bitmask(field) (char *)__get_dynamic_array(field) |
| 786 | |
| 787 | #undef __assign_bitmask |
| 788 | #define __assign_bitmask(dst, src, nr_bits) \ |
| 789 | memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) |
| 790 | |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 791 | #undef __rel_dynamic_array |
| 792 | #define __rel_dynamic_array(type, item, len) \ |
| 793 | __entry->__rel_loc_##item = __data_offsets.item; |
| 794 | |
| 795 | #undef __rel_string |
| 796 | #define __rel_string(item, src) __rel_dynamic_array(char, item, -1) |
| 797 | |
| 798 | #undef __rel_string_len |
| 799 | #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1) |
| 800 | |
| 801 | #undef __assign_rel_str |
| 802 | #define __assign_rel_str(dst, src) \ |
| 803 | strcpy(__get_rel_str(dst), (src) ? (const char *)(src) : "(null)"); |
| 804 | |
| 805 | #undef __assign_rel_str_len |
| 806 | #define __assign_rel_str_len(dst, src, len) \ |
| 807 | do { \ |
| 808 | memcpy(__get_rel_str(dst), (src), (len)); \ |
| 809 | __get_rel_str(dst)[len] = '\0'; \ |
| 810 | } while (0) |
| 811 | |
| 812 | #undef __rel_bitmask |
| 813 | #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) |
| 814 | |
| 815 | #undef __get_rel_bitmask |
| 816 | #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) |
| 817 | |
| 818 | #undef __assign_rel_bitmask |
| 819 | #define __assign_rel_bitmask(dst, src, nr_bits) \ |
| 820 | memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) |
| 821 | |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 822 | #undef TP_fast_assign |
| 823 | #define TP_fast_assign(args...) args |
| 824 | |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 825 | #undef __perf_count |
| 826 | #define __perf_count(c) (c) |
| 827 | |
| 828 | #undef __perf_task |
| 829 | #define __perf_task(t) (t) |
| 830 | |
| 831 | #undef DECLARE_EVENT_CLASS |
| 832 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
| 833 | \ |
| 834 | static notrace void \ |
| 835 | trace_event_raw_event_##call(void *__data, proto) \ |
| 836 | { \ |
| 837 | struct trace_event_file *trace_file = __data; \ |
| 838 | struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\ |
| 839 | struct trace_event_buffer fbuffer; \ |
| 840 | struct trace_event_raw_##call *entry; \ |
| 841 | int __data_size; \ |
| 842 | \ |
| 843 | if (trace_trigger_soft_disabled(trace_file)) \ |
| 844 | return; \ |
| 845 | \ |
| 846 | __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \ |
| 847 | \ |
| 848 | entry = trace_event_buffer_reserve(&fbuffer, trace_file, \ |
| 849 | sizeof(*entry) + __data_size); \ |
| 850 | \ |
| 851 | if (!entry) \ |
| 852 | return; \ |
| 853 | \ |
| 854 | tstruct \ |
| 855 | \ |
| 856 | { assign; } \ |
| 857 | \ |
| 858 | trace_event_buffer_commit(&fbuffer); \ |
| 859 | } |
| 860 | /* |
| 861 | * The ftrace_test_probe is compiled out, it is only here as a build time check |
| 862 | * to make sure that if the tracepoint handling changes, the ftrace probe will |
| 863 | * fail to compile unless it too is updated. |
| 864 | */ |
| 865 | |
| 866 | #undef DEFINE_EVENT |
| 867 | #define DEFINE_EVENT(template, call, proto, args) \ |
| 868 | static inline void ftrace_test_probe_##call(void) \ |
| 869 | { \ |
| 870 | check_trace_callback_type_##call(trace_event_raw_event_##template); \ |
| 871 | } |
| 872 | |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 873 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
| 874 | |
| 875 | #undef __entry |
| 876 | #define __entry REC |
| 877 | |
| 878 | #undef __print_flags |
| 879 | #undef __print_symbolic |
| 880 | #undef __print_hex |
Daniel Borkmann | 2acae0d | 2017-01-25 02:28:16 +0100 | [diff] [blame] | 881 | #undef __print_hex_str |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 882 | #undef __get_dynamic_array |
| 883 | #undef __get_dynamic_array_len |
| 884 | #undef __get_str |
| 885 | #undef __get_bitmask |
Masami Hiramatsu | 55de2c0 | 2021-11-22 18:30:21 +0900 | [diff] [blame] | 886 | #undef __get_rel_dynamic_array |
| 887 | #undef __get_rel_dynamic_array_len |
| 888 | #undef __get_rel_str |
| 889 | #undef __get_rel_bitmask |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 890 | #undef __print_array |
Piotr Maziarz | 02a65a0 | 2019-11-26 11:06:31 +0100 | [diff] [blame] | 891 | #undef __print_hex_dump |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 892 | |
Steven Rostedt | 62de4f2 | 2021-06-22 16:42:26 +0200 | [diff] [blame] | 893 | /* |
| 894 | * The below is not executed in the kernel. It is only what is |
| 895 | * displayed in the print format for userspace to parse. |
| 896 | */ |
| 897 | #undef __print_ns_to_secs |
| 898 | #define __print_ns_to_secs(val) (val) / 1000000000UL |
| 899 | |
| 900 | #undef __print_ns_without_secs |
| 901 | #define __print_ns_without_secs(val) (val) % 1000000000UL |
| 902 | |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 903 | #undef TP_printk |
| 904 | #define TP_printk(fmt, args...) "\"" fmt "\", " __stringify(args) |
| 905 | |
| 906 | #undef DECLARE_EVENT_CLASS |
| 907 | #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ |
| 908 | _TRACE_PERF_PROTO(call, PARAMS(proto)); \ |
| 909 | static char print_fmt_##call[] = print; \ |
| 910 | static struct trace_event_class __used __refdata event_class_##call = { \ |
| 911 | .system = TRACE_SYSTEM_STRING, \ |
Peter Zijlstra | 04ae87a | 2019-10-24 22:26:59 +0200 | [diff] [blame] | 912 | .fields_array = trace_event_fields_##call, \ |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 913 | .fields = LIST_HEAD_INIT(event_class_##call.fields),\ |
| 914 | .raw_init = trace_event_raw_init, \ |
| 915 | .probe = trace_event_raw_event_##call, \ |
| 916 | .reg = trace_event_reg, \ |
| 917 | _TRACE_PERF_INIT(call) \ |
| 918 | }; |
| 919 | |
| 920 | #undef DEFINE_EVENT |
| 921 | #define DEFINE_EVENT(template, call, proto, args) \ |
| 922 | \ |
| 923 | static struct trace_event_call __used event_##call = { \ |
| 924 | .class = &event_class_##template, \ |
| 925 | { \ |
| 926 | .tp = &__tracepoint_##call, \ |
| 927 | }, \ |
| 928 | .event.funcs = &trace_event_type_funcs_##template, \ |
| 929 | .print_fmt = print_fmt_##template, \ |
| 930 | .flags = TRACE_EVENT_FL_TRACEPOINT, \ |
| 931 | }; \ |
| 932 | static struct trace_event_call __used \ |
Joe Perches | 33def84 | 2020-10-21 19:36:07 -0700 | [diff] [blame] | 933 | __section("_ftrace_events") *__event_##call = &event_##call |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 934 | |
| 935 | #undef DEFINE_EVENT_PRINT |
| 936 | #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ |
| 937 | \ |
| 938 | static char print_fmt_##call[] = print; \ |
| 939 | \ |
| 940 | static struct trace_event_call __used event_##call = { \ |
| 941 | .class = &event_class_##template, \ |
| 942 | { \ |
| 943 | .tp = &__tracepoint_##call, \ |
| 944 | }, \ |
| 945 | .event.funcs = &trace_event_type_funcs_##call, \ |
| 946 | .print_fmt = print_fmt_##call, \ |
| 947 | .flags = TRACE_EVENT_FL_TRACEPOINT, \ |
| 948 | }; \ |
| 949 | static struct trace_event_call __used \ |
Joe Perches | 33def84 | 2020-10-21 19:36:07 -0700 | [diff] [blame] | 950 | __section("_ftrace_events") *__event_##call = &event_##call |
Steven Rostedt (Red Hat) | 46ac518 | 2015-09-23 09:26:27 -0400 | [diff] [blame] | 951 | |
| 952 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |