blob: 3ddb8947be8a5eef55c7d786cd3ac5ec9c28b67c [file] [log] [blame]
Steven Rostedt520509432009-08-17 16:18:05 +02001#ifndef _PARSE_EVENTS_H
2#define _PARSE_EVENTS_H
3
4
5#define __unused __attribute__((unused))
6
7
8#ifndef PAGE_MASK
9#define PAGE_MASK (page_size - 1)
10#endif
11
12enum {
13 RINGBUF_TYPE_PADDING = 29,
14 RINGBUF_TYPE_TIME_EXTEND = 30,
15 RINGBUF_TYPE_TIME_STAMP = 31,
16};
17
18#ifndef TS_SHIFT
19#define TS_SHIFT 27
20#endif
21
22#define NSECS_PER_SEC 1000000000ULL
23#define NSECS_PER_USEC 1000ULL
24
25enum format_flags {
26 FIELD_IS_ARRAY = 1,
27 FIELD_IS_POINTER = 2,
28};
29
30struct format_field {
31 struct format_field *next;
32 char *type;
33 char *name;
34 int offset;
35 int size;
36 unsigned long flags;
37};
38
39struct format {
40 int nr_common;
41 int nr_fields;
42 struct format_field *common_fields;
43 struct format_field *fields;
44};
45
46struct print_arg_atom {
47 char *atom;
48};
49
50struct print_arg_string {
51 char *string;
52};
53
54struct print_arg_field {
55 char *name;
56 struct format_field *field;
57};
58
59struct print_flag_sym {
60 struct print_flag_sym *next;
61 char *value;
62 char *str;
63};
64
65struct print_arg_typecast {
66 char *type;
67 struct print_arg *item;
68};
69
70struct print_arg_flags {
71 struct print_arg *field;
72 char *delim;
73 struct print_flag_sym *flags;
74};
75
76struct print_arg_symbol {
77 struct print_arg *field;
78 struct print_flag_sym *symbols;
79};
80
81struct print_arg;
82
83struct print_arg_op {
84 char *op;
85 int prio;
86 struct print_arg *left;
87 struct print_arg *right;
88};
89
90struct print_arg_func {
91 char *name;
92 struct print_arg *args;
93};
94
95enum 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,
104};
105
106struct 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;
118 };
119};
120
121struct print_fmt {
122 char *format;
123 struct print_arg *args;
124};
125
126struct event {
127 struct event *next;
128 char *name;
129 int id;
130 int flags;
131 struct format format;
132 struct print_fmt print_fmt;
133};
134
135enum {
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,
142};
143
144struct record {
145 unsigned long long ts;
146 int size;
147 void *data;
148};
149
150struct record *trace_peek_data(int cpu);
151struct record *trace_read_data(int cpu);
152
153void parse_set_info(int nr_cpus, int long_sz);
154
155void trace_report(void);
156
157void *malloc_or_die(unsigned int size);
158
159void parse_cmdlines(char *file, int size);
160void parse_proc_kallsyms(char *file, unsigned int size);
161void parse_ftrace_printk(char *file, unsigned int size);
162
163void print_funcs(void);
164void print_printk(void);
165
166int parse_ftrace_file(char *buf, unsigned long size);
167int parse_event_file(char *buf, unsigned long size, char *system);
168void print_event(int cpu, void *data, int size, unsigned long long nsecs,
169 char *comm);
170
171extern int file_bigendian;
172extern int host_bigendian;
173
174int bigendian(void);
175
176static inline unsigned short __data2host2(unsigned short data)
177{
178 unsigned short swap;
179
180 if (host_bigendian == file_bigendian)
181 return data;
182
183 swap = ((data & 0xffULL) << 8) |
184 ((data & (0xffULL << 8)) >> 8);
185
186 return swap;
187}
188
189static inline unsigned int __data2host4(unsigned int data)
190{
191 unsigned int swap;
192
193 if (host_bigendian == file_bigendian)
194 return data;
195
196 swap = ((data & 0xffULL) << 24) |
197 ((data & (0xffULL << 8)) << 8) |
198 ((data & (0xffULL << 16)) >> 8) |
199 ((data & (0xffULL << 24)) >> 24);
200
201 return swap;
202}
203
204static inline unsigned long long __data2host8(unsigned long long data)
205{
206 unsigned long long swap;
207
208 if (host_bigendian == file_bigendian)
209 return data;
210
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);
219
220 return swap;
221}
222
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)
226
227extern int header_page_ts_offset;
228extern int header_page_ts_size;
229extern int header_page_size_offset;
230extern int header_page_size_size;
231extern int header_page_data_offset;
232extern int header_page_data_size;
233
234int parse_header_page(char *buf, unsigned long size);
235
236void read_tracing_data(void);
237
238#endif /* _PARSE_EVENTS_H */