drm/i915: Fix typo that broke SVID1 in intel_sdvo_multifunc_encoder()
[linux-2.6/linux-2.6-openrd.git] / kernel / trace / trace_export.c
blobd06cf898dc86aeb012a5f2e5bb1abed214aa8102
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 trace_seq *s) \
64 { \
65 struct args field; \
66 int ret; \
68 tstruct; \
70 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
72 return ret; \
75 #undef TRACE_EVENT_FORMAT_NOFILTER
76 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
77 tpfmt) \
78 static int \
79 ftrace_format_##call(struct trace_seq *s) \
80 { \
81 struct args field; \
82 int ret; \
84 tstruct; \
86 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
88 return ret; \
91 #include "trace_event_types.h"
93 #undef TRACE_ZERO_CHAR
94 #define TRACE_ZERO_CHAR(arg)
96 #undef TRACE_FIELD
97 #define TRACE_FIELD(type, item, assign)\
98 entry->item = assign;
100 #undef TRACE_FIELD
101 #define TRACE_FIELD(type, item, assign)\
102 entry->item = assign;
104 #undef TRACE_FIELD_SIGN
105 #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \
106 TRACE_FIELD(type, item, assign)
108 #undef TP_CMD
109 #define TP_CMD(cmd...) cmd
111 #undef TRACE_ENTRY
112 #define TRACE_ENTRY entry
114 #undef TRACE_FIELD_SPECIAL
115 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
116 cmd;
118 #undef TRACE_EVENT_FORMAT
119 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
120 int ftrace_define_fields_##call(void); \
121 static int ftrace_raw_init_event_##call(void); \
123 struct ftrace_event_call __used \
124 __attribute__((__aligned__(4))) \
125 __attribute__((section("_ftrace_events"))) event_##call = { \
126 .name = #call, \
127 .id = proto, \
128 .system = __stringify(TRACE_SYSTEM), \
129 .raw_init = ftrace_raw_init_event_##call, \
130 .show_format = ftrace_format_##call, \
131 .define_fields = ftrace_define_fields_##call, \
132 }; \
133 static int ftrace_raw_init_event_##call(void) \
135 INIT_LIST_HEAD(&event_##call.fields); \
136 init_preds(&event_##call); \
137 return 0; \
140 #undef TRACE_EVENT_FORMAT_NOFILTER
141 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
142 tpfmt) \
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, \
153 #include "trace_event_types.h"
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;
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;
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;
179 #undef TRACE_FIELD_ZERO_CHAR
180 #define TRACE_FIELD_ZERO_CHAR(item)
182 #undef TRACE_EVENT_FORMAT
183 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
184 int \
185 ftrace_define_fields_##call(void) \
187 struct ftrace_event_call *event_call = &event_##call; \
188 struct args field; \
189 int ret; \
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); \
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"