2 * trace_export.c - export basic ftrace utilities to user space
4 * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com>
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>
16 #include "trace_output.h"
20 #define TRACE_STRUCT(args...) args
22 extern void __bad_type_size(void);
25 #define TRACE_FIELD(type, item, assign) \
26 if (sizeof(type) != sizeof(field.item)) \
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)); \
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)); \
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)); \
53 #undef TRACE_FIELD_SIGN
54 #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \
55 TRACE_FIELD(type, item, assign)
58 #define TP_RAW_FMT(args...) args
60 #undef TRACE_EVENT_FORMAT
61 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
63 ftrace_format_##call(struct ftrace_event_call *unused, \
64 struct trace_seq *s) \
71 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
76 #undef TRACE_EVENT_FORMAT_NOFILTER
77 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
80 ftrace_format_##call(struct ftrace_event_call *unused, \
81 struct trace_seq *s) \
88 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
93 #include "trace_event_types.h"
95 #undef TRACE_ZERO_CHAR
96 #define TRACE_ZERO_CHAR(arg)
99 #define TRACE_FIELD(type, item, assign)\
100 entry->item = assign;
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)
111 #define TP_CMD(cmd...) cmd
114 #define TRACE_ENTRY entry
116 #undef TRACE_FIELD_SPECIAL
117 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
120 static int ftrace_raw_init_event(struct ftrace_event_call *event_call)
122 INIT_LIST_HEAD(&event_call->fields);
123 init_preds(event_call);
127 #undef TRACE_EVENT_FORMAT
128 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
129 int ftrace_define_fields_##call(struct ftrace_event_call *event_call); \
131 struct ftrace_event_call __used \
132 __attribute__((__aligned__(4))) \
133 __attribute__((section("_ftrace_events"))) event_##call = { \
136 .system = __stringify(TRACE_SYSTEM), \
137 .raw_init = ftrace_raw_init_event, \
138 .show_format = ftrace_format_##call, \
139 .define_fields = ftrace_define_fields_##call, \
142 #undef TRACE_EVENT_FORMAT_NOFILTER
143 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
146 struct ftrace_event_call __used \
147 __attribute__((__aligned__(4))) \
148 __attribute__((section("_ftrace_events"))) event_##call = { \
151 .system = __stringify(TRACE_SYSTEM), \
152 .show_format = ftrace_format_##call, \
155 #include "trace_event_types.h"
158 #define TRACE_FIELD(type, item, assign) \
159 ret = trace_define_field(event_call, #type, #item, \
160 offsetof(typeof(field), item), \
161 sizeof(field.item), \
162 is_signed_type(type), FILTER_OTHER); \
166 #undef TRACE_FIELD_SPECIAL
167 #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \
168 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
169 offsetof(typeof(field), item), \
170 sizeof(field.item), 0, FILTER_OTHER); \
174 #undef TRACE_FIELD_SIGN
175 #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \
176 ret = trace_define_field(event_call, #type, #item, \
177 offsetof(typeof(field), item), \
178 sizeof(field.item), is_signed, \
183 #undef TRACE_FIELD_ZERO_CHAR
184 #define TRACE_FIELD_ZERO_CHAR(item)
186 #undef TRACE_EVENT_FORMAT
187 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
189 ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
194 ret = trace_define_common_fields(event_call); \
203 #undef TRACE_EVENT_FORMAT_NOFILTER
204 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
207 #include "trace_event_types.h"