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