John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 1 | #ifndef __PERF_TRACE_EVENTS_H |
| 2 | #define __PERF_TRACE_EVENTS_H |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 3 | |
Frederic Weisbecker | 1ef2ed1 | 2009-08-28 03:09:58 +0200 | [diff] [blame] | 4 | #include "parse-events.h" |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 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, |
Tom Zanussi | 26a5074 | 2009-10-06 01:09:50 -0500 | [diff] [blame] | 29 | FIELD_IS_SIGNED = 4, |
Tom Zanussi | 064739b | 2009-10-06 01:09:52 -0500 | [diff] [blame] | 30 | FIELD_IS_STRING = 8, |
| 31 | FIELD_IS_DYNAMIC = 16, |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | struct 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 | |
| 43 | struct format { |
| 44 | int nr_common; |
| 45 | int nr_fields; |
| 46 | struct format_field *common_fields; |
| 47 | struct format_field *fields; |
| 48 | }; |
| 49 | |
| 50 | struct print_arg_atom { |
| 51 | char *atom; |
| 52 | }; |
| 53 | |
| 54 | struct print_arg_string { |
| 55 | char *string; |
Frederic Weisbecker | 561f732 | 2009-08-31 06:45:21 +0200 | [diff] [blame] | 56 | int offset; |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct print_arg_field { |
| 60 | char *name; |
| 61 | struct format_field *field; |
| 62 | }; |
| 63 | |
| 64 | struct print_flag_sym { |
| 65 | struct print_flag_sym *next; |
| 66 | char *value; |
| 67 | char *str; |
| 68 | }; |
| 69 | |
| 70 | struct print_arg_typecast { |
| 71 | char *type; |
| 72 | struct print_arg *item; |
| 73 | }; |
| 74 | |
| 75 | struct print_arg_flags { |
| 76 | struct print_arg *field; |
| 77 | char *delim; |
| 78 | struct print_flag_sym *flags; |
| 79 | }; |
| 80 | |
| 81 | struct print_arg_symbol { |
| 82 | struct print_arg *field; |
| 83 | struct print_flag_sym *symbols; |
| 84 | }; |
| 85 | |
| 86 | struct print_arg; |
| 87 | |
| 88 | struct print_arg_op { |
| 89 | char *op; |
| 90 | int prio; |
| 91 | struct print_arg *left; |
| 92 | struct print_arg *right; |
| 93 | }; |
| 94 | |
| 95 | struct print_arg_func { |
| 96 | char *name; |
| 97 | struct print_arg *args; |
| 98 | }; |
| 99 | |
| 100 | enum 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 | |
| 111 | struct 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 | |
| 126 | struct print_fmt { |
| 127 | char *format; |
| 128 | struct print_arg *args; |
| 129 | }; |
| 130 | |
| 131 | struct event { |
| 132 | struct event *next; |
| 133 | char *name; |
| 134 | int id; |
| 135 | int flags; |
| 136 | struct format format; |
| 137 | struct print_fmt print_fmt; |
Tom Zanussi | 2774601 | 2009-10-06 01:09:51 -0500 | [diff] [blame] | 138 | char *system; |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | enum { |
Steven Rostedt | 07a4bdd | 2009-10-14 15:43:39 -0400 | [diff] [blame] | 142 | EVENT_FL_ISFTRACE = 0x01, |
| 143 | EVENT_FL_ISPRINT = 0x02, |
| 144 | EVENT_FL_ISBPRINT = 0x04, |
| 145 | EVENT_FL_ISFUNC = 0x08, |
| 146 | EVENT_FL_ISFUNCENT = 0x10, |
| 147 | EVENT_FL_ISFUNCRET = 0x20, |
| 148 | |
| 149 | EVENT_FL_FAILED = 0x80000000 |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 150 | }; |
| 151 | |
| 152 | struct record { |
| 153 | unsigned long long ts; |
| 154 | int size; |
| 155 | void *data; |
| 156 | }; |
| 157 | |
| 158 | struct record *trace_peek_data(int cpu); |
| 159 | struct record *trace_read_data(int cpu); |
| 160 | |
| 161 | void parse_set_info(int nr_cpus, int long_sz); |
| 162 | |
Frederic Weisbecker | 03456a1 | 2009-10-06 23:36:47 +0200 | [diff] [blame] | 163 | void trace_report(int fd); |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 164 | |
| 165 | void *malloc_or_die(unsigned int size); |
| 166 | |
| 167 | void parse_cmdlines(char *file, int size); |
| 168 | void parse_proc_kallsyms(char *file, unsigned int size); |
| 169 | void parse_ftrace_printk(char *file, unsigned int size); |
| 170 | |
| 171 | void print_funcs(void); |
| 172 | void print_printk(void); |
| 173 | |
| 174 | int parse_ftrace_file(char *buf, unsigned long size); |
Tom Zanussi | 2774601 | 2009-10-06 01:09:51 -0500 | [diff] [blame] | 175 | int parse_event_file(char *buf, unsigned long size, char *sys); |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 176 | void print_event(int cpu, void *data, int size, unsigned long long nsecs, |
| 177 | char *comm); |
| 178 | |
| 179 | extern int file_bigendian; |
| 180 | extern int host_bigendian; |
| 181 | |
| 182 | int bigendian(void); |
| 183 | |
| 184 | static inline unsigned short __data2host2(unsigned short data) |
| 185 | { |
| 186 | unsigned short swap; |
| 187 | |
| 188 | if (host_bigendian == file_bigendian) |
| 189 | return data; |
| 190 | |
| 191 | swap = ((data & 0xffULL) << 8) | |
| 192 | ((data & (0xffULL << 8)) >> 8); |
| 193 | |
| 194 | return swap; |
| 195 | } |
| 196 | |
| 197 | static inline unsigned int __data2host4(unsigned int data) |
| 198 | { |
| 199 | unsigned int swap; |
| 200 | |
| 201 | if (host_bigendian == file_bigendian) |
| 202 | return data; |
| 203 | |
| 204 | swap = ((data & 0xffULL) << 24) | |
| 205 | ((data & (0xffULL << 8)) << 8) | |
| 206 | ((data & (0xffULL << 16)) >> 8) | |
| 207 | ((data & (0xffULL << 24)) >> 24); |
| 208 | |
| 209 | return swap; |
| 210 | } |
| 211 | |
| 212 | static inline unsigned long long __data2host8(unsigned long long data) |
| 213 | { |
| 214 | unsigned long long swap; |
| 215 | |
| 216 | if (host_bigendian == file_bigendian) |
| 217 | return data; |
| 218 | |
| 219 | swap = ((data & 0xffULL) << 56) | |
| 220 | ((data & (0xffULL << 8)) << 40) | |
| 221 | ((data & (0xffULL << 16)) << 24) | |
| 222 | ((data & (0xffULL << 24)) << 8) | |
| 223 | ((data & (0xffULL << 32)) >> 8) | |
| 224 | ((data & (0xffULL << 40)) >> 24) | |
| 225 | ((data & (0xffULL << 48)) >> 40) | |
| 226 | ((data & (0xffULL << 56)) >> 56); |
| 227 | |
| 228 | return swap; |
| 229 | } |
| 230 | |
| 231 | #define data2host2(ptr) __data2host2(*(unsigned short *)ptr) |
| 232 | #define data2host4(ptr) __data2host4(*(unsigned int *)ptr) |
| 233 | #define data2host8(ptr) __data2host8(*(unsigned long long *)ptr) |
| 234 | |
| 235 | extern int header_page_ts_offset; |
| 236 | extern int header_page_ts_size; |
| 237 | extern int header_page_size_offset; |
| 238 | extern int header_page_size_size; |
| 239 | extern int header_page_data_offset; |
| 240 | extern int header_page_data_size; |
| 241 | |
Steven Rostedt | cda4846 | 2009-10-14 15:43:42 -0400 | [diff] [blame^] | 242 | extern int latency_format; |
| 243 | |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 244 | int parse_header_page(char *buf, unsigned long size); |
Ingo Molnar | ec15676 | 2009-09-11 12:12:54 +0200 | [diff] [blame] | 245 | int trace_parse_common_type(void *data); |
| 246 | struct event *trace_find_event(int id); |
Frederic Weisbecker | 4653881 | 2009-09-12 02:43:45 +0200 | [diff] [blame] | 247 | unsigned long long |
| 248 | raw_field_value(struct event *event, const char *name, void *data); |
| 249 | void *raw_field_ptr(struct event *event, const char *name, void *data); |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 250 | |
Frederic Weisbecker | 03456a1 | 2009-10-06 23:36:47 +0200 | [diff] [blame] | 251 | void read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events); |
Steven Rostedt | 52050943 | 2009-08-17 16:18:05 +0200 | [diff] [blame] | 252 | |
Steven Rostedt | cda4846 | 2009-10-14 15:43:42 -0400 | [diff] [blame^] | 253 | /* taken from kernel/trace/trace.h */ |
| 254 | enum trace_flag_type { |
| 255 | TRACE_FLAG_IRQS_OFF = 0x01, |
| 256 | TRACE_FLAG_IRQS_NOSUPPORT = 0x02, |
| 257 | TRACE_FLAG_NEED_RESCHED = 0x04, |
| 258 | TRACE_FLAG_HARDIRQ = 0x08, |
| 259 | TRACE_FLAG_SOFTIRQ = 0x10, |
| 260 | }; |
| 261 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 262 | #endif /* __PERF_TRACE_EVENTS_H */ |