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