Merge branch 'fixes-for-arm-soc' of git://sources.calxeda.com/kernel/linux into fixes
[linux-2.6-block.git] / tools / perf / util / trace-event.h
CommitLineData
8b40f521
JK
1#ifndef __PERF_TRACE_EVENTS_H
2#define __PERF_TRACE_EVENTS_H
52050943 3
c0555642 4#include <stdbool.h>
1ef2ed10 5#include "parse-events.h"
743eb868
ACM
6
7struct machine;
8struct perf_sample;
9union perf_event;
10struct thread;
52050943
SR
11
12#define __unused __attribute__((unused))
13
14
15#ifndef PAGE_MASK
16#define PAGE_MASK (page_size - 1)
17#endif
18
19enum {
20 RINGBUF_TYPE_PADDING = 29,
21 RINGBUF_TYPE_TIME_EXTEND = 30,
22 RINGBUF_TYPE_TIME_STAMP = 31,
23};
24
25#ifndef TS_SHIFT
26#define TS_SHIFT 27
27#endif
28
29#define NSECS_PER_SEC 1000000000ULL
30#define NSECS_PER_USEC 1000ULL
31
32enum format_flags {
33 FIELD_IS_ARRAY = 1,
34 FIELD_IS_POINTER = 2,
26a50744 35 FIELD_IS_SIGNED = 4,
064739bc
TZ
36 FIELD_IS_STRING = 8,
37 FIELD_IS_DYNAMIC = 16,
eb9a42ca
TZ
38 FIELD_IS_FLAG = 32,
39 FIELD_IS_SYMBOLIC = 64,
52050943
SR
40};
41
42struct format_field {
43 struct format_field *next;
44 char *type;
45 char *name;
46 int offset;
47 int size;
48 unsigned long flags;
49};
50
51struct format {
52 int nr_common;
53 int nr_fields;
54 struct format_field *common_fields;
55 struct format_field *fields;
56};
57
58struct print_arg_atom {
59 char *atom;
60};
61
62struct print_arg_string {
63 char *string;
561f732c 64 int offset;
52050943
SR
65};
66
67struct print_arg_field {
68 char *name;
69 struct format_field *field;
70};
71
72struct print_flag_sym {
73 struct print_flag_sym *next;
74 char *value;
75 char *str;
76};
77
78struct print_arg_typecast {
79 char *type;
80 struct print_arg *item;
81};
82
83struct print_arg_flags {
84 struct print_arg *field;
85 char *delim;
86 struct print_flag_sym *flags;
87};
88
89struct print_arg_symbol {
90 struct print_arg *field;
91 struct print_flag_sym *symbols;
92};
93
94struct print_arg;
95
96struct print_arg_op {
97 char *op;
98 int prio;
99 struct print_arg *left;
100 struct print_arg *right;
101};
102
103struct print_arg_func {
104 char *name;
105 struct print_arg *args;
106};
107
108enum print_arg_type {
109 PRINT_NULL,
110 PRINT_ATOM,
111 PRINT_FIELD,
112 PRINT_FLAGS,
113 PRINT_SYMBOL,
114 PRINT_TYPE,
115 PRINT_STRING,
116 PRINT_OP,
117};
118
119struct print_arg {
120 struct print_arg *next;
121 enum print_arg_type type;
122 union {
123 struct print_arg_atom atom;
124 struct print_arg_field field;
125 struct print_arg_typecast typecast;
126 struct print_arg_flags flags;
127 struct print_arg_symbol symbol;
128 struct print_arg_func func;
129 struct print_arg_string string;
130 struct print_arg_op op;
131 };
132};
133
134struct print_fmt {
135 char *format;
136 struct print_arg *args;
137};
138
139struct event {
140 struct event *next;
141 char *name;
142 int id;
143 int flags;
144 struct format format;
145 struct print_fmt print_fmt;
27746018 146 char *system;
52050943
SR
147};
148
149enum {
07a4bddd
SR
150 EVENT_FL_ISFTRACE = 0x01,
151 EVENT_FL_ISPRINT = 0x02,
152 EVENT_FL_ISBPRINT = 0x04,
153 EVENT_FL_ISFUNC = 0x08,
154 EVENT_FL_ISFUNCENT = 0x10,
155 EVENT_FL_ISFUNCRET = 0x20,
156
157 EVENT_FL_FAILED = 0x80000000
52050943
SR
158};
159
160struct record {
161 unsigned long long ts;
162 int size;
163 void *data;
164};
165
166struct record *trace_peek_data(int cpu);
167struct record *trace_read_data(int cpu);
168
169void parse_set_info(int nr_cpus, int long_sz);
170
454c407e 171ssize_t trace_report(int fd, bool repipe);
52050943
SR
172
173void *malloc_or_die(unsigned int size);
174
175void parse_cmdlines(char *file, int size);
176void parse_proc_kallsyms(char *file, unsigned int size);
177void parse_ftrace_printk(char *file, unsigned int size);
178
179void print_funcs(void);
180void print_printk(void);
181
182int parse_ftrace_file(char *buf, unsigned long size);
27746018 183int parse_event_file(char *buf, unsigned long size, char *sys);
c70c94b4 184void print_trace_event(int cpu, void *data, int size);
52050943
SR
185
186extern int file_bigendian;
187extern int host_bigendian;
188
189int bigendian(void);
190
191static inline unsigned short __data2host2(unsigned short data)
192{
193 unsigned short swap;
194
195 if (host_bigendian == file_bigendian)
196 return data;
197
198 swap = ((data & 0xffULL) << 8) |
199 ((data & (0xffULL << 8)) >> 8);
200
201 return swap;
202}
203
204static inline unsigned int __data2host4(unsigned int data)
205{
206 unsigned int swap;
207
208 if (host_bigendian == file_bigendian)
209 return data;
210
211 swap = ((data & 0xffULL) << 24) |
212 ((data & (0xffULL << 8)) << 8) |
213 ((data & (0xffULL << 16)) >> 8) |
214 ((data & (0xffULL << 24)) >> 24);
215
216 return swap;
217}
218
219static inline unsigned long long __data2host8(unsigned long long data)
220{
221 unsigned long long swap;
222
223 if (host_bigendian == file_bigendian)
224 return data;
225
226 swap = ((data & 0xffULL) << 56) |
227 ((data & (0xffULL << 8)) << 40) |
228 ((data & (0xffULL << 16)) << 24) |
229 ((data & (0xffULL << 24)) << 8) |
230 ((data & (0xffULL << 32)) >> 8) |
231 ((data & (0xffULL << 40)) >> 24) |
232 ((data & (0xffULL << 48)) >> 40) |
233 ((data & (0xffULL << 56)) >> 56);
234
235 return swap;
236}
237
238#define data2host2(ptr) __data2host2(*(unsigned short *)ptr)
239#define data2host4(ptr) __data2host4(*(unsigned int *)ptr)
85cb68b2
FW
240#define data2host8(ptr) ({ \
241 unsigned long long __val; \
242 \
243 memcpy(&__val, (ptr), sizeof(unsigned long long)); \
244 __data2host8(__val); \
245})
52050943
SR
246
247extern int header_page_ts_offset;
248extern int header_page_ts_size;
249extern int header_page_size_offset;
250extern int header_page_size_size;
251extern int header_page_data_offset;
252extern int header_page_data_size;
253
c0555642 254extern bool latency_format;
cda48461 255
ec156764 256int trace_parse_common_type(void *data);
16c632de 257int trace_parse_common_pid(void *data);
d1b93772
TZ
258int parse_common_pc(void *data);
259int parse_common_flags(void *data);
260int parse_common_lock_depth(void *data);
ec156764 261struct event *trace_find_event(int id);
16c632de
TZ
262struct event *trace_find_next_event(struct event *event);
263unsigned long long read_size(void *ptr, int size);
46538818
FW
264unsigned long long
265raw_field_value(struct event *event, const char *name, void *data);
266void *raw_field_ptr(struct event *event, const char *name, void *data);
16c632de 267unsigned long long eval_flag(const char *flag);
52050943 268
69aad6f1 269int read_tracing_data(int fd, struct list_head *pattrs);
29208e57
JO
270
271struct tracing_data {
272 /* size is only valid if temp is 'true' */
273 ssize_t size;
274 bool temp;
275 char temp_file[50];
276};
277
278struct tracing_data *tracing_data_get(struct list_head *pattrs,
279 int fd, bool temp);
280void tracing_data_put(struct tracing_data *tdata);
281
52050943 282
cda48461
SR
283/* taken from kernel/trace/trace.h */
284enum trace_flag_type {
285 TRACE_FLAG_IRQS_OFF = 0x01,
286 TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
287 TRACE_FLAG_NEED_RESCHED = 0x04,
288 TRACE_FLAG_HARDIRQ = 0x08,
289 TRACE_FLAG_SOFTIRQ = 0x10,
290};
291
956ffd02
TZ
292struct scripting_ops {
293 const char *name;
586bc5cc 294 int (*start_script) (const char *script, int argc, const char **argv);
956ffd02 295 int (*stop_script) (void);
be6d842a
DA
296 void (*process_event) (union perf_event *event,
297 struct perf_sample *sample,
9e69c210 298 struct perf_evsel *evsel,
743eb868 299 struct machine *machine,
be6d842a 300 struct thread *thread);
956ffd02
TZ
301 int (*generate_script) (const char *outfile);
302};
303
304int script_spec_register(const char *spec, struct scripting_ops *ops);
305
16c632de 306void setup_perl_scripting(void);
7e4b21b8 307void setup_python_scripting(void);
16c632de 308
7397d80d
TZ
309struct scripting_context {
310 void *event_data;
311};
312
313int common_pc(struct scripting_context *context);
314int common_flags(struct scripting_context *context);
315int common_lock_depth(struct scripting_context *context);
316
8b40f521 317#endif /* __PERF_TRACE_EVENTS_H */