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