tracing/filters: Defer pred allocation
[linux-2.6/mini2440.git] / kernel / trace / trace_export.c
blobdf1bf6e48bb9dc88b5c4704fec2aac8c95f8fa78
1 /*
2 * trace_export.c - export basic ftrace utilities to user space
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>
16 #include "trace_output.h"
19 #undef TRACE_STRUCT
20 #define TRACE_STRUCT(args...) args
22 extern void __bad_type_size(void);
24 #undef TRACE_FIELD
25 #define TRACE_FIELD(type, item, assign) \
26 if (sizeof(type) != sizeof(field.item)) \
27 __bad_type_size(); \
28 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
29 "offset:%u;\tsize:%u;\n", \
30 (unsigned int)offsetof(typeof(field), item), \
31 (unsigned int)sizeof(field.item)); \
32 if (!ret) \
33 return 0;
36 #undef TRACE_FIELD_SPECIAL
37 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
38 ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \
39 "offset:%u;\tsize:%u;\n", \
40 (unsigned int)offsetof(typeof(field), item), \
41 (unsigned int)sizeof(field.item)); \
42 if (!ret) \
43 return 0;
45 #undef TRACE_FIELD_ZERO_CHAR
46 #define TRACE_FIELD_ZERO_CHAR(item) \
47 ret = trace_seq_printf(s, "\tfield:char " #item ";\t" \
48 "offset:%u;\tsize:0;\n", \
49 (unsigned int)offsetof(typeof(field), item)); \
50 if (!ret) \
51 return 0;
53 #undef TRACE_FIELD_SIGN
54 #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \
55 TRACE_FIELD(type, item, assign)
57 #undef TP_RAW_FMT
58 #define TP_RAW_FMT(args...) args
60 #undef TRACE_EVENT_FORMAT
61 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
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; \
69 tstruct; \
71 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
73 return ret; \
76 #undef TRACE_EVENT_FORMAT_NOFILTER
77 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
78 tpfmt) \
79 static int \
80 ftrace_format_##call(struct ftrace_event_call *unused, \
81 struct trace_seq *s) \
82 { \
83 struct args field; \
84 int ret; \
86 tstruct; \
88 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
90 return ret; \
93 #include "trace_event_types.h"
95 #undef TRACE_ZERO_CHAR
96 #define TRACE_ZERO_CHAR(arg)
98 #undef TRACE_FIELD
99 #define TRACE_FIELD(type, item, assign)\
100 entry->item = assign;
102 #undef TRACE_FIELD
103 #define TRACE_FIELD(type, item, assign)\
104 entry->item = assign;
106 #undef TRACE_FIELD_SIGN
107 #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \
108 TRACE_FIELD(type, item, assign)
110 #undef TP_CMD
111 #define TP_CMD(cmd...) cmd
113 #undef TRACE_ENTRY
114 #define TRACE_ENTRY entry
116 #undef TRACE_FIELD_SPECIAL
117 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
118 cmd;
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); \
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) \
137 INIT_LIST_HEAD(&event_##call.fields); \
138 return 0; \
141 #undef TRACE_EVENT_FORMAT_NOFILTER
142 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
143 tpfmt) \
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, \
154 #include "trace_event_types.h"
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;
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;
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;
182 #undef TRACE_FIELD_ZERO_CHAR
183 #define TRACE_FIELD_ZERO_CHAR(item)
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) \
190 struct args field; \
191 int ret; \
193 ret = trace_define_common_fields(event_call); \
194 if (ret) \
195 return ret; \
197 tstruct; \
199 return ret; \
202 #undef TRACE_EVENT_FORMAT_NOFILTER
203 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
204 tpfmt)
206 #include "trace_event_types.h"