Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1 | #ifndef __PERF_RECORD_H |
| 2 | #define __PERF_RECORD_H |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 3 | |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 4 | #include <limits.h> |
Arnaldo Carvalho de Melo | 482ad89 | 2011-12-02 11:06:37 -0200 | [diff] [blame] | 5 | #include <stdio.h> |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 6 | |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 7 | #include "../perf.h" |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 8 | #include "map.h" |
Jiri Olsa | 4383db8 | 2012-10-27 23:18:29 +0200 | [diff] [blame] | 9 | #include "build-id.h" |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 10 | |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 11 | struct mmap_event { |
| 12 | struct perf_event_header header; |
| 13 | u32 pid, tid; |
| 14 | u64 start; |
| 15 | u64 len; |
| 16 | u64 pgoff; |
| 17 | char filename[PATH_MAX]; |
| 18 | }; |
| 19 | |
| 20 | struct comm_event { |
| 21 | struct perf_event_header header; |
| 22 | u32 pid, tid; |
| 23 | char comm[16]; |
| 24 | }; |
| 25 | |
| 26 | struct fork_event { |
| 27 | struct perf_event_header header; |
| 28 | u32 pid, ppid; |
| 29 | u32 tid, ptid; |
Arjan van de Ven | 393b2ad | 2009-09-12 07:52:47 +0200 | [diff] [blame] | 30 | u64 time; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | struct lost_event { |
| 34 | struct perf_event_header header; |
| 35 | u64 id; |
| 36 | u64 lost; |
| 37 | }; |
| 38 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 39 | /* |
| 40 | * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID |
| 41 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 42 | struct read_event { |
| 43 | struct perf_event_header header; |
Ingo Molnar | dc02bf7 | 2009-09-16 13:45:00 +0200 | [diff] [blame] | 44 | u32 pid, tid; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 45 | u64 value; |
| 46 | u64 time_enabled; |
| 47 | u64 time_running; |
| 48 | u64 id; |
| 49 | }; |
| 50 | |
Frederic Weisbecker | a285412 | 2011-05-21 19:33:04 +0200 | [diff] [blame] | 51 | |
| 52 | #define PERF_SAMPLE_MASK \ |
| 53 | (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \ |
| 54 | PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \ |
| 55 | PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \ |
| 56 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) |
| 57 | |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 58 | struct sample_event { |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 59 | struct perf_event_header header; |
| 60 | u64 array[]; |
| 61 | }; |
| 62 | |
Jiri Olsa | 0f6a301 | 2012-08-07 15:20:45 +0200 | [diff] [blame] | 63 | struct regs_dump { |
| 64 | u64 *regs; |
| 65 | }; |
| 66 | |
| 67 | struct stack_dump { |
| 68 | u16 offset; |
| 69 | u64 size; |
| 70 | char *data; |
| 71 | }; |
| 72 | |
Jiri Olsa | 9ede473 | 2012-10-10 17:38:13 +0200 | [diff] [blame] | 73 | struct sample_read_value { |
| 74 | u64 value; |
| 75 | u64 id; |
| 76 | }; |
| 77 | |
| 78 | struct sample_read { |
| 79 | u64 time_enabled; |
| 80 | u64 time_running; |
| 81 | union { |
| 82 | struct { |
| 83 | u64 nr; |
| 84 | struct sample_read_value *values; |
| 85 | } group; |
| 86 | struct sample_read_value one; |
| 87 | }; |
| 88 | }; |
| 89 | |
Arnaldo Carvalho de Melo | 8d50e5b | 2011-01-29 13:02:00 -0200 | [diff] [blame] | 90 | struct perf_sample { |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 91 | u64 ip; |
| 92 | u32 pid, tid; |
| 93 | u64 time; |
| 94 | u64 addr; |
| 95 | u64 id; |
| 96 | u64 stream_id; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 97 | u64 period; |
Andi Kleen | 0548429 | 2013-01-24 16:10:29 +0100 | [diff] [blame] | 98 | u64 weight; |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 99 | u32 cpu; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 100 | u32 raw_size; |
Stephane Eranian | 98a3b32 | 2013-01-24 16:10:35 +0100 | [diff] [blame] | 101 | u64 data_src; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 102 | void *raw_data; |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 103 | struct ip_callchain *callchain; |
Roberto Agostino Vitillo | b538752 | 2012-02-09 23:21:01 +0100 | [diff] [blame] | 104 | struct branch_stack *branch_stack; |
Jiri Olsa | 0f6a301 | 2012-08-07 15:20:45 +0200 | [diff] [blame] | 105 | struct regs_dump user_regs; |
| 106 | struct stack_dump user_stack; |
Jiri Olsa | 9ede473 | 2012-10-10 17:38:13 +0200 | [diff] [blame] | 107 | struct sample_read read; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 108 | }; |
| 109 | |
Stephane Eranian | 98a3b32 | 2013-01-24 16:10:35 +0100 | [diff] [blame] | 110 | #define PERF_MEM_DATA_SRC_NONE \ |
| 111 | (PERF_MEM_S(OP, NA) |\ |
| 112 | PERF_MEM_S(LVL, NA) |\ |
| 113 | PERF_MEM_S(SNOOP, NA) |\ |
| 114 | PERF_MEM_S(LOCK, NA) |\ |
| 115 | PERF_MEM_S(TLB, NA)) |
| 116 | |
Arnaldo Carvalho de Melo | 8d06367 | 2009-11-04 18:50:43 -0200 | [diff] [blame] | 117 | struct build_id_event { |
| 118 | struct perf_event_header header; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 119 | pid_t pid; |
Irina Tirdea | 9ac3e48 | 2012-09-11 01:15:01 +0300 | [diff] [blame] | 120 | u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))]; |
Arnaldo Carvalho de Melo | 8d06367 | 2009-11-04 18:50:43 -0200 | [diff] [blame] | 121 | char filename[]; |
| 122 | }; |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 123 | |
Frederic Weisbecker | 9840280 | 2010-05-02 22:05:29 +0200 | [diff] [blame] | 124 | enum perf_user_event_type { /* above any possible kernel type */ |
Thomas Gleixner | 9aefcab | 2010-12-07 12:48:47 +0000 | [diff] [blame] | 125 | PERF_RECORD_USER_TYPE_START = 64, |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 126 | PERF_RECORD_HEADER_ATTR = 64, |
Jiri Olsa | 6065210 | 2013-07-11 17:28:33 +0200 | [diff] [blame] | 127 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame] | 128 | PERF_RECORD_HEADER_TRACING_DATA = 66, |
Tom Zanussi | c7929e4 | 2010-04-01 23:59:22 -0500 | [diff] [blame] | 129 | PERF_RECORD_HEADER_BUILD_ID = 67, |
Frederic Weisbecker | 9840280 | 2010-05-02 22:05:29 +0200 | [diff] [blame] | 130 | PERF_RECORD_FINISHED_ROUND = 68, |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 131 | PERF_RECORD_HEADER_MAX |
| 132 | }; |
| 133 | |
| 134 | struct attr_event { |
| 135 | struct perf_event_header header; |
| 136 | struct perf_event_attr attr; |
| 137 | u64 id[]; |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 138 | }; |
| 139 | |
Tom Zanussi | cd19a03 | 2010-04-01 23:59:20 -0500 | [diff] [blame] | 140 | #define MAX_EVENT_NAME 64 |
| 141 | |
| 142 | struct perf_trace_event_type { |
| 143 | u64 event_id; |
| 144 | char name[MAX_EVENT_NAME]; |
| 145 | }; |
| 146 | |
| 147 | struct event_type_event { |
| 148 | struct perf_event_header header; |
| 149 | struct perf_trace_event_type event_type; |
| 150 | }; |
| 151 | |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame] | 152 | struct tracing_data_event { |
| 153 | struct perf_event_header header; |
| 154 | u32 size; |
| 155 | }; |
| 156 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 157 | union perf_event { |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 158 | struct perf_event_header header; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 159 | struct mmap_event mmap; |
| 160 | struct comm_event comm; |
| 161 | struct fork_event fork; |
| 162 | struct lost_event lost; |
| 163 | struct read_event read; |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 164 | struct sample_event sample; |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 165 | struct attr_event attr; |
Tom Zanussi | cd19a03 | 2010-04-01 23:59:20 -0500 | [diff] [blame] | 166 | struct event_type_event event_type; |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame] | 167 | struct tracing_data_event tracing_data; |
Tom Zanussi | c7929e4 | 2010-04-01 23:59:22 -0500 | [diff] [blame] | 168 | struct build_id_event build_id; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 169 | }; |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 170 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 171 | void perf_event__print_totals(void); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 172 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 173 | struct perf_tool; |
Arnaldo Carvalho de Melo | 401b8e1 | 2011-02-10 12:52:47 -0200 | [diff] [blame] | 174 | struct thread_map; |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 175 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 176 | typedef int (*perf_event__handler_t)(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 177 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 178 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 179 | struct machine *machine); |
Arnaldo Carvalho de Melo | cf55311 | 2010-01-07 19:59:40 -0200 | [diff] [blame] | 180 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 181 | int perf_event__synthesize_thread_map(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 182 | struct thread_map *threads, |
Arnaldo Carvalho de Melo | 7c940c1 | 2011-02-11 11:45:54 -0200 | [diff] [blame] | 183 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 184 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 185 | int perf_event__synthesize_threads(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 186 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 187 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 188 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 189 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 190 | struct machine *machine, |
| 191 | const char *symbol_name); |
| 192 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 193 | int perf_event__synthesize_modules(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 194 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 195 | struct machine *machine); |
| 196 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 197 | int perf_event__process_comm(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 198 | union perf_event *event, |
| 199 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 200 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 201 | int perf_event__process_lost(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 202 | union perf_event *event, |
| 203 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 204 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 205 | int perf_event__process_mmap(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 206 | union perf_event *event, |
| 207 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 208 | struct machine *machine); |
Arnaldo Carvalho de Melo | f62d3f0 | 2012-10-06 15:44:59 -0300 | [diff] [blame] | 209 | int perf_event__process_fork(struct perf_tool *tool, |
| 210 | union perf_event *event, |
| 211 | struct perf_sample *sample, |
| 212 | struct machine *machine); |
| 213 | int perf_event__process_exit(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 214 | union perf_event *event, |
| 215 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 216 | struct machine *machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 217 | int perf_event__process(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 218 | union perf_event *event, |
| 219 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 220 | struct machine *machine); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 221 | |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 222 | struct addr_location; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 223 | int perf_event__preprocess_sample(const union perf_event *self, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 224 | struct machine *machine, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 225 | struct addr_location *al, |
Adrian Hunter | e44baa3 | 2013-08-08 14:32:25 +0300 | [diff] [blame] | 226 | struct perf_sample *sample); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 227 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 228 | const char *perf_event__name(unsigned int id); |
Arnaldo Carvalho de Melo | c8446b9 | 2010-05-14 10:36:42 -0300 | [diff] [blame] | 229 | |
Andrew Vagin | 74eec26 | 2011-11-28 12:03:31 +0300 | [diff] [blame] | 230 | int perf_event__synthesize_sample(union perf_event *event, u64 type, |
| 231 | const struct perf_sample *sample, |
| 232 | bool swapped); |
Arnaldo Carvalho de Melo | d0dd74e | 2011-01-21 13:46:41 -0200 | [diff] [blame] | 233 | |
Arnaldo Carvalho de Melo | 482ad89 | 2011-12-02 11:06:37 -0200 | [diff] [blame] | 234 | size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp); |
| 235 | size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp); |
| 236 | size_t perf_event__fprintf_task(union perf_event *event, FILE *fp); |
| 237 | size_t perf_event__fprintf(union perf_event *event, FILE *fp); |
| 238 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 239 | #endif /* __PERF_RECORD_H */ |