blob: 00b440df66d840a314d3ee5788758b15f936789a [file] [log] [blame]
John Kacur8b40f522009-09-24 18:02:18 +02001#ifndef __PERF_TRACE_EVENTS_H
2#define __PERF_TRACE_EVENTS_H
Steven Rostedt520509432009-08-17 16:18:05 +02003
Frederic Weisbecker1ef2ed12009-08-28 03:09:58 +02004#include "parse-events.h"
Steven Rostedt520509432009-08-17 16:18:05 +02005
6#define __unused __attribute__((unused))
7
8
9#ifndef PAGE_MASK
10#define PAGE_MASK (page_size - 1)
11#endif
12
13enum {
14 RINGBUF_TYPE_PADDING = 29,
15 RINGBUF_TYPE_TIME_EXTEND = 30,
16 RINGBUF_TYPE_TIME_STAMP = 31,
17};
18
19#ifndef TS_SHIFT
20#define TS_SHIFT 27
21#endif
22
23#define NSECS_PER_SEC 1000000000ULL
24#define NSECS_PER_USEC 1000ULL
25
26enum format_flags {
27 FIELD_IS_ARRAY = 1,
28 FIELD_IS_POINTER = 2,
Tom Zanussi26a50742009-10-06 01:09:50 -050029 FIELD_IS_SIGNED = 4,
Steven Rostedt520509432009-08-17 16:18:05 +020030};
31
32struct format_field {
33 struct format_field *next;
34 char *type;
35 char *name;
36 int offset;
37 int size;
38 unsigned long flags;
39};
40
41struct format {
42 int nr_common;
43 int nr_fields;
44 struct format_field *common_fields;
45 struct format_field *fields;
46};
47
48struct print_arg_atom {
49 char *atom;
50};
51
52struct print_arg_string {
53 char *string;
Frederic Weisbecker561f7322009-08-31 06:45:21 +020054 int offset;
Steven Rostedt520509432009-08-17 16:18:05 +020055};
56
57struct print_arg_field {
58 char *name;
59 struct format_field *field;
60};
61
62struct print_flag_sym {
63 struct print_flag_sym *next;
64 char *value;
65 char *str;
66};
67
68struct print_arg_typecast {
69 char *type;
70 struct print_arg *item;
71};
72
73struct print_arg_flags {
74 struct print_arg *field;
75 char *delim;
76 struct print_flag_sym *flags;
77};
78
79struct print_arg_symbol {
80 struct print_arg *field;
81 struct print_flag_sym *symbols;
82};
83
84struct print_arg;
85
86struct print_arg_op {
87 char *op;
88 int prio;
89 struct print_arg *left;
90 struct print_arg *right;
91};
92
93struct print_arg_func {
94 char *name;
95 struct print_arg *args;
96};
97
98enum print_arg_type {
99 PRINT_NULL,
100 PRINT_ATOM,
101 PRINT_FIELD,
102 PRINT_FLAGS,
103 PRINT_SYMBOL,
104 PRINT_TYPE,
105 PRINT_STRING,
106 PRINT_OP,
107};
108
109struct print_arg {
110 struct print_arg *next;
111 enum print_arg_type type;
112 union {
113 struct print_arg_atom atom;
114 struct print_arg_field field;
115 struct print_arg_typecast typecast;
116 struct print_arg_flags flags;
117 struct print_arg_symbol symbol;
118 struct print_arg_func func;
119 struct print_arg_string string;
120 struct print_arg_op op;
121 };
122};
123
124struct print_fmt {
125 char *format;
126 struct print_arg *args;
127};
128
129struct event {
130 struct event *next;
131 char *name;
132 int id;
133 int flags;
134 struct format format;
135 struct print_fmt print_fmt;
136};
137
138enum {
139 EVENT_FL_ISFTRACE = 1,
140 EVENT_FL_ISPRINT = 2,
141 EVENT_FL_ISBPRINT = 4,
142 EVENT_FL_ISFUNC = 8,
143 EVENT_FL_ISFUNCENT = 16,
144 EVENT_FL_ISFUNCRET = 32,
145};
146
147struct record {
148 unsigned long long ts;
149 int size;
150 void *data;
151};
152
153struct record *trace_peek_data(int cpu);
154struct record *trace_read_data(int cpu);
155
156void parse_set_info(int nr_cpus, int long_sz);
157
158void trace_report(void);
159
160void *malloc_or_die(unsigned int size);
161
162void parse_cmdlines(char *file, int size);
163void parse_proc_kallsyms(char *file, unsigned int size);
164void parse_ftrace_printk(char *file, unsigned int size);
165
166void print_funcs(void);
167void print_printk(void);
168
169int parse_ftrace_file(char *buf, unsigned long size);
170int parse_event_file(char *buf, unsigned long size, char *system);
171void print_event(int cpu, void *data, int size, unsigned long long nsecs,
172 char *comm);
173
174extern int file_bigendian;
175extern int host_bigendian;
176
177int bigendian(void);
178
179static inline unsigned short __data2host2(unsigned short data)
180{
181 unsigned short swap;
182
183 if (host_bigendian == file_bigendian)
184 return data;
185
186 swap = ((data & 0xffULL) << 8) |
187 ((data & (0xffULL << 8)) >> 8);
188
189 return swap;
190}
191
192static inline unsigned int __data2host4(unsigned int data)
193{
194 unsigned int swap;
195
196 if (host_bigendian == file_bigendian)
197 return data;
198
199 swap = ((data & 0xffULL) << 24) |
200 ((data & (0xffULL << 8)) << 8) |
201 ((data & (0xffULL << 16)) >> 8) |
202 ((data & (0xffULL << 24)) >> 24);
203
204 return swap;
205}
206
207static inline unsigned long long __data2host8(unsigned long long data)
208{
209 unsigned long long swap;
210
211 if (host_bigendian == file_bigendian)
212 return data;
213
214 swap = ((data & 0xffULL) << 56) |
215 ((data & (0xffULL << 8)) << 40) |
216 ((data & (0xffULL << 16)) << 24) |
217 ((data & (0xffULL << 24)) << 8) |
218 ((data & (0xffULL << 32)) >> 8) |
219 ((data & (0xffULL << 40)) >> 24) |
220 ((data & (0xffULL << 48)) >> 40) |
221 ((data & (0xffULL << 56)) >> 56);
222
223 return swap;
224}
225
226#define data2host2(ptr) __data2host2(*(unsigned short *)ptr)
227#define data2host4(ptr) __data2host4(*(unsigned int *)ptr)
228#define data2host8(ptr) __data2host8(*(unsigned long long *)ptr)
229
230extern int header_page_ts_offset;
231extern int header_page_ts_size;
232extern int header_page_size_offset;
233extern int header_page_size_size;
234extern int header_page_data_offset;
235extern int header_page_data_size;
236
237int parse_header_page(char *buf, unsigned long size);
Ingo Molnarec156762009-09-11 12:12:54 +0200238int trace_parse_common_type(void *data);
239struct event *trace_find_event(int id);
Frederic Weisbecker46538812009-09-12 02:43:45 +0200240unsigned long long
241raw_field_value(struct event *event, const char *name, void *data);
242void *raw_field_ptr(struct event *event, const char *name, void *data);
Steven Rostedt520509432009-08-17 16:18:05 +0200243
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200244void read_tracing_data(struct perf_event_attr *pattrs, int nb_events);
Steven Rostedt520509432009-08-17 16:18:05 +0200245
John Kacur8b40f522009-09-24 18:02:18 +0200246#endif /* __PERF_TRACE_EVENTS_H */