perf trace: Add subsystem string to struct event
[safe/jmp/linux-2.6] / tools / perf / util / trace-event.h
1 #ifndef __PERF_TRACE_EVENTS_H
2 #define __PERF_TRACE_EVENTS_H
3
4 #include "parse-events.h"
5
6 #define __unused __attribute__((unused))
7
8
9 #ifndef PAGE_MASK
10 #define PAGE_MASK (page_size - 1)
11 #endif
12
13 enum {
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
26 enum format_flags {
27         FIELD_IS_ARRAY          = 1,
28         FIELD_IS_POINTER        = 2,
29         FIELD_IS_SIGNED         = 4,
30 };
31
32 struct 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
41 struct format {
42         int                     nr_common;
43         int                     nr_fields;
44         struct format_field     *common_fields;
45         struct format_field     *fields;
46 };
47
48 struct print_arg_atom {
49         char                    *atom;
50 };
51
52 struct print_arg_string {
53         char                    *string;
54         int                     offset;
55 };
56
57 struct print_arg_field {
58         char                    *name;
59         struct format_field     *field;
60 };
61
62 struct print_flag_sym {
63         struct print_flag_sym   *next;
64         char                    *value;
65         char                    *str;
66 };
67
68 struct print_arg_typecast {
69         char                    *type;
70         struct print_arg        *item;
71 };
72
73 struct print_arg_flags {
74         struct print_arg        *field;
75         char                    *delim;
76         struct print_flag_sym   *flags;
77 };
78
79 struct print_arg_symbol {
80         struct print_arg        *field;
81         struct print_flag_sym   *symbols;
82 };
83
84 struct print_arg;
85
86 struct print_arg_op {
87         char                    *op;
88         int                     prio;
89         struct print_arg        *left;
90         struct print_arg        *right;
91 };
92
93 struct print_arg_func {
94         char                    *name;
95         struct print_arg        *args;
96 };
97
98 enum 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
109 struct 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
124 struct print_fmt {
125         char                    *format;
126         struct print_arg        *args;
127 };
128
129 struct 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         char                    *system;
137 };
138
139 enum {
140         EVENT_FL_ISFTRACE       = 1,
141         EVENT_FL_ISPRINT        = 2,
142         EVENT_FL_ISBPRINT       = 4,
143         EVENT_FL_ISFUNC         = 8,
144         EVENT_FL_ISFUNCENT      = 16,
145         EVENT_FL_ISFUNCRET      = 32,
146 };
147
148 struct record {
149         unsigned long long ts;
150         int size;
151         void *data;
152 };
153
154 struct record *trace_peek_data(int cpu);
155 struct record *trace_read_data(int cpu);
156
157 void parse_set_info(int nr_cpus, int long_sz);
158
159 void trace_report(void);
160
161 void *malloc_or_die(unsigned int size);
162
163 void parse_cmdlines(char *file, int size);
164 void parse_proc_kallsyms(char *file, unsigned int size);
165 void parse_ftrace_printk(char *file, unsigned int size);
166
167 void print_funcs(void);
168 void print_printk(void);
169
170 int parse_ftrace_file(char *buf, unsigned long size);
171 int parse_event_file(char *buf, unsigned long size, char *sys);
172 void print_event(int cpu, void *data, int size, unsigned long long nsecs,
173                   char *comm);
174
175 extern int file_bigendian;
176 extern int host_bigendian;
177
178 int bigendian(void);
179
180 static inline unsigned short __data2host2(unsigned short data)
181 {
182         unsigned short swap;
183
184         if (host_bigendian == file_bigendian)
185                 return data;
186
187         swap = ((data & 0xffULL) << 8) |
188                 ((data & (0xffULL << 8)) >> 8);
189
190         return swap;
191 }
192
193 static inline unsigned int __data2host4(unsigned int data)
194 {
195         unsigned int swap;
196
197         if (host_bigendian == file_bigendian)
198                 return data;
199
200         swap = ((data & 0xffULL) << 24) |
201                 ((data & (0xffULL << 8)) << 8) |
202                 ((data & (0xffULL << 16)) >> 8) |
203                 ((data & (0xffULL << 24)) >> 24);
204
205         return swap;
206 }
207
208 static inline unsigned long long __data2host8(unsigned long long data)
209 {
210         unsigned long long swap;
211
212         if (host_bigendian == file_bigendian)
213                 return data;
214
215         swap = ((data & 0xffULL) << 56) |
216                 ((data & (0xffULL << 8)) << 40) |
217                 ((data & (0xffULL << 16)) << 24) |
218                 ((data & (0xffULL << 24)) << 8) |
219                 ((data & (0xffULL << 32)) >> 8) |
220                 ((data & (0xffULL << 40)) >> 24) |
221                 ((data & (0xffULL << 48)) >> 40) |
222                 ((data & (0xffULL << 56)) >> 56);
223
224         return swap;
225 }
226
227 #define data2host2(ptr)         __data2host2(*(unsigned short *)ptr)
228 #define data2host4(ptr)         __data2host4(*(unsigned int *)ptr)
229 #define data2host8(ptr)         __data2host8(*(unsigned long long *)ptr)
230
231 extern int header_page_ts_offset;
232 extern int header_page_ts_size;
233 extern int header_page_size_offset;
234 extern int header_page_size_size;
235 extern int header_page_data_offset;
236 extern int header_page_data_size;
237
238 int parse_header_page(char *buf, unsigned long size);
239 int trace_parse_common_type(void *data);
240 struct event *trace_find_event(int id);
241 unsigned long long
242 raw_field_value(struct event *event, const char *name, void *data);
243 void *raw_field_ptr(struct event *event, const char *name, void *data);
244
245 void read_tracing_data(struct perf_event_attr *pattrs, int nb_events);
246
247 #endif /* __PERF_TRACE_EVENTS_H */