diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-09-12 19:26:21 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-09-12 23:08:10 -0400 |
commit | 4e5292ea1ac0c2939e815e6c44fad3d8696ea281 (patch) | |
tree | f97dbe73d38b893ee5a2458a1d97490789e6ccb0 /kernel/trace | |
parent | d73150943cf47b6cabcb4f4e52dd25975e820ae2 (diff) |
tracing: use the new trace_entries.h to create format files
This patch changes the way the format files in
debugfs/tracing/events/ftrace/*/format
are created. It uses the new trace_entries.h file to automate the
creation of the format files to ensure that they are always in sync
with the actual structures. This is the same methodology used to
create the format files for the TRACE_EVENT macro.
This also updates the filter creation that was built on the creation
of the format files.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.h | 12 | ||||
-rw-r--r-- | kernel/trace/trace_events.c | 1 | ||||
-rw-r--r-- | kernel/trace/trace_export.c | 241 |
3 files changed, 136 insertions, 118 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index b0d287d49a6d..86bcff94791a 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/clocksource.h> | 7 | #include <linux/clocksource.h> |
8 | #include <linux/ring_buffer.h> | 8 | #include <linux/ring_buffer.h> |
9 | #include <linux/mmiotrace.h> | 9 | #include <linux/mmiotrace.h> |
10 | #include <linux/tracepoint.h> | ||
10 | #include <linux/ftrace.h> | 11 | #include <linux/ftrace.h> |
11 | #include <trace/boot.h> | 12 | #include <trace/boot.h> |
12 | #include <linux/kmemtrace.h> | 13 | #include <linux/kmemtrace.h> |
@@ -746,11 +747,12 @@ extern struct list_head ftrace_events; | |||
746 | extern const char *__start___trace_bprintk_fmt[]; | 747 | extern const char *__start___trace_bprintk_fmt[]; |
747 | extern const char *__stop___trace_bprintk_fmt[]; | 748 | extern const char *__stop___trace_bprintk_fmt[]; |
748 | 749 | ||
749 | #undef TRACE_EVENT_FORMAT | 750 | #undef FTRACE_ENTRY |
750 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | 751 | #define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \ |
751 | extern struct ftrace_event_call event_##call; | 752 | extern struct ftrace_event_call event_##call; |
752 | #undef TRACE_EVENT_FORMAT_NOFILTER | 753 | #undef FTRACE_ENTRY_DUP |
753 | #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, tpfmt) | 754 | #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \ |
754 | #include "trace_event_types.h" | 755 | FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print)) |
756 | #include "trace_entries.h" | ||
755 | 757 | ||
756 | #endif /* _LINUX_KERNEL_TRACE_H */ | 758 | #endif /* _LINUX_KERNEL_TRACE_H */ |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index f46d14cefdec..adbed124c3e7 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "trace_output.h" | 22 | #include "trace_output.h" |
23 | 23 | ||
24 | #undef TRACE_SYSTEM | ||
24 | #define TRACE_SYSTEM "TRACE_SYSTEM" | 25 | #define TRACE_SYSTEM "TRACE_SYSTEM" |
25 | 26 | ||
26 | DEFINE_MUTEX(event_mutex); | 27 | DEFINE_MUTEX(event_mutex); |
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index df1bf6e48bb9..4cb29d84d73a 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
@@ -15,82 +15,163 @@ | |||
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) \ | ||
27 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ | ||
28 | "offset:%zu;\tsize:%zu;\n", \ | ||
29 | offsetof(typeof(field), item), \ | ||
30 | sizeof(field.item)); \ | ||
31 | if (!ret) \ | ||
32 | return 0; | ||
23 | 33 | ||
24 | #undef TRACE_FIELD | 34 | #undef __field_desc |
25 | #define TRACE_FIELD(type, item, assign) \ | 35 | #define __field_desc(type, container, item) \ |
26 | if (sizeof(type) != sizeof(field.item)) \ | ||
27 | __bad_type_size(); \ | ||
28 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ | 36 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ |
29 | "offset:%u;\tsize:%u;\n", \ | 37 | "offset:%zu;\tsize:%zu;\n", \ |
30 | (unsigned int)offsetof(typeof(field), item), \ | 38 | offsetof(typeof(field), container.item), \ |
31 | (unsigned int)sizeof(field.item)); \ | 39 | sizeof(field.container.item)); \ |
32 | if (!ret) \ | 40 | if (!ret) \ |
33 | return 0; | 41 | return 0; |
34 | 42 | ||
43 | #undef __array | ||
44 | #define __array(type, item, len) \ | ||
45 | ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ | ||
46 | "offset:%zu;\tsize:%zu;\n", \ | ||
47 | offsetof(typeof(field), item), \ | ||
48 | sizeof(field.item)); \ | ||
49 | if (!ret) \ | ||
50 | return 0; | ||
35 | 51 | ||
36 | #undef TRACE_FIELD_SPECIAL | 52 | #undef __array_desc |
37 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ | 53 | #define __array_desc(type, container, item, len) \ |
38 | ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \ | 54 | ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ |
39 | "offset:%u;\tsize:%u;\n", \ | 55 | "offset:%zu;\tsize:%zu;\n", \ |
40 | (unsigned int)offsetof(typeof(field), item), \ | 56 | offsetof(typeof(field), container.item), \ |
41 | (unsigned int)sizeof(field.item)); \ | 57 | sizeof(field.container.item)); \ |
42 | if (!ret) \ | 58 | if (!ret) \ |
43 | return 0; | 59 | return 0; |
44 | 60 | ||
45 | #undef TRACE_FIELD_ZERO_CHAR | 61 | #undef __dynamic_array |
46 | #define TRACE_FIELD_ZERO_CHAR(item) \ | 62 | #define __dynamic_array(type, item) \ |
47 | ret = trace_seq_printf(s, "\tfield:char " #item ";\t" \ | 63 | ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ |
48 | "offset:%u;\tsize:0;\n", \ | 64 | "offset:%zu;\tsize:0;\n", \ |
49 | (unsigned int)offsetof(typeof(field), item)); \ | 65 | offsetof(typeof(field), item)); \ |
50 | if (!ret) \ | 66 | if (!ret) \ |
51 | return 0; | 67 | return 0; |
52 | 68 | ||
53 | #undef TRACE_FIELD_SIGN | 69 | #undef F_printk |
54 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | 70 | #define F_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args) |
55 | TRACE_FIELD(type, item, assign) | ||
56 | 71 | ||
57 | #undef TP_RAW_FMT | 72 | #undef __entry |
58 | #define TP_RAW_FMT(args...) args | 73 | #define __entry REC |
59 | 74 | ||
60 | #undef TRACE_EVENT_FORMAT | 75 | #undef FTRACE_ENTRY |
61 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | 76 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ |
62 | static int \ | 77 | static int \ |
63 | ftrace_format_##call(struct ftrace_event_call *unused, \ | 78 | ftrace_format_##name(struct ftrace_event_call *unused, \ |
64 | struct trace_seq *s) \ | 79 | struct trace_seq *s) \ |
65 | { \ | 80 | { \ |
66 | struct args field; \ | 81 | struct struct_name field __attribute__((unused)); \ |
67 | int ret; \ | 82 | int ret = 0; \ |
68 | \ | 83 | \ |
69 | tstruct; \ | 84 | tstruct; \ |
70 | \ | 85 | \ |
71 | trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \ | 86 | trace_seq_printf(s, "\nprint fmt: " print); \ |
72 | \ | 87 | \ |
73 | return ret; \ | 88 | return ret; \ |
74 | } | 89 | } |
75 | 90 | ||
76 | #undef TRACE_EVENT_FORMAT_NOFILTER | 91 | #undef FTRACE_ENTRY_DUP |
77 | #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \ | 92 | #define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \ |
78 | tpfmt) \ | 93 | FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) |
79 | static int \ | 94 | |
80 | ftrace_format_##call(struct ftrace_event_call *unused, \ | 95 | #include "trace_entries.h" |
81 | struct trace_seq *s) \ | 96 | |
97 | |||
98 | #undef __field | ||
99 | #define __field(type, item) \ | ||
100 | ret = trace_define_field(event_call, #type, #item, \ | ||
101 | offsetof(typeof(field), item), \ | ||
102 | sizeof(field.item), \ | ||
103 | is_signed_type(type), FILTER_OTHER); \ | ||
104 | if (ret) \ | ||
105 | return ret; | ||
106 | |||
107 | #undef __field_desc | ||
108 | #define __field_desc(type, container, item) \ | ||
109 | ret = trace_define_field(event_call, #type, #item, \ | ||
110 | offsetof(typeof(field), \ | ||
111 | container.item), \ | ||
112 | sizeof(field.container.item), \ | ||
113 | is_signed_type(type), FILTER_OTHER); \ | ||
114 | if (ret) \ | ||
115 | return ret; | ||
116 | |||
117 | #undef __array | ||
118 | #define __array(type, item, len) \ | ||
119 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | ||
120 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | ||
121 | offsetof(typeof(field), item), \ | ||
122 | sizeof(field.item), 0, FILTER_OTHER); \ | ||
123 | if (ret) \ | ||
124 | return ret; | ||
125 | |||
126 | #undef __array_desc | ||
127 | #define __array_desc(type, container, item, len) \ | ||
128 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | ||
129 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | ||
130 | offsetof(typeof(field), \ | ||
131 | container.item), \ | ||
132 | sizeof(field.container.item), 0, \ | ||
133 | FILTER_OTHER); \ | ||
134 | if (ret) \ | ||
135 | return ret; | ||
136 | |||
137 | #undef __dynamic_array | ||
138 | #define __dynamic_array(type, item) | ||
139 | |||
140 | #undef FTRACE_ENTRY | ||
141 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ | ||
142 | int \ | ||
143 | ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ | ||
82 | { \ | 144 | { \ |
83 | struct args field; \ | 145 | struct struct_name field; \ |
84 | int ret; \ | 146 | int ret; \ |
85 | \ | 147 | \ |
86 | tstruct; \ | 148 | ret = trace_define_common_fields(event_call); \ |
149 | if (ret) \ | ||
150 | return ret; \ | ||
87 | \ | 151 | \ |
88 | trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \ | 152 | tstruct; \ |
89 | \ | 153 | \ |
90 | return ret; \ | 154 | return ret; \ |
91 | } | 155 | } |
92 | 156 | ||
93 | #include "trace_event_types.h" | 157 | #include "trace_entries.h" |
158 | |||
159 | |||
160 | #undef __field | ||
161 | #define __field(type, item) | ||
162 | |||
163 | #undef __field_desc | ||
164 | #define __field_desc(type, container, item) | ||
165 | |||
166 | #undef __array | ||
167 | #define __array(type, item, len) | ||
168 | |||
169 | #undef __array_desc | ||
170 | #define __array_desc(type, container, item, len) | ||
171 | |||
172 | #undef __dynamic_array | ||
173 | #define __dynamic_array(type, item) | ||
174 | |||
94 | 175 | ||
95 | #undef TRACE_ZERO_CHAR | 176 | #undef TRACE_ZERO_CHAR |
96 | #define TRACE_ZERO_CHAR(arg) | 177 | #define TRACE_ZERO_CHAR(arg) |
@@ -117,16 +198,15 @@ ftrace_format_##call(struct ftrace_event_call *unused, \ | |||
117 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ | 198 | #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \ |
118 | cmd; | 199 | cmd; |
119 | 200 | ||
120 | #undef TRACE_EVENT_FORMAT | 201 | #undef FTRACE_ENTRY |
121 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | 202 | #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \ |
122 | int ftrace_define_fields_##call(struct ftrace_event_call *event_call); \ | ||
123 | static int ftrace_raw_init_event_##call(void); \ | 203 | static int ftrace_raw_init_event_##call(void); \ |
124 | \ | 204 | \ |
125 | struct ftrace_event_call __used \ | 205 | struct ftrace_event_call __used \ |
126 | __attribute__((__aligned__(4))) \ | 206 | __attribute__((__aligned__(4))) \ |
127 | __attribute__((section("_ftrace_events"))) event_##call = { \ | 207 | __attribute__((section("_ftrace_events"))) event_##call = { \ |
128 | .name = #call, \ | 208 | .name = #call, \ |
129 | .id = proto, \ | 209 | .id = type, \ |
130 | .system = __stringify(TRACE_SYSTEM), \ | 210 | .system = __stringify(TRACE_SYSTEM), \ |
131 | .raw_init = ftrace_raw_init_event_##call, \ | 211 | .raw_init = ftrace_raw_init_event_##call, \ |
132 | .show_format = ftrace_format_##call, \ | 212 | .show_format = ftrace_format_##call, \ |
@@ -138,69 +218,4 @@ static int ftrace_raw_init_event_##call(void) \ | |||
138 | return 0; \ | 218 | return 0; \ |
139 | } \ | 219 | } \ |
140 | 220 | ||
141 | #undef TRACE_EVENT_FORMAT_NOFILTER | 221 | #include "trace_entries.h" |
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 | |||
154 | #include "trace_event_types.h" | ||
155 | |||
156 | #undef TRACE_FIELD | ||
157 | #define TRACE_FIELD(type, item, assign) \ | ||
158 | ret = trace_define_field(event_call, #type, #item, \ | ||
159 | offsetof(typeof(field), item), \ | ||
160 | sizeof(field.item), \ | ||
161 | is_signed_type(type), FILTER_OTHER); \ | ||
162 | if (ret) \ | ||
163 | return ret; | ||
164 | |||
165 | #undef TRACE_FIELD_SPECIAL | ||
166 | #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \ | ||
167 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | ||
168 | offsetof(typeof(field), item), \ | ||
169 | sizeof(field.item), 0, FILTER_OTHER); \ | ||
170 | if (ret) \ | ||
171 | return ret; | ||
172 | |||
173 | #undef TRACE_FIELD_SIGN | ||
174 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | ||
175 | ret = trace_define_field(event_call, #type, #item, \ | ||
176 | offsetof(typeof(field), item), \ | ||
177 | sizeof(field.item), is_signed, \ | ||
178 | FILTER_OTHER); \ | ||
179 | if (ret) \ | ||
180 | return ret; | ||
181 | |||
182 | #undef TRACE_FIELD_ZERO_CHAR | ||
183 | #define TRACE_FIELD_ZERO_CHAR(item) | ||
184 | |||
185 | #undef TRACE_EVENT_FORMAT | ||
186 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | ||
187 | int \ | ||
188 | ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ | ||
189 | { \ | ||
190 | struct args field; \ | ||
191 | int ret; \ | ||
192 | \ | ||
193 | ret = trace_define_common_fields(event_call); \ | ||
194 | if (ret) \ | ||
195 | return ret; \ | ||
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" | ||