Merge branch 'core/printk' into tracing/ftrace
[linux-2.6] / kernel / trace / trace_events_stage_2.h
1 /*
2  * Stage 2 of the trace events.
3  *
4  * Override the macros in <trace/trace_event_types.h> to include the following:
5  *
6  * enum print_line_t
7  * ftrace_raw_output_<call>(struct trace_iterator *iter, int flags)
8  * {
9  *      struct trace_seq *s = &iter->seq;
10  *      struct ftrace_raw_<call> *field; <-- defined in stage 1
11  *      struct trace_entry *entry;
12  *      int ret;
13  *
14  *      entry = iter->ent;
15  *
16  *      if (entry->type != event_<call>.id) {
17  *              WARN_ON_ONCE(1);
18  *              return TRACE_TYPE_UNHANDLED;
19  *      }
20  *
21  *      field = (typeof(field))entry;
22  *
23  *      ret = trace_seq_printf(s, <TP_RAW_FMT> "%s", <ARGS> "\n");
24  *      if (!ret)
25  *              return TRACE_TYPE_PARTIAL_LINE;
26  *
27  *      return TRACE_TYPE_HANDLED;
28  * }
29  *
30  * This is the method used to print the raw event to the trace
31  * output format. Note, this is not needed if the data is read
32  * in binary.
33  */
34
35 #undef __entry
36 #define __entry field
37
38 #undef TP_printk
39 #define TP_printk(fmt, args...) fmt "\n", args
40
41 #undef TRACE_EVENT
42 #define TRACE_EVENT(call, proto, args, tstruct, print, assign)          \
43 enum print_line_t                                                       \
44 ftrace_raw_output_##call(struct trace_iterator *iter, int flags)        \
45 {                                                                       \
46         struct trace_seq *s = &iter->seq;                               \
47         struct ftrace_raw_##call *field;                                \
48         struct trace_entry *entry;                                      \
49         int ret;                                                        \
50                                                                         \
51         entry = iter->ent;                                              \
52                                                                         \
53         if (entry->type != event_##call.id) {                           \
54                 WARN_ON_ONCE(1);                                        \
55                 return TRACE_TYPE_UNHANDLED;                            \
56         }                                                               \
57                                                                         \
58         field = (typeof(field))entry;                                   \
59                                                                         \
60         ret = trace_seq_printf(s, print);                               \
61         if (!ret)                                                       \
62                 return TRACE_TYPE_PARTIAL_LINE;                         \
63                                                                         \
64         return TRACE_TYPE_HANDLED;                                      \
65 }
66         
67 #include <trace/trace_event_types.h>
68
69 /*
70  * Setup the showing format of trace point.
71  *
72  * int
73  * ftrace_format_##call(struct trace_seq *s)
74  * {
75  *      struct ftrace_raw_##call field;
76  *      int ret;
77  *
78  *      ret = trace_seq_printf(s, #type " " #item ";"
79  *                             " size:%d; offset:%d;\n",
80  *                             sizeof(field.type),
81  *                             offsetof(struct ftrace_raw_##call,
82  *                                      item));
83  *
84  * }
85  */
86
87 #undef TP_STRUCT__entry
88 #define TP_STRUCT__entry(args...) args
89
90 #undef __field
91 #define __field(type, item)                                     \
92         ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"      \
93                                "offset:%u;\tsize:%u;\n",                \
94                                (unsigned int)offsetof(typeof(field), item), \
95                                (unsigned int)sizeof(field.item));       \
96         if (!ret)                                                       \
97                 return 0;
98
99 #undef __array
100 #define __array(type, item, len)                                                \
101         ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t"    \
102                                "offset:%u;\tsize:%u;\n",                \
103                                (unsigned int)offsetof(typeof(field), item), \
104                                (unsigned int)sizeof(field.item));       \
105         if (!ret)                                                       \
106                 return 0;
107
108 #undef __entry
109 #define __entry "REC"
110
111 #undef TP_printk
112 #define TP_printk(fmt, args...) "%s, %s\n", #fmt, #args
113
114 #undef TP_fast_assign
115 #define TP_fast_assign(args...) args
116
117 #undef TRACE_EVENT
118 #define TRACE_EVENT(call, proto, args, tstruct, print, func)            \
119 static int                                                              \
120 ftrace_format_##call(struct trace_seq *s)                               \
121 {                                                                       \
122         struct ftrace_raw_##call field;                                 \
123         int ret;                                                        \
124                                                                         \
125         tstruct;                                                        \
126                                                                         \
127         trace_seq_printf(s, "\nprint fmt: " print);                     \
128                                                                         \
129         return ret;                                                     \
130 }
131
132 #include <trace/trace_event_types.h>