tracing: use the new trace_entries.h to create format files
[deliverable/linux.git] / kernel / trace / trace_export.c
1 /*
2 * trace_export.c - export basic ftrace utilities to user space
3 *
4 * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com>
5 */
6 #include <linux/stringify.h>
7 #include <linux/kallsyms.h>
8 #include <linux/seq_file.h>
9 #include <linux/debugfs.h>
10 #include <linux/uaccess.h>
11 #include <linux/ftrace.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/fs.h>
15
16 #include "trace_output.h"
17
18 #undef TRACE_SYSTEM
19 #define TRACE_SYSTEM ftrace
20
21 /* not needed for this file */
22 #undef __field_struct
23 #define __field_struct(type, item)
24
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;
33
34 #undef __field_desc
35 #define __field_desc(type, container, item) \
36 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
37 "offset:%zu;\tsize:%zu;\n", \
38 offsetof(typeof(field), container.item), \
39 sizeof(field.container.item)); \
40 if (!ret) \
41 return 0;
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;
51
52 #undef __array_desc
53 #define __array_desc(type, container, item, len) \
54 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
55 "offset:%zu;\tsize:%zu;\n", \
56 offsetof(typeof(field), container.item), \
57 sizeof(field.container.item)); \
58 if (!ret) \
59 return 0;
60
61 #undef __dynamic_array
62 #define __dynamic_array(type, item) \
63 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
64 "offset:%zu;\tsize:0;\n", \
65 offsetof(typeof(field), item)); \
66 if (!ret) \
67 return 0;
68
69 #undef F_printk
70 #define F_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
71
72 #undef __entry
73 #define __entry REC
74
75 #undef FTRACE_ENTRY
76 #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
77 static int \
78 ftrace_format_##name(struct ftrace_event_call *unused, \
79 struct trace_seq *s) \
80 { \
81 struct struct_name field __attribute__((unused)); \
82 int ret = 0; \
83 \
84 tstruct; \
85 \
86 trace_seq_printf(s, "\nprint fmt: " print); \
87 \
88 return ret; \
89 }
90
91 #undef FTRACE_ENTRY_DUP
92 #define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \
93 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
94
95 #include "trace_entries.h"
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) \
144 { \
145 struct struct_name field; \
146 int ret; \
147 \
148 ret = trace_define_common_fields(event_call); \
149 if (ret) \
150 return ret; \
151 \
152 tstruct; \
153 \
154 return ret; \
155 }
156
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
175
176 #undef TRACE_ZERO_CHAR
177 #define TRACE_ZERO_CHAR(arg)
178
179 #undef TRACE_FIELD
180 #define TRACE_FIELD(type, item, assign)\
181 entry->item = assign;
182
183 #undef TRACE_FIELD
184 #define TRACE_FIELD(type, item, assign)\
185 entry->item = assign;
186
187 #undef TRACE_FIELD_SIGN
188 #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \
189 TRACE_FIELD(type, item, assign)
190
191 #undef TP_CMD
192 #define TP_CMD(cmd...) cmd
193
194 #undef TRACE_ENTRY
195 #define TRACE_ENTRY entry
196
197 #undef TRACE_FIELD_SPECIAL
198 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
199 cmd;
200
201 #undef FTRACE_ENTRY
202 #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \
203 static int ftrace_raw_init_event_##call(void); \
204 \
205 struct ftrace_event_call __used \
206 __attribute__((__aligned__(4))) \
207 __attribute__((section("_ftrace_events"))) event_##call = { \
208 .name = #call, \
209 .id = type, \
210 .system = __stringify(TRACE_SYSTEM), \
211 .raw_init = ftrace_raw_init_event_##call, \
212 .show_format = ftrace_format_##call, \
213 .define_fields = ftrace_define_fields_##call, \
214 }; \
215 static int ftrace_raw_init_event_##call(void) \
216 { \
217 INIT_LIST_HEAD(&event_##call.fields); \
218 return 0; \
219 } \
220
221 #include "trace_entries.h"
This page took 0.037007 seconds and 6 git commands to generate.