perf tools: Add trace event debugfs IO handler
[linux-2.6/libata-dev.git] / tools / perf / util / trace-event.h
blob3ddb8947be8a5eef55c7d786cd3ac5ec9c28b67c
1 #ifndef _PARSE_EVENTS_H
2 #define _PARSE_EVENTS_H
5 #define __unused __attribute__((unused))
8 #ifndef PAGE_MASK
9 #define PAGE_MASK (page_size - 1)
10 #endif
12 enum {
13 RINGBUF_TYPE_PADDING = 29,
14 RINGBUF_TYPE_TIME_EXTEND = 30,
15 RINGBUF_TYPE_TIME_STAMP = 31,
18 #ifndef TS_SHIFT
19 #define TS_SHIFT 27
20 #endif
22 #define NSECS_PER_SEC 1000000000ULL
23 #define NSECS_PER_USEC 1000ULL
25 enum format_flags {
26 FIELD_IS_ARRAY = 1,
27 FIELD_IS_POINTER = 2,
30 struct format_field {
31 struct format_field *next;
32 char *type;
33 char *name;
34 int offset;
35 int size;
36 unsigned long flags;
39 struct format {
40 int nr_common;
41 int nr_fields;
42 struct format_field *common_fields;
43 struct format_field *fields;
46 struct print_arg_atom {
47 char *atom;
50 struct print_arg_string {
51 char *string;
54 struct print_arg_field {
55 char *name;
56 struct format_field *field;
59 struct print_flag_sym {
60 struct print_flag_sym *next;
61 char *value;
62 char *str;
65 struct print_arg_typecast {
66 char *type;
67 struct print_arg *item;
70 struct print_arg_flags {
71 struct print_arg *field;
72 char *delim;
73 struct print_flag_sym *flags;
76 struct print_arg_symbol {
77 struct print_arg *field;
78 struct print_flag_sym *symbols;
81 struct print_arg;
83 struct print_arg_op {
84 char *op;
85 int prio;
86 struct print_arg *left;
87 struct print_arg *right;
90 struct print_arg_func {
91 char *name;
92 struct print_arg *args;
95 enum print_arg_type {
96 PRINT_NULL,
97 PRINT_ATOM,
98 PRINT_FIELD,
99 PRINT_FLAGS,
100 PRINT_SYMBOL,
101 PRINT_TYPE,
102 PRINT_STRING,
103 PRINT_OP,
106 struct print_arg {
107 struct print_arg *next;
108 enum print_arg_type type;
109 union {
110 struct print_arg_atom atom;
111 struct print_arg_field field;
112 struct print_arg_typecast typecast;
113 struct print_arg_flags flags;
114 struct print_arg_symbol symbol;
115 struct print_arg_func func;
116 struct print_arg_string string;
117 struct print_arg_op op;
121 struct print_fmt {
122 char *format;
123 struct print_arg *args;
126 struct event {
127 struct event *next;
128 char *name;
129 int id;
130 int flags;
131 struct format format;
132 struct print_fmt print_fmt;
135 enum {
136 EVENT_FL_ISFTRACE = 1,
137 EVENT_FL_ISPRINT = 2,
138 EVENT_FL_ISBPRINT = 4,
139 EVENT_FL_ISFUNC = 8,
140 EVENT_FL_ISFUNCENT = 16,
141 EVENT_FL_ISFUNCRET = 32,
144 struct record {
145 unsigned long long ts;
146 int size;
147 void *data;
150 struct record *trace_peek_data(int cpu);
151 struct record *trace_read_data(int cpu);
153 void parse_set_info(int nr_cpus, int long_sz);
155 void trace_report(void);
157 void *malloc_or_die(unsigned int size);
159 void parse_cmdlines(char *file, int size);
160 void parse_proc_kallsyms(char *file, unsigned int size);
161 void parse_ftrace_printk(char *file, unsigned int size);
163 void print_funcs(void);
164 void print_printk(void);
166 int parse_ftrace_file(char *buf, unsigned long size);
167 int parse_event_file(char *buf, unsigned long size, char *system);
168 void print_event(int cpu, void *data, int size, unsigned long long nsecs,
169 char *comm);
171 extern int file_bigendian;
172 extern int host_bigendian;
174 int bigendian(void);
176 static inline unsigned short __data2host2(unsigned short data)
178 unsigned short swap;
180 if (host_bigendian == file_bigendian)
181 return data;
183 swap = ((data & 0xffULL) << 8) |
184 ((data & (0xffULL << 8)) >> 8);
186 return swap;
189 static inline unsigned int __data2host4(unsigned int data)
191 unsigned int swap;
193 if (host_bigendian == file_bigendian)
194 return data;
196 swap = ((data & 0xffULL) << 24) |
197 ((data & (0xffULL << 8)) << 8) |
198 ((data & (0xffULL << 16)) >> 8) |
199 ((data & (0xffULL << 24)) >> 24);
201 return swap;
204 static inline unsigned long long __data2host8(unsigned long long data)
206 unsigned long long swap;
208 if (host_bigendian == file_bigendian)
209 return data;
211 swap = ((data & 0xffULL) << 56) |
212 ((data & (0xffULL << 8)) << 40) |
213 ((data & (0xffULL << 16)) << 24) |
214 ((data & (0xffULL << 24)) << 8) |
215 ((data & (0xffULL << 32)) >> 8) |
216 ((data & (0xffULL << 40)) >> 24) |
217 ((data & (0xffULL << 48)) >> 40) |
218 ((data & (0xffULL << 56)) >> 56);
220 return swap;
223 #define data2host2(ptr) __data2host2(*(unsigned short *)ptr)
224 #define data2host4(ptr) __data2host4(*(unsigned int *)ptr)
225 #define data2host8(ptr) __data2host8(*(unsigned long long *)ptr)
227 extern int header_page_ts_offset;
228 extern int header_page_ts_size;
229 extern int header_page_size_offset;
230 extern int header_page_size_size;
231 extern int header_page_data_offset;
232 extern int header_page_data_size;
234 int parse_header_page(char *buf, unsigned long size);
236 void read_tracing_data(void);
238 #endif /* _PARSE_EVENTS_H */