1 #ifndef __PERF_TRACE_EVENTS_H
2 #define __PERF_TRACE_EVENTS_H
4 #include "parse-events.h"
6 #define __unused __attribute__((unused))
10 #define PAGE_MASK (page_size - 1)
14 RINGBUF_TYPE_PADDING
= 29,
15 RINGBUF_TYPE_TIME_EXTEND
= 30,
16 RINGBUF_TYPE_TIME_STAMP
= 31,
23 #define NSECS_PER_SEC 1000000000ULL
24 #define NSECS_PER_USEC 1000ULL
31 FIELD_IS_DYNAMIC
= 16,
35 struct format_field
*next
;
46 struct format_field
*common_fields
;
47 struct format_field
*fields
;
50 struct print_arg_atom
{
54 struct print_arg_string
{
59 struct print_arg_field
{
61 struct format_field
*field
;
64 struct print_flag_sym
{
65 struct print_flag_sym
*next
;
70 struct print_arg_typecast
{
72 struct print_arg
*item
;
75 struct print_arg_flags
{
76 struct print_arg
*field
;
78 struct print_flag_sym
*flags
;
81 struct print_arg_symbol
{
82 struct print_arg
*field
;
83 struct print_flag_sym
*symbols
;
91 struct print_arg
*left
;
92 struct print_arg
*right
;
95 struct print_arg_func
{
97 struct print_arg
*args
;
100 enum print_arg_type
{
112 struct print_arg
*next
;
113 enum print_arg_type type
;
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
;
128 struct print_arg
*args
;
136 struct format format
;
137 struct print_fmt print_fmt
;
142 EVENT_FL_ISFTRACE
= 1,
143 EVENT_FL_ISPRINT
= 2,
144 EVENT_FL_ISBPRINT
= 4,
146 EVENT_FL_ISFUNCENT
= 16,
147 EVENT_FL_ISFUNCRET
= 32,
151 unsigned long long ts
;
156 struct record
*trace_peek_data(int cpu
);
157 struct record
*trace_read_data(int cpu
);
159 void parse_set_info(int nr_cpus
, int long_sz
);
161 void trace_report(int fd
);
163 void *malloc_or_die(unsigned int size
);
165 void parse_cmdlines(char *file
, int size
);
166 void parse_proc_kallsyms(char *file
, unsigned int size
);
167 void parse_ftrace_printk(char *file
, unsigned int size
);
169 void print_funcs(void);
170 void print_printk(void);
172 int parse_ftrace_file(char *buf
, unsigned long size
);
173 int parse_event_file(char *buf
, unsigned long size
, char *sys
);
174 void print_event(int cpu
, void *data
, int size
, unsigned long long nsecs
,
177 extern int file_bigendian
;
178 extern int host_bigendian
;
182 static inline unsigned short __data2host2(unsigned short data
)
186 if (host_bigendian
== file_bigendian
)
189 swap
= ((data
& 0xffULL
) << 8) |
190 ((data
& (0xffULL
<< 8)) >> 8);
195 static inline unsigned int __data2host4(unsigned int data
)
199 if (host_bigendian
== file_bigendian
)
202 swap
= ((data
& 0xffULL
) << 24) |
203 ((data
& (0xffULL
<< 8)) << 8) |
204 ((data
& (0xffULL
<< 16)) >> 8) |
205 ((data
& (0xffULL
<< 24)) >> 24);
210 static inline unsigned long long __data2host8(unsigned long long data
)
212 unsigned long long swap
;
214 if (host_bigendian
== file_bigendian
)
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);
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)
233 extern int header_page_ts_offset
;
234 extern int header_page_ts_size
;
235 extern int header_page_size_offset
;
236 extern int header_page_size_size
;
237 extern int header_page_data_offset
;
238 extern int header_page_data_size
;
240 int parse_header_page(char *buf
, unsigned long size
);
241 int trace_parse_common_type(void *data
);
242 struct event
*trace_find_event(int id
);
244 raw_field_value(struct event
*event
, const char *name
, void *data
);
245 void *raw_field_ptr(struct event
*event
, const char *name
, void *data
);
247 void read_tracing_data(int fd
, struct perf_event_attr
*pattrs
, int nb_events
);
249 #endif /* __PERF_TRACE_EVENTS_H */