tracing/filters: add TRACE_EVENT_FORMAT_NOFILTER event macro
[safe/jmp/linux-2.6] / 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
19 #undef TRACE_STRUCT
20 #define TRACE_STRUCT(args...) args
21
22 #undef TRACE_FIELD
23 #define TRACE_FIELD(type, item, assign)                                 \
24         ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"      \
25                                "offset:%u;\tsize:%u;\n",                \
26                                (unsigned int)offsetof(typeof(field), item), \
27                                (unsigned int)sizeof(field.item));       \
28         if (!ret)                                                       \
29                 return 0;
30
31
32 #undef TRACE_FIELD_SPECIAL
33 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd)                  \
34         ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t"   \
35                                "offset:%u;\tsize:%u;\n",                \
36                                (unsigned int)offsetof(typeof(field), item), \
37                                (unsigned int)sizeof(field.item));       \
38         if (!ret)                                                       \
39                 return 0;
40
41 #undef TRACE_FIELD_ZERO_CHAR
42 #define TRACE_FIELD_ZERO_CHAR(item)                                     \
43         ret = trace_seq_printf(s, "\tfield:char " #item ";\t"           \
44                                "offset:%u;\tsize:0;\n",                 \
45                                (unsigned int)offsetof(typeof(field), item)); \
46         if (!ret)                                                       \
47                 return 0;
48
49
50 #undef TP_RAW_FMT
51 #define TP_RAW_FMT(args...) args
52
53 #undef TRACE_EVENT_FORMAT
54 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)      \
55 static int                                                              \
56 ftrace_format_##call(struct trace_seq *s)                               \
57 {                                                                       \
58         struct args field;                                              \
59         int ret;                                                        \
60                                                                         \
61         tstruct;                                                        \
62                                                                         \
63         trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt);            \
64                                                                         \
65         return ret;                                                     \
66 }
67
68 #undef TRACE_EVENT_FORMAT_NOFILTER
69 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct,    \
70                                     tpfmt)                              \
71 static int                                                              \
72 ftrace_format_##call(struct trace_seq *s)                               \
73 {                                                                       \
74         struct args field;                                              \
75         int ret;                                                        \
76                                                                         \
77         tstruct;                                                        \
78                                                                         \
79         trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt);            \
80                                                                         \
81         return ret;                                                     \
82 }
83
84 #include "trace_event_types.h"
85
86 #undef TRACE_ZERO_CHAR
87 #define TRACE_ZERO_CHAR(arg)
88
89 #undef TRACE_FIELD
90 #define TRACE_FIELD(type, item, assign)\
91         entry->item = assign;
92
93 #undef TRACE_FIELD
94 #define TRACE_FIELD(type, item, assign)\
95         entry->item = assign;
96
97 #undef TP_CMD
98 #define TP_CMD(cmd...)  cmd
99
100 #undef TRACE_ENTRY
101 #define TRACE_ENTRY     entry
102
103 #undef TRACE_FIELD_SPECIAL
104 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd)  \
105         cmd;
106
107 #undef TRACE_EVENT_FORMAT
108 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)      \
109 int ftrace_define_fields_##call(void);                                  \
110 static int ftrace_raw_init_event_##call(void);                          \
111                                                                         \
112 struct ftrace_event_call __used                                         \
113 __attribute__((__aligned__(4)))                                         \
114 __attribute__((section("_ftrace_events"))) event_##call = {             \
115         .name                   = #call,                                \
116         .id                     = proto,                                \
117         .system                 = __stringify(TRACE_SYSTEM),            \
118         .raw_init               = ftrace_raw_init_event_##call,         \
119         .show_format            = ftrace_format_##call,                 \
120         .define_fields          = ftrace_define_fields_##call,          \
121 };                                                                      \
122 static int ftrace_raw_init_event_##call(void)                           \
123 {                                                                       \
124         INIT_LIST_HEAD(&event_##call.fields);                           \
125         return 0;                                                       \
126 }                                                                       \
127
128 #undef TRACE_EVENT_FORMAT_NOFILTER
129 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct,    \
130                                     tpfmt)                              \
131                                                                         \
132 struct ftrace_event_call __used                                         \
133 __attribute__((__aligned__(4)))                                         \
134 __attribute__((section("_ftrace_events"))) event_##call = {             \
135         .name                   = #call,                                \
136         .id                     = proto,                                \
137         .system                 = __stringify(TRACE_SYSTEM),            \
138         .show_format            = ftrace_format_##call,                 \
139 };
140
141 #include "trace_event_types.h"
142
143 #undef TRACE_FIELD
144 #define TRACE_FIELD(type, item, assign)                                 \
145         ret = trace_define_field(event_call, #type, #item,              \
146                                  offsetof(typeof(field), item),         \
147                                  sizeof(field.item));                   \
148         if (ret)                                                        \
149                 return ret;
150
151 #undef TRACE_FIELD_SPECIAL
152 #define TRACE_FIELD_SPECIAL(type, item, len, cmd)                       \
153         ret = trace_define_field(event_call, #type "[" #len "]", #item, \
154                                  offsetof(typeof(field), item),         \
155                                  sizeof(field.item));                   \
156         if (ret)                                                        \
157                 return ret;
158
159 #undef TRACE_FIELD_ZERO_CHAR
160 #define TRACE_FIELD_ZERO_CHAR(item)
161
162 #undef TRACE_EVENT_FORMAT
163 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)      \
164 int                                                                     \
165 ftrace_define_fields_##call(void)                                       \
166 {                                                                       \
167         struct ftrace_event_call *event_call = &event_##call;           \
168         struct args field;                                              \
169         int ret;                                                        \
170                                                                         \
171         __common_field(unsigned char, type);                            \
172         __common_field(unsigned char, flags);                           \
173         __common_field(unsigned char, preempt_count);                   \
174         __common_field(int, pid);                                       \
175         __common_field(int, tgid);                                      \
176                                                                         \
177         tstruct;                                                        \
178                                                                         \
179         return ret;                                                     \
180 }
181
182 #undef TRACE_EVENT_FORMAT_NOFILTER
183 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct,    \
184                                     tpfmt)
185
186 #include "trace_event_types.h"