Commit | Line | Data |
---|---|---|
770cb243 SR |
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 | ||
4e5292ea SR |
18 | #undef TRACE_SYSTEM |
19 | #define TRACE_SYSTEM ftrace | |
da4d0302 | 20 | |
8f082018 SR |
21 | struct ftrace_event_class event_class_ftrace = { |
22 | .system = __stringify(TRACE_SYSTEM), | |
23 | }; | |
24 | ||
4e5292ea SR |
25 | /* not needed for this file */ |
26 | #undef __field_struct | |
27 | #define __field_struct(type, item) | |
da4d0302 | 28 | |
05ffa2d0 LZ |
29 | #undef __field |
30 | #define __field(type, item) type item; | |
31 | ||
32 | #undef __field_desc | |
33 | #define __field_desc(type, container, item) type item; | |
34 | ||
35 | #undef __array | |
36 | #define __array(type, item, size) type item[size]; | |
37 | ||
38 | #undef __array_desc | |
39 | #define __array_desc(type, container, item, size) type item[size]; | |
40 | ||
41 | #undef __dynamic_array | |
42 | #define __dynamic_array(type, item) type item[]; | |
43 | ||
44 | #undef F_STRUCT | |
45 | #define F_STRUCT(args...) args | |
46 | ||
47 | #undef F_printk | |
48 | #define F_printk(fmt, args...) fmt, args | |
49 | ||
50 | #undef FTRACE_ENTRY | |
51 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ | |
52 | struct ____ftrace_##name { \ | |
53 | tstruct \ | |
54 | }; \ | |
5e9b3972 | 55 | static void __always_unused ____ftrace_check_##name(void) \ |
05ffa2d0 LZ |
56 | { \ |
57 | struct ____ftrace_##name *__entry = NULL; \ | |
58 | \ | |
5e9b3972 | 59 | /* force compile-time check on F_printk() */ \ |
05ffa2d0 LZ |
60 | printk(print); \ |
61 | } | |
62 | ||
63 | #undef FTRACE_ENTRY_DUP | |
64 | #define FTRACE_ENTRY_DUP(name, struct_name, id, tstruct, print) \ | |
65 | FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) | |
66 | ||
67 | #include "trace_entries.h" | |
68 | ||
4e5292ea SR |
69 | #undef __field |
70 | #define __field(type, item) \ | |
71 | ret = trace_define_field(event_call, #type, #item, \ | |
72 | offsetof(typeof(field), item), \ | |
73 | sizeof(field.item), \ | |
74 | is_signed_type(type), FILTER_OTHER); \ | |
75 | if (ret) \ | |
76 | return ret; | |
77 | ||
78 | #undef __field_desc | |
79 | #define __field_desc(type, container, item) \ | |
80 | ret = trace_define_field(event_call, #type, #item, \ | |
81 | offsetof(typeof(field), \ | |
82 | container.item), \ | |
83 | sizeof(field.container.item), \ | |
84 | is_signed_type(type), FILTER_OTHER); \ | |
85 | if (ret) \ | |
86 | return ret; | |
87 | ||
88 | #undef __array | |
89 | #define __array(type, item, len) \ | |
90 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | |
91 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | |
92 | offsetof(typeof(field), item), \ | |
fb7ae981 LJ |
93 | sizeof(field.item), \ |
94 | is_signed_type(type), FILTER_OTHER); \ | |
4e5292ea SR |
95 | if (ret) \ |
96 | return ret; | |
97 | ||
98 | #undef __array_desc | |
99 | #define __array_desc(type, container, item, len) \ | |
100 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | |
101 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | |
102 | offsetof(typeof(field), \ | |
103 | container.item), \ | |
fb7ae981 LJ |
104 | sizeof(field.container.item), \ |
105 | is_signed_type(type), FILTER_OTHER); \ | |
4e5292ea SR |
106 | if (ret) \ |
107 | return ret; | |
108 | ||
109 | #undef __dynamic_array | |
809826a3 LJ |
110 | #define __dynamic_array(type, item) \ |
111 | ret = trace_define_field(event_call, #type, #item, \ | |
112 | offsetof(typeof(field), item), \ | |
113 | 0, is_signed_type(type), FILTER_OTHER);\ | |
114 | if (ret) \ | |
115 | return ret; | |
4e5292ea SR |
116 | |
117 | #undef FTRACE_ENTRY | |
118 | #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \ | |
119 | int \ | |
120 | ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ | |
e45f2e2b | 121 | { \ |
4e5292ea | 122 | struct struct_name field; \ |
e45f2e2b TZ |
123 | int ret; \ |
124 | \ | |
4e5292ea | 125 | tstruct; \ |
e45f2e2b TZ |
126 | \ |
127 | return ret; \ | |
128 | } | |
129 | ||
4e5292ea SR |
130 | #include "trace_entries.h" |
131 | ||
d7a4b414 FW |
132 | static int ftrace_raw_init_event(struct ftrace_event_call *call) |
133 | { | |
134 | INIT_LIST_HEAD(&call->fields); | |
135 | return 0; | |
136 | } | |
4e5292ea | 137 | |
509e760c LJ |
138 | #undef __entry |
139 | #define __entry REC | |
140 | ||
4e5292ea SR |
141 | #undef __field |
142 | #define __field(type, item) | |
143 | ||
144 | #undef __field_desc | |
145 | #define __field_desc(type, container, item) | |
146 | ||
147 | #undef __array | |
148 | #define __array(type, item, len) | |
149 | ||
150 | #undef __array_desc | |
151 | #define __array_desc(type, container, item, len) | |
152 | ||
153 | #undef __dynamic_array | |
154 | #define __dynamic_array(type, item) | |
155 | ||
509e760c LJ |
156 | #undef F_printk |
157 | #define F_printk(fmt, args...) #fmt ", " __stringify(args) | |
158 | ||
4e5292ea SR |
159 | #undef FTRACE_ENTRY |
160 | #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \ | |
770cb243 | 161 | \ |
e1112b4d | 162 | struct ftrace_event_call __used \ |
770cb243 SR |
163 | __attribute__((__aligned__(4))) \ |
164 | __attribute__((section("_ftrace_events"))) event_##call = { \ | |
ef18012b | 165 | .name = #call, \ |
4e5292ea | 166 | .id = type, \ |
8f082018 | 167 | .class = &event_class_ftrace, \ |
d7a4b414 | 168 | .raw_init = ftrace_raw_init_event, \ |
509e760c | 169 | .print_fmt = print, \ |
e1112b4d TZ |
170 | .define_fields = ftrace_define_fields_##call, \ |
171 | }; \ | |
e1112b4d | 172 | |
4e5292ea | 173 | #include "trace_entries.h" |