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