1 #ifndef _LINUX_FTRACE_EVENT_H
2 #define _LINUX_FTRACE_EVENT_H
4 #include <linux/trace_seq.h>
5 #include <linux/ring_buffer.h>
12 * The trace entry - the most basic unit of tracing. This is what
13 * is printed in the end as a single line in the trace output, such as:
15 * bash-15816 [01] 235.197585: idle_cpu <- irq_enter
20 unsigned char preempt_count;
26 * Trace iterator - used by printout routines who present trace
27 * results to users and which routines might sleep, etc:
29 struct trace_iterator {
30 struct trace_array *tr;
35 struct ring_buffer_iter *buffer_iter[NR_CPUS];
37 /* The below is zeroed out in pipe_read */
39 struct trace_entry *ent;
43 unsigned long iter_flags;
47 cpumask_var_t started;
51 typedef enum print_line_t (*trace_print_func)(struct trace_iterator *iter,
54 struct hlist_node node;
56 trace_print_func trace;
59 trace_print_func binary;
62 extern int register_ftrace_event(struct trace_event *event);
63 extern int unregister_ftrace_event(struct trace_event *event);
65 /* Return values for print_line callback */
67 TRACE_TYPE_PARTIAL_LINE = 0, /* Retry after flushing the seq */
68 TRACE_TYPE_HANDLED = 1,
69 TRACE_TYPE_UNHANDLED = 2, /* Relay to other output functions */
70 TRACE_TYPE_NO_CONSUME = 3 /* Handled but ask to not consume */
74 struct ring_buffer_event *
75 trace_current_buffer_lock_reserve(unsigned char type, unsigned long len,
76 unsigned long flags, int pc);
77 void trace_current_buffer_unlock_commit(struct ring_buffer_event *event,
78 unsigned long flags, int pc);
79 void trace_nowake_buffer_unlock_commit(struct ring_buffer_event *event,
80 unsigned long flags, int pc);
81 void trace_current_buffer_discard_commit(struct ring_buffer_event *event);
83 void tracing_record_cmdline(struct task_struct *tsk);
85 struct ftrace_event_call {
86 struct list_head list;
92 void (*unregfunc)(void);
94 int (*raw_init)(void);
95 int (*show_format)(struct trace_seq *s);
96 int (*define_fields)(void);
97 struct list_head fields;
99 struct filter_pred **preds;
101 #ifdef CONFIG_EVENT_PROFILE
102 atomic_t profile_count;
103 int (*profile_enable)(struct ftrace_event_call *);
104 void (*profile_disable)(struct ftrace_event_call *);
108 #define MAX_FILTER_PRED 8
109 #define MAX_FILTER_STR_VAL 128
111 extern int init_preds(struct ftrace_event_call *call);
112 extern int filter_match_preds(struct ftrace_event_call *call, void *rec);
113 extern int filter_current_check_discard(struct ftrace_event_call *call,
115 struct ring_buffer_event *event);
117 extern int trace_define_field(struct ftrace_event_call *call, char *type,
118 char *name, int offset, int size);
122 * The double __builtin_constant_p is because gcc will give us an error
123 * if we try to allocate the static variable to fmt if it is not a
124 * constant. Even with the outer if statement optimizing out.
126 #define event_trace_printk(ip, fmt, args...) \
128 __trace_printk_check_format(fmt, ##args); \
129 tracing_record_cmdline(current); \
130 if (__builtin_constant_p(fmt)) { \
131 static const char *trace_printk_fmt \
132 __attribute__((section("__trace_printk_fmt"))) = \
133 __builtin_constant_p(fmt) ? fmt : NULL; \
135 __trace_bprintk(ip, trace_printk_fmt, ##args); \
137 __trace_printk(ip, fmt, ##args); \
140 #define __common_field(type, item) \
141 ret = trace_define_field(event_call, #type, "common_" #item, \
142 offsetof(typeof(field.ent), item), \
143 sizeof(field.ent.item)); \
147 #endif /* _LINUX_FTRACE_EVENT_H */