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> |
| 5 | |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 6 | #include "../perf.h" |
Arnaldo Carvalho de Melo | 4a58e61 | 2009-12-27 21:37:00 -0200 | [diff] [blame] | 7 | #include "map.h" |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 8 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 9 | /* |
| 10 | * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * |
| 11 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 12 | struct ip_event { |
| 13 | struct perf_event_header header; |
| 14 | u64 ip; |
| 15 | u32 pid, tid; |
| 16 | unsigned char __more_data[]; |
| 17 | }; |
| 18 | |
| 19 | struct mmap_event { |
| 20 | struct perf_event_header header; |
| 21 | u32 pid, tid; |
| 22 | u64 start; |
| 23 | u64 len; |
| 24 | u64 pgoff; |
| 25 | char filename[PATH_MAX]; |
| 26 | }; |
| 27 | |
| 28 | struct comm_event { |
| 29 | struct perf_event_header header; |
| 30 | u32 pid, tid; |
| 31 | char comm[16]; |
| 32 | }; |
| 33 | |
| 34 | struct fork_event { |
| 35 | struct perf_event_header header; |
| 36 | u32 pid, ppid; |
| 37 | u32 tid, ptid; |
Arjan van de Ven | 393b2ad | 2009-09-12 07:52:47 +0200 | [diff] [blame] | 38 | u64 time; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | struct lost_event { |
| 42 | struct perf_event_header header; |
| 43 | u64 id; |
| 44 | u64 lost; |
| 45 | }; |
| 46 | |
Peter Zijlstra | 18408dd | 2009-08-13 11:47:55 +0200 | [diff] [blame] | 47 | /* |
| 48 | * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID |
| 49 | */ |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 50 | struct read_event { |
| 51 | struct perf_event_header header; |
Ingo Molnar | dc02bf7 | 2009-09-16 13:45:00 +0200 | [diff] [blame] | 52 | u32 pid, tid; |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 53 | u64 value; |
| 54 | u64 time_enabled; |
| 55 | u64 time_running; |
| 56 | u64 id; |
| 57 | }; |
| 58 | |
Frederic Weisbecker | a285412 | 2011-05-21 19:33:04 +0200 | [diff] [blame] | 59 | |
| 60 | #define PERF_SAMPLE_MASK \ |
| 61 | (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \ |
| 62 | PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \ |
| 63 | PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \ |
| 64 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) |
| 65 | |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 66 | struct sample_event { |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 67 | struct perf_event_header header; |
| 68 | u64 array[]; |
| 69 | }; |
| 70 | |
Arnaldo Carvalho de Melo | 8d50e5b | 2011-01-29 13:02:00 -0200 | [diff] [blame] | 71 | struct perf_sample { |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 72 | u64 ip; |
| 73 | u32 pid, tid; |
| 74 | u64 time; |
| 75 | u64 addr; |
| 76 | u64 id; |
| 77 | u64 stream_id; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 78 | u64 period; |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 79 | u32 cpu; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 80 | u32 raw_size; |
| 81 | void *raw_data; |
Arnaldo Carvalho de Melo | eed05fe | 2010-04-05 12:53:45 -0300 | [diff] [blame] | 82 | struct ip_callchain *callchain; |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 83 | }; |
| 84 | |
Arnaldo Carvalho de Melo | 8d06367 | 2009-11-04 18:50:43 -0200 | [diff] [blame] | 85 | #define BUILD_ID_SIZE 20 |
| 86 | |
| 87 | struct build_id_event { |
| 88 | struct perf_event_header header; |
Zhang, Yanmin | a1645ce | 2010-04-19 13:32:50 +0800 | [diff] [blame] | 89 | pid_t pid; |
Arnaldo Carvalho de Melo | 8d06367 | 2009-11-04 18:50:43 -0200 | [diff] [blame] | 90 | u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))]; |
| 91 | char filename[]; |
| 92 | }; |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 93 | |
Frederic Weisbecker | 9840280 | 2010-05-02 22:05:29 +0200 | [diff] [blame] | 94 | enum perf_user_event_type { /* above any possible kernel type */ |
Thomas Gleixner | 9aefcab | 2010-12-07 12:48:47 +0000 | [diff] [blame] | 95 | PERF_RECORD_USER_TYPE_START = 64, |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 96 | PERF_RECORD_HEADER_ATTR = 64, |
Tom Zanussi | cd19a03 | 2010-04-01 23:59:20 -0500 | [diff] [blame] | 97 | PERF_RECORD_HEADER_EVENT_TYPE = 65, |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame] | 98 | PERF_RECORD_HEADER_TRACING_DATA = 66, |
Tom Zanussi | c7929e4 | 2010-04-01 23:59:22 -0500 | [diff] [blame] | 99 | PERF_RECORD_HEADER_BUILD_ID = 67, |
Frederic Weisbecker | 9840280 | 2010-05-02 22:05:29 +0200 | [diff] [blame] | 100 | PERF_RECORD_FINISHED_ROUND = 68, |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 101 | PERF_RECORD_HEADER_MAX |
| 102 | }; |
| 103 | |
| 104 | struct attr_event { |
| 105 | struct perf_event_header header; |
| 106 | struct perf_event_attr attr; |
| 107 | u64 id[]; |
Tom Zanussi | 8dc5810 | 2010-04-01 23:59:15 -0500 | [diff] [blame] | 108 | }; |
| 109 | |
Tom Zanussi | cd19a03 | 2010-04-01 23:59:20 -0500 | [diff] [blame] | 110 | #define MAX_EVENT_NAME 64 |
| 111 | |
| 112 | struct perf_trace_event_type { |
| 113 | u64 event_id; |
| 114 | char name[MAX_EVENT_NAME]; |
| 115 | }; |
| 116 | |
| 117 | struct event_type_event { |
| 118 | struct perf_event_header header; |
| 119 | struct perf_trace_event_type event_type; |
| 120 | }; |
| 121 | |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame] | 122 | struct tracing_data_event { |
| 123 | struct perf_event_header header; |
| 124 | u32 size; |
| 125 | }; |
| 126 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 127 | union perf_event { |
Frederic Weisbecker | 1fe2c10 | 2009-08-12 10:19:53 +0200 | [diff] [blame] | 128 | struct perf_event_header header; |
| 129 | struct ip_event ip; |
| 130 | struct mmap_event mmap; |
| 131 | struct comm_event comm; |
| 132 | struct fork_event fork; |
| 133 | struct lost_event lost; |
| 134 | struct read_event read; |
Arjan van de Ven | fd39e05 | 2009-09-12 07:53:00 +0200 | [diff] [blame] | 135 | struct sample_event sample; |
Tom Zanussi | 2c46dbb | 2010-04-01 23:59:19 -0500 | [diff] [blame] | 136 | struct attr_event attr; |
Tom Zanussi | cd19a03 | 2010-04-01 23:59:20 -0500 | [diff] [blame] | 137 | struct event_type_event event_type; |
Tom Zanussi | 9215545 | 2010-04-01 23:59:21 -0500 | [diff] [blame] | 138 | struct tracing_data_event tracing_data; |
Tom Zanussi | c7929e4 | 2010-04-01 23:59:22 -0500 | [diff] [blame] | 139 | struct build_id_event build_id; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 140 | }; |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 141 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 142 | void perf_event__print_totals(void); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 143 | |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 144 | struct perf_event_ops; |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 145 | struct perf_session; |
Arnaldo Carvalho de Melo | 401b8e1 | 2011-02-10 12:52:47 -0200 | [diff] [blame] | 146 | struct thread_map; |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 147 | |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 148 | typedef int (*perf_event__handler_t)(struct perf_event_ops *ops, |
| 149 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 150 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 640c03c | 2010-12-02 14:10:21 -0200 | [diff] [blame] | 151 | struct perf_session *session); |
Arnaldo Carvalho de Melo | cf55311 | 2010-01-07 19:59:40 -0200 | [diff] [blame] | 152 | |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 153 | int perf_event__synthesize_thread_map(struct perf_event_ops *ops, |
| 154 | struct thread_map *threads, |
Arnaldo Carvalho de Melo | 7c940c1 | 2011-02-11 11:45:54 -0200 | [diff] [blame] | 155 | perf_event__handler_t process, |
| 156 | struct perf_session *session); |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 157 | int perf_event__synthesize_threads(struct perf_event_ops *ops, |
| 158 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 159 | struct perf_session *session); |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 160 | int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops, |
| 161 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 162 | struct perf_session *session, |
| 163 | struct machine *machine, |
| 164 | const char *symbol_name); |
| 165 | |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 166 | int perf_event__synthesize_modules(struct perf_event_ops *ops, |
| 167 | perf_event__handler_t process, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 168 | struct perf_session *session, |
| 169 | struct machine *machine); |
| 170 | |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 171 | int perf_event__process_comm(struct perf_event_ops *ops, |
| 172 | union perf_event *event, |
| 173 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | d8f6624 | 2009-12-13 19:50:24 -0200 | [diff] [blame] | 174 | struct perf_session *session); |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 175 | int perf_event__process_lost(struct perf_event_ops *ops, |
| 176 | union perf_event *event, |
| 177 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 178 | struct perf_session *session); |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 179 | int perf_event__process_mmap(struct perf_event_ops *ops, |
| 180 | union perf_event *event, |
| 181 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 182 | struct perf_session *session); |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 183 | int perf_event__process_task(struct perf_event_ops *ops, |
| 184 | union perf_event *event, |
| 185 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 186 | struct perf_session *session); |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame^] | 187 | int perf_event__process(struct perf_event_ops *ops, |
| 188 | union perf_event *event, |
| 189 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 640c03c | 2010-12-02 14:10:21 -0200 | [diff] [blame] | 190 | struct perf_session *session); |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 191 | |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 192 | struct addr_location; |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 193 | int perf_event__preprocess_sample(const union perf_event *self, |
| 194 | struct perf_session *session, |
| 195 | struct addr_location *al, |
| 196 | struct perf_sample *sample, |
| 197 | symbol_filter_t filter); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 198 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 199 | const char *perf_event__name(unsigned int id); |
Arnaldo Carvalho de Melo | c8446b9 | 2010-05-14 10:36:42 -0300 | [diff] [blame] | 200 | |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 201 | int perf_event__parse_sample(const union perf_event *event, u64 type, |
Frederic Weisbecker | a285412 | 2011-05-21 19:33:04 +0200 | [diff] [blame] | 202 | int sample_size, bool sample_id_all, |
David Ahern | 936be50 | 2011-09-06 09:12:26 -0600 | [diff] [blame] | 203 | struct perf_sample *sample, bool swapped); |
Arnaldo Carvalho de Melo | d0dd74e | 2011-01-21 13:46:41 -0200 | [diff] [blame] | 204 | |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 205 | #endif /* __PERF_RECORD_H */ |