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)); \
55 #define TP_RAW_FMT(args...) args
57 #undef TRACE_EVENT_FORMAT
58 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
60 ftrace_format_##call(struct trace_seq *s) \
67 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
72 #undef TRACE_EVENT_FORMAT_NOFILTER
73 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
76 ftrace_format_##call(struct trace_seq *s) \
83 trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
88 #include "trace_event_types.h"
90 #undef TRACE_ZERO_CHAR
91 #define TRACE_ZERO_CHAR(arg)
94 #define TRACE_FIELD(type, item, assign)\
98 #define TRACE_FIELD(type, item, assign)\
102 #define TP_CMD(cmd...) cmd
105 #define TRACE_ENTRY entry
107 #undef TRACE_FIELD_SPECIAL
108 #define TRACE_FIELD_SPECIAL(type_item, item, len, cmd) \
111 #undef TRACE_EVENT_FORMAT
112 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
113 int ftrace_define_fields_##call(void); \
114 static int ftrace_raw_init_event_##call(void); \
116 struct ftrace_event_call __used \
117 __attribute__((__aligned__(4))) \
118 __attribute__((section("_ftrace_events"))) event_##call = { \
121 .system = __stringify(TRACE_SYSTEM), \
122 .raw_init = ftrace_raw_init_event_##call, \
123 .show_format = ftrace_format_##call, \
124 .define_fields = ftrace_define_fields_##call, \
126 static int ftrace_raw_init_event_##call(void) \
128 INIT_LIST_HEAD(&event_##call.fields); \
129 init_preds(&event_##call); \
133 #undef TRACE_EVENT_FORMAT_NOFILTER
134 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
137 struct ftrace_event_call __used \
138 __attribute__((__aligned__(4))) \
139 __attribute__((section("_ftrace_events"))) event_##call = { \
142 .system = __stringify(TRACE_SYSTEM), \
143 .show_format = ftrace_format_##call, \
146 #include "trace_event_types.h"
149 #define TRACE_FIELD(type, item, assign) \
150 ret = trace_define_field(event_call, #type, #item, \
151 offsetof(typeof(field), item), \
152 sizeof(field.item)); \
156 #undef TRACE_FIELD_SPECIAL
157 #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \
158 ret = trace_define_field(event_call, #type "[" #len "]", #item, \
159 offsetof(typeof(field), item), \
160 sizeof(field.item)); \
164 #undef TRACE_FIELD_ZERO_CHAR
165 #define TRACE_FIELD_ZERO_CHAR(item)
167 #undef TRACE_EVENT_FORMAT
168 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
170 ftrace_define_fields_##call(void) \
172 struct ftrace_event_call *event_call = &event_##call; \
176 __common_field(unsigned char, type); \
177 __common_field(unsigned char, flags); \
178 __common_field(unsigned char, preempt_count); \
179 __common_field(int, pid); \
180 __common_field(int, tgid); \
187 #undef TRACE_EVENT_FORMAT_NOFILTER
188 #define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, \
191 #include "trace_event_types.h"
This page took 0.105259 seconds and 5 git commands to generate.