perf tools: Merge trace.info content into perf.data
[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
1ef2ed10 4#include "parse-events.h"
52050943
SR
5
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,
26a50744 29 FIELD_IS_SIGNED = 4,
064739bc
TZ
30 FIELD_IS_STRING = 8,
31 FIELD_IS_DYNAMIC = 16,
52050943
SR
32};
33
34struct format_field {
35 struct format_field *next;
36 char *type;
37 char *name;
38 int offset;
39 int size;
40 unsigned long flags;
41};
42
43struct format {
44 int nr_common;
45 int nr_fields;
46 struct format_field *common_fields;
47 struct format_field *fields;
48};
49
50struct print_arg_atom {
51 char *atom;
52};
53
54struct print_arg_string {
55 char *string;
561f732c 56 int offset;
52050943
SR
57};
58
59struct print_arg_field {
60 char *name;
61 struct format_field *field;
62};
63
64struct print_flag_sym {
65 struct print_flag_sym *next;
66 char *value;
67 char *str;
68};
69
70struct print_arg_typecast {
71 char *type;
72 struct print_arg *item;
73};
74
75struct print_arg_flags {
76 struct print_arg *field;
77 char *delim;
78 struct print_flag_sym *flags;
79};
80
81struct print_arg_symbol {
82 struct print_arg *field;
83 struct print_flag_sym *symbols;
84};
85
86struct print_arg;
87
88struct print_arg_op {
89 char *op;
90 int prio;
91 struct print_arg *left;
92 struct print_arg *right;
93};
94
95struct print_arg_func {
96 char *name;
97 struct print_arg *args;
98};
99
100enum print_arg_type {
101 PRINT_NULL,
102 PRINT_ATOM,
103 PRINT_FIELD,
104 PRINT_FLAGS,
105 PRINT_SYMBOL,
106 PRINT_TYPE,
107 PRINT_STRING,
108 PRINT_OP,
109};
110
111struct print_arg {
112 struct print_arg *next;
113 enum print_arg_type type;
114 union {
115 struct print_arg_atom atom;
116 struct print_arg_field field;
117 struct print_arg_typecast typecast;
118 struct print_arg_flags flags;
119 struct print_arg_symbol symbol;
120 struct print_arg_func func;
121 struct print_arg_string string;
122 struct print_arg_op op;
123 };
124};
125
126struct print_fmt {
127 char *format;
128 struct print_arg *args;
129};
130
131struct event {
132 struct event *next;
133 char *name;
134 int id;
135 int flags;
136 struct format format;
137 struct print_fmt print_fmt;
27746018 138 char *system;
52050943
SR
139};
140
141enum {
142 EVENT_FL_ISFTRACE = 1,
143 EVENT_FL_ISPRINT = 2,
144 EVENT_FL_ISBPRINT = 4,
145 EVENT_FL_ISFUNC = 8,
146 EVENT_FL_ISFUNCENT = 16,
147 EVENT_FL_ISFUNCRET = 32,
148};
149
150struct record {
151 unsigned long long ts;
152 int size;
153 void *data;
154};
155
156struct record *trace_peek_data(int cpu);
157struct record *trace_read_data(int cpu);
158
159void parse_set_info(int nr_cpus, int long_sz);
160
03456a15 161void trace_report(int fd);
52050943
SR
162
163void *malloc_or_die(unsigned int size);
164
165void parse_cmdlines(char *file, int size);
166void parse_proc_kallsyms(char *file, unsigned int size);
167void parse_ftrace_printk(char *file, unsigned int size);
168
169void print_funcs(void);
170void print_printk(void);
171
172int parse_ftrace_file(char *buf, unsigned long size);
27746018 173int parse_event_file(char *buf, unsigned long size, char *sys);
52050943
SR
174void print_event(int cpu, void *data, int size, unsigned long long nsecs,
175 char *comm);
176
177extern int file_bigendian;
178extern int host_bigendian;
179
180int bigendian(void);
181
182static inline unsigned short __data2host2(unsigned short data)
183{
184 unsigned short swap;
185
186 if (host_bigendian == file_bigendian)
187 return data;
188
189 swap = ((data & 0xffULL) << 8) |
190 ((data & (0xffULL << 8)) >> 8);
191
192 return swap;
193}
194
195static inline unsigned int __data2host4(unsigned int data)
196{
197 unsigned int swap;
198
199 if (host_bigendian == file_bigendian)
200 return data;
201
202 swap = ((data & 0xffULL) << 24) |
203 ((data & (0xffULL << 8)) << 8) |
204 ((data & (0xffULL << 16)) >> 8) |
205 ((data & (0xffULL << 24)) >> 24);
206
207 return swap;
208}
209
210static inline unsigned long long __data2host8(unsigned long long data)
211{
212 unsigned long long swap;
213
214 if (host_bigendian == file_bigendian)
215 return data;
216
217 swap = ((data & 0xffULL) << 56) |
218 ((data & (0xffULL << 8)) << 40) |
219 ((data & (0xffULL << 16)) << 24) |
220 ((data & (0xffULL << 24)) << 8) |
221 ((data & (0xffULL << 32)) >> 8) |
222 ((data & (0xffULL << 40)) >> 24) |
223 ((data & (0xffULL << 48)) >> 40) |
224 ((data & (0xffULL << 56)) >> 56);
225
226 return swap;
227}
228
229#define data2host2(ptr) __data2host2(*(unsigned short *)ptr)
230#define data2host4(ptr) __data2host4(*(unsigned int *)ptr)
231#define data2host8(ptr) __data2host8(*(unsigned long long *)ptr)
232
233extern int header_page_ts_offset;
234extern int header_page_ts_size;
235extern int header_page_size_offset;
236extern int header_page_size_size;
237extern int header_page_data_offset;
238extern int header_page_data_size;
239
240int parse_header_page(char *buf, unsigned long size);
ec156764
IM
241int trace_parse_common_type(void *data);
242struct event *trace_find_event(int id);
46538818
FW
243unsigned long long
244raw_field_value(struct event *event, const char *name, void *data);
245void *raw_field_ptr(struct event *event, const char *name, void *data);
52050943 246
03456a15 247void read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events);
52050943 248
8b40f521 249#endif /* __PERF_TRACE_EVENTS_H */