diff options
Diffstat (limited to 'kernel/trace/trace_export.c')
| -rw-r--r-- | kernel/trace/trace_export.c | 284 |
1 files changed, 155 insertions, 129 deletions
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index df1bf6e48bb9..9753fcc61bc5 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
| @@ -15,146 +15,125 @@ | |||
| 15 | 15 | ||
| 16 | #include "trace_output.h" | 16 | #include "trace_output.h" |
| 17 | 17 | ||
| 18 | #undef TRACE_SYSTEM | ||
| 19 | #define TRACE_SYSTEM ftrace | ||
| 18 | 20 | ||
| 19 | #undef TRACE_STRUCT | 21 | /* not needed for this file */ |
| 20 | #define TRACE_STRUCT(args...) args | 22 | #undef __field_struct |
| 23 | #define __field_struct(type, item) | ||
| 21 | 24 | ||
| 22 | extern void __bad_type_size(void); | 25 | #undef __field |
| 26 | #define __field(type, item) type item; | ||
| 23 | 27 | ||
| 24 | #undef TRACE_FIELD | 28 | #undef __field_desc |
| 25 | #define TRACE_FIELD(type, item, assign) \ | 29 | #define __field_desc(type, container, item) type item; |
| 26 | if (sizeof(type) != sizeof(field.item)) \ | 30 | |
| 27 | __bad_type_size(); \ | 31 | #undef __array |
| 32 | #define __array(type, item, size) type item[size]; | ||
| 33 | |||
| 34 | #undef __array_desc | ||
| 35 | #define __array_desc(type, container, item, size) type item[size]; | ||
| 36 | |||
| 37 | #undef __dynamic_array | ||
| 38 | #define __dynamic_array(type, item) type item[]; | ||
| 39 | |||
| 40 | #undef F_STRUCT | ||
| 41 | #define F_STRUCT(args...) args | ||
| 42 | |||
| 43 | #undef F_printk | ||
| 44 | #define F_printk(fmt, args...) fmt, args | ||
| 45 | |||
| 46 | #undef FTRACE_ENTRY | ||
| 47 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ | ||
| 48 | struct ____ftrace_##name { \ | ||
| 49 | tstruct \ | ||
| 50 | }; \ | ||
| 51 | static void __used ____ftrace_check_##name(void) \ | ||
| 52 | { \ | ||
| 53 | struct ____ftrace_##name *__entry = NULL; \ | ||
| 54 | \ | ||
| 55 | /* force cmpile-time check on F_printk() */ \ | ||
| 56 | printk(print); \ | ||
| 57 | } | ||
| 58 | |||
| 59 | #undef FTRACE_ENTRY_DUP | ||
| 60 | #define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \ | ||
| 61 | FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) | ||
| 62 | |||
| 63 | #include "trace_entries.h" | ||
| 64 | |||
| 65 | |||
| 66 | #undef __field | ||
| 67 | #define __field(type, item) \ | ||
| 28 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ | 68 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ |
| 29 | "offset:%u;\tsize:%u;\n", \ | 69 | "offset:%zu;\tsize:%zu;\n", \ |
| 30 | (unsigned int)offsetof(typeof(field), item), \ | 70 | offsetof(typeof(field), item), \ |
| 31 | (unsigned int)sizeof(field.item)); \ | 71 | sizeof(field.item)); \ |
| 32 | if (!ret) \ | 72 | if (!ret) \ |
| 33 | return 0; | 73 | return 0; |
| 34 | 74 | ||
| 75 | #undef __field_desc | ||
| 76 | #define __field_desc(type, container, item) \ | ||
| 77 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ | ||
| 78 | "offset:%zu;\tsize:%zu;\n", \ | ||
| 79 | offsetof(typeof(field), container.item), \ | ||
| 80 | sizeof(field.container.item)); \ | ||
| 81 | if (!ret) \ | ||
| 82 | return 0; | ||
| 35 | 83 | ||
| 36 | #undef TRACE_FIELD_SPECIAL | 84 | #undef __array |
| 37 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ | 85 | #define __array(type, item, len) \ |
| 38 | ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \ | 86 | ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ |
| 39 | "offset:%u;\tsize:%u;\n", \ | 87 | "offset:%zu;\tsize:%zu;\n", \ |
| 40 | (unsigned int)offsetof(typeof(field), item), \ | 88 | offsetof(typeof(field), item), \ |
| 41 | (unsigned int)sizeof(field.item)); \ | 89 | sizeof(field.item)); \ |
| 42 | if (!ret) \ | 90 | if (!ret) \ |
| 43 | return 0; | 91 | return 0; |
| 44 | 92 | ||
| 45 | #undef TRACE_FIELD_ZERO_CHAR | 93 | #undef __array_desc |
| 46 | #define TRACE_FIELD_ZERO_CHAR(item) \ | 94 | #define __array_desc(type, container, item, len) \ |
| 47 | ret = trace_seq_printf(s, "\tfield:char " #item ";\t" \ | 95 | ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ |
| 48 | "offset:%u;\tsize:0;\n", \ | 96 | "offset:%zu;\tsize:%zu;\n", \ |
| 49 | (unsigned int)offsetof(typeof(field), item)); \ | 97 | offsetof(typeof(field), container.item), \ |
| 98 | sizeof(field.container.item)); \ | ||
| 50 | if (!ret) \ | 99 | if (!ret) \ |
| 51 | return 0; | 100 | return 0; |
| 52 | 101 | ||
| 53 | #undef TRACE_FIELD_SIGN | 102 | #undef __dynamic_array |
| 54 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | 103 | #define __dynamic_array(type, item) \ |
| 55 | TRACE_FIELD(type, item, assign) | 104 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ |
| 105 | "offset:%zu;\tsize:0;\n", \ | ||
| 106 | offsetof(typeof(field), item)); \ | ||
| 107 | if (!ret) \ | ||
| 108 | return 0; | ||
| 56 | 109 | ||
| 57 | #undef TP_RAW_FMT | 110 | #undef F_printk |
| 58 | #define TP_RAW_FMT(args...) args | 111 | #define F_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args) |
| 59 | 112 | ||
| 60 | #undef TRACE_EVENT_FORMAT | 113 | #undef __entry |
| 61 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | 114 | #define __entry REC |
| 62 | static int \ | ||
| 63 | ftrace_format_##call(struct ftrace_event_call *unused, \ | ||
| 64 | struct trace_seq *s) \ | ||
| 65 | { \ | ||
| 66 | struct args field; \ | ||
| 67 | int ret; \ | ||
| 68 | \ | ||
| 69 | tstruct; \ | ||
| 70 | \ | ||
| 71 | trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \ | ||
| 72 | \ | ||
| 73 | return ret; \ | ||
| 74 | } | ||
| 75 | 115 | ||
| 76 | #undef TRACE_EVENT_FORMAT_NOFILTER | 116 | #undef FTRACE_ENTRY |
| 77 | #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ | 117 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ |
| 78 | tpfmt) \ | ||
| 79 | static int \ | 118 | static int \ |
| 80 | ftrace_format_##call(struct ftrace_event_call *unused, \ | 119 | ftrace_format_##name(struct ftrace_event_call *unused, \ |
| 81 | struct trace_seq *s) \ | 120 | struct trace_seq *s) \ |
| 82 | { \ | 121 | { \ |
| 83 | struct args field; \ | 122 | struct struct_name field __attribute__((unused)); \ |
| 84 | int ret; \ | 123 | int ret = 0; \ |
| 85 | \ | 124 | \ |
| 86 | tstruct; \ | 125 | tstruct; \ |
| 87 | \ | 126 | \ |
| 88 | trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \ | 127 | trace_seq_printf(s, "\nprint fmt: " print); \ |
| 89 | \ | 128 | \ |
| 90 | return ret; \ | 129 | return ret; \ |
| 91 | } | 130 | } |
| 92 | 131 | ||
| 93 | #include "trace_event_types.h" | 132 | #include "trace_entries.h" |
| 94 | |||
| 95 | #undef TRACE_ZERO_CHAR | ||
| 96 | #define TRACE_ZERO_CHAR(arg) | ||
| 97 | |||
| 98 | #undef TRACE_FIELD | ||
| 99 | #define TRACE_FIELD(type, item, assign)\ | ||
| 100 | entry->item = assign; | ||
| 101 | |||
| 102 | #undef TRACE_FIELD | ||
| 103 | #define TRACE_FIELD(type, item, assign)\ | ||
| 104 | entry->item = assign; | ||
| 105 | |||
| 106 | #undef TRACE_FIELD_SIGN | ||
| 107 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | ||
| 108 | TRACE_FIELD(type, item, assign) | ||
| 109 | |||
| 110 | #undef TP_CMD | ||
| 111 | #define TP_CMD(cmd...) cmd | ||
| 112 | |||
| 113 | #undef TRACE_ENTRY | ||
| 114 | #define TRACE_ENTRY entry | ||
| 115 | |||
| 116 | #undef TRACE_FIELD_SPECIAL | ||
| 117 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ | ||
| 118 | cmd; | ||
| 119 | |||
| 120 | #undef TRACE_EVENT_FORMAT | ||
| 121 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | ||
| 122 | int ftrace_define_fields_##call(struct ftrace_event_call *event_call); \ | ||
| 123 | static int ftrace_raw_init_event_##call(void); \ | ||
| 124 | \ | ||
| 125 | struct ftrace_event_call __used \ | ||
| 126 | __attribute__((__aligned__(4))) \ | ||
| 127 | __attribute__((section("_ftrace_events"))) event_##call = { \ | ||
| 128 | .name = #call, \ | ||
| 129 | .id = proto, \ | ||
| 130 | .system = __stringify(TRACE_SYSTEM), \ | ||
| 131 | .raw_init = ftrace_raw_init_event_##call, \ | ||
| 132 | .show_format = ftrace_format_##call, \ | ||
| 133 | .define_fields = ftrace_define_fields_##call, \ | ||
| 134 | }; \ | ||
| 135 | static int ftrace_raw_init_event_##call(void) \ | ||
| 136 | { \ | ||
| 137 | INIT_LIST_HEAD(&event_##call.fields); \ | ||
| 138 | return 0; \ | ||
| 139 | } \ | ||
| 140 | |||
| 141 | #undef TRACE_EVENT_FORMAT_NOFILTER | ||
| 142 | #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ | ||
| 143 | tpfmt) \ | ||
| 144 | \ | ||
| 145 | struct ftrace_event_call __used \ | ||
| 146 | __attribute__((__aligned__(4))) \ | ||
| 147 | __attribute__((section("_ftrace_events"))) event_##call = { \ | ||
| 148 | .name = #call, \ | ||
| 149 | .id = proto, \ | ||
| 150 | .system = __stringify(TRACE_SYSTEM), \ | ||
| 151 | .show_format = ftrace_format_##call, \ | ||
| 152 | }; | ||
| 153 | 133 | ||
| 154 | #include "trace_event_types.h" | ||
| 155 | 134 | ||
| 156 | #undef TRACE_FIELD | 135 | #undef __field |
| 157 | #define TRACE_FIELD(type, item, assign) \ | 136 | #define __field(type, item) \ |
| 158 | ret = trace_define_field(event_call, #type, #item, \ | 137 | ret = trace_define_field(event_call, #type, #item, \ |
| 159 | offsetof(typeof(field), item), \ | 138 | offsetof(typeof(field), item), \ |
| 160 | sizeof(field.item), \ | 139 | sizeof(field.item), \ |
| @@ -162,32 +141,45 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ | |||
| 162 | if (ret) \ | 141 | if (ret) \ |
| 163 | return ret; | 142 | return ret; |
| 164 | 143 | ||
| 165 | #undef TRACE_FIELD_SPECIAL | 144 | #undef __field_desc |
| 166 | #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \ | 145 | #define __field_desc(type, container, item) \ |
| 146 | ret = trace_define_field(event_call, #type, #item, \ | ||
| 147 | offsetof(typeof(field), \ | ||
| 148 | container.item), \ | ||
| 149 | sizeof(field.container.item), \ | ||
| 150 | is_signed_type(type), FILTER_OTHER); \ | ||
| 151 | if (ret) \ | ||
| 152 | return ret; | ||
| 153 | |||
| 154 | #undef __array | ||
| 155 | #define __array(type, item, len) \ | ||
| 156 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | ||
| 167 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 157 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
| 168 | offsetof(typeof(field), item), \ | 158 | offsetof(typeof(field), item), \ |
| 169 | sizeof(field.item), 0, FILTER_OTHER); \ | 159 | sizeof(field.item), 0, FILTER_OTHER); \ |
| 170 | if (ret) \ | 160 | if (ret) \ |
| 171 | return ret; | 161 | return ret; |
| 172 | 162 | ||
| 173 | #undef TRACE_FIELD_SIGN | 163 | #undef __array_desc |
| 174 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | 164 | #define __array_desc(type, container, item, len) \ |
| 175 | ret = trace_define_field(event_call, #type, #item, \ | 165 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ |
| 176 | offsetof(typeof(field), item), \ | 166 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
| 177 | sizeof(field.item), is_signed, \ | 167 | offsetof(typeof(field), \ |
| 168 | container.item), \ | ||
| 169 | sizeof(field.container.item), 0, \ | ||
| 178 | FILTER_OTHER); \ | 170 | FILTER_OTHER); \ |
| 179 | if (ret) \ | 171 | if (ret) \ |
| 180 | return ret; | 172 | return ret; |
| 181 | 173 | ||
| 182 | #undef TRACE_FIELD_ZERO_CHAR | 174 | #undef __dynamic_array |
| 183 | #define TRACE_FIELD_ZERO_CHAR(item) | 175 | #define __dynamic_array(type, item) |
| 184 | 176 | ||
| 185 | #undef TRACE_EVENT_FORMAT | 177 | #undef FTRACE_ENTRY |
| 186 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | 178 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ |
| 187 | int \ | 179 | int \ |
| 188 | ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ | 180 | ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ |
| 189 | { \ | 181 | { \ |
| 190 | struct args field; \ | 182 | struct struct_name field; \ |
| 191 | int ret; \ | 183 | int ret; \ |
| 192 | \ | 184 | \ |
| 193 | ret = trace_define_common_fields(event_call); \ | 185 | ret = trace_define_common_fields(event_call); \ |
| @@ -199,8 +191,42 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ | |||
| 199 | return ret; \ | 191 | return ret; \ |
| 200 | } | 192 | } |
| 201 | 193 | ||
| 202 | #undef TRACE_EVENT_FORMAT_NOFILTER | 194 | #include "trace_entries.h" |
| 203 | #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ | 195 | |
| 204 | tpfmt) | 196 | |
| 197 | #undef __field | ||
| 198 | #define __field(type, item) | ||
| 199 | |||
| 200 | #undef __field_desc | ||
| 201 | #define __field_desc(type, container, item) | ||
| 202 | |||
| 203 | #undef __array | ||
| 204 | #define __array(type, item, len) | ||
| 205 | |||
| 206 | #undef __array_desc | ||
| 207 | #define __array_desc(type, container, item, len) | ||
| 208 | |||
| 209 | #undef __dynamic_array | ||
| 210 | #define __dynamic_array(type, item) | ||
| 211 | |||
| 212 | #undef FTRACE_ENTRY | ||
| 213 | #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \ | ||
| 214 | static int ftrace_raw_init_event_##call(void); \ | ||
| 215 | \ | ||
| 216 | struct ftrace_event_call __used \ | ||
| 217 | __attribute__((__aligned__(4))) \ | ||
| 218 | __attribute__((section("_ftrace_events"))) event_##call = { \ | ||
| 219 | .name = #call, \ | ||
| 220 | .id = type, \ | ||
| 221 | .system = __stringify(TRACE_SYSTEM), \ | ||
| 222 | .raw_init = ftrace_raw_init_event_##call, \ | ||
| 223 | .show_format = ftrace_format_##call, \ | ||
| 224 | .define_fields = ftrace_define_fields_##call, \ | ||
| 225 | }; \ | ||
| 226 | static int ftrace_raw_init_event_##call(void) \ | ||
| 227 | { \ | ||
| 228 | INIT_LIST_HEAD(&event_##call.fields); \ | ||
| 229 | return 0; \ | ||
| 230 | } \ | ||
| 205 | 231 | ||
| 206 | #include "trace_event_types.h" | 232 | #include "trace_entries.h" |
