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"
19 #define TRACE_SYSTEM ftrace
21 struct ftrace_event_class event_class_ftrace = {
22 .system = __stringify(TRACE_SYSTEM),
25 /* not needed for this file */
27 #define __field_struct(type, item)
30 #define __field(type, item) type item;
33 #define __field_desc(type, container, item) type item;
36 #define __array(type, item, size) type item[size];
39 #define __array_desc(type, container, item, size) type item[size];
41 #undef __dynamic_array
42 #define __dynamic_array(type, item) type item[];
45 #define F_STRUCT(args...) args
48 #define F_printk(fmt, args...) fmt, args
51 #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
52 struct ____ftrace_##name { \
55 static void __always_unused ____ftrace_check_##name(void) \
57 struct ____ftrace_##name *__entry = NULL; \
59 /* force compile-time check on F_printk() */ \
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))
67 #include "trace_entries.h"
70 #define __field(type, item) \
71 ret = trace_define_field(event_call, #type, #item, \
72 offsetof(typeof(field), item), \
74 is_signed_type(type), FILTER_OTHER); \
79 #define __field_desc(type, container, item) \
80 ret = trace_define_field(event_call, #type, #item, \
81 offsetof(typeof(field), \
83 sizeof(field.container.item), \
84 is_signed_type(type), FILTER_OTHER); \
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), \
94 is_signed_type(type), FILTER_OTHER); \
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), \
104 sizeof(field.container.item), \
105 is_signed_type(type), FILTER_OTHER); \
109 #undef __dynamic_array
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);\
118 #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
120 ftrace_define_fields_##name(struct ftrace_event_call *event_call) \
122 struct struct_name field; \
130 #include "trace_entries.h"
132 static int ftrace_raw_init_event(struct ftrace_event_call *call)
134 INIT_LIST_HEAD(&call->fields);
142 #define __field(type, item)
145 #define __field_desc(type, container, item)
148 #define __array(type, item, len)
151 #define __array_desc(type, container, item, len)
153 #undef __dynamic_array
154 #define __dynamic_array(type, item)
157 #define F_printk(fmt, args...) #fmt ", " __stringify(args)
160 #define FTRACE_ENTRY(call, struct_name, type, tstruct, print) \
162 struct ftrace_event_call __used \
163 __attribute__((__aligned__(4))) \
164 __attribute__((section("_ftrace_events"))) event_##call = { \
167 .class = &event_class_ftrace, \
168 .raw_init = ftrace_raw_init_event, \
169 .print_fmt = print, \
170 .define_fields = ftrace_define_fields_##call, \
173 #include "trace_entries.h"