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
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)); \
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)); \
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)); \
51 #define TP_RAW_FMT(args...) args
53 #undef TRACE_EVENT_FORMAT
54 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
56 ftrace_format_##call(struct trace_seq *s) \
63 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
68 #undef TRACE_EVENT_FORMAT_NOFILTER
69 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
72 ftrace_format_##call(struct trace_seq *s) \
79 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
84 #include "trace_event_types.h"
86 #undef TRACE_ZERO_CHAR
87 #define TRACE_ZERO_CHAR(arg)
90 #define TRACE_FIELD(type, item, assign)\
94 #define TRACE_FIELD(type, item, assign)\
98 #define TP_CMD(cmd...) cmd
101 #define TRACE_ENTRY entry
103 #undef TRACE_FIELD_SPECIAL
104 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
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); \
112 struct ftrace_event_call __used \
113 __attribute__((__aligned__(4))) \
114 __attribute__((section("_ftrace_events"))) event_##call = { \
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, \
122 static int ftrace_raw_init_event_##call(void) \
124 INIT_LIST_HEAD(&event_##call.fields); \
125 init_preds(&event_##call); \
129 #undef TRACE_EVENT_FORMAT_NOFILTER
130 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
133 struct ftrace_event_call __used \
134 __attribute__((__aligned__(4))) \
135 __attribute__((section("_ftrace_events"))) event_##call = { \
138 .system = __stringify(TRACE_SYSTEM), \
139 .show_format = ftrace_format_##call, \
142 #include "trace_event_types.h"
145 #define TRACE_FIELD(type, item, assign) \
146 ret = trace_define_field(event_call, #type, #item, \
147 offsetof(typeof(field), item), \
148 sizeof(field.item)); \
152 #undef TRACE_FIELD_SPECIAL
153 #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \
154 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
155 offsetof(typeof(field), item), \
156 sizeof(field.item)); \
160 #undef TRACE_FIELD_ZERO_CHAR
161 #define TRACE_FIELD_ZERO_CHAR(item)
163 #undef TRACE_EVENT_FORMAT
164 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
166 ftrace_define_fields_##call(void) \
168 struct ftrace_event_call *event_call = &event_##call; \
172 __common_field(unsigned char, type); \
173 __common_field(unsigned char, flags); \
174 __common_field(unsigned char, preempt_count); \
175 __common_field(int, pid); \
176 __common_field(int, tgid); \
183 #undef TRACE_EVENT_FORMAT_NOFILTER
184 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
187 #include "trace_event_types.h"