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