]>
Commit | Line | Data |
---|---|---|
cdd6c482 IM |
1 | #ifndef __PERF_RECORD_H |
2 | #define __PERF_RECORD_H | |
8b40f521 | 3 | |
4a58e611 | 4 | #include <limits.h> |
482ad897 | 5 | #include <stdio.h> |
4a58e611 | 6 | |
1fe2c106 | 7 | #include "../perf.h" |
4a58e611 | 8 | #include "map.h" |
4383db88 | 9 | #include "build-id.h" |
1fe2c106 | 10 | |
1fe2c106 FW |
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 | ||
5c5e854b SE |
20 | struct mmap2_event { |
21 | struct perf_event_header header; | |
22 | u32 pid, tid; | |
23 | u64 start; | |
24 | u64 len; | |
25 | u64 pgoff; | |
26 | u32 maj; | |
27 | u32 min; | |
28 | u64 ino; | |
29 | u64 ino_generation; | |
7ef80703 DZ |
30 | u32 prot; |
31 | u32 flags; | |
5c5e854b SE |
32 | char filename[PATH_MAX]; |
33 | }; | |
34 | ||
1fe2c106 FW |
35 | struct comm_event { |
36 | struct perf_event_header header; | |
37 | u32 pid, tid; | |
38 | char comm[16]; | |
39 | }; | |
40 | ||
41 | struct fork_event { | |
42 | struct perf_event_header header; | |
43 | u32 pid, ppid; | |
44 | u32 tid, ptid; | |
393b2ad8 | 45 | u64 time; |
1fe2c106 FW |
46 | }; |
47 | ||
48 | struct lost_event { | |
49 | struct perf_event_header header; | |
50 | u64 id; | |
51 | u64 lost; | |
52 | }; | |
53 | ||
18408ddc PZ |
54 | /* |
55 | * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID | |
56 | */ | |
1fe2c106 FW |
57 | struct read_event { |
58 | struct perf_event_header header; | |
dc02bf71 | 59 | u32 pid, tid; |
1fe2c106 FW |
60 | u64 value; |
61 | u64 time_enabled; | |
62 | u64 time_running; | |
63 | u64 id; | |
64 | }; | |
65 | ||
dd96c46b JO |
66 | struct throttle_event { |
67 | struct perf_event_header header; | |
68 | u64 time; | |
69 | u64 id; | |
70 | u64 stream_id; | |
71 | }; | |
a2854124 FW |
72 | |
73 | #define PERF_SAMPLE_MASK \ | |
74 | (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \ | |
75 | PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \ | |
76 | PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \ | |
75562573 AH |
77 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \ |
78 | PERF_SAMPLE_IDENTIFIER) | |
a2854124 | 79 | |
a65cb4b9 JO |
80 | /* perf sample has 16 bits size limit */ |
81 | #define PERF_SAMPLE_MAX_SIZE (1 << 16) | |
82 | ||
180f95e2 | 83 | struct sample_event { |
fd39e055 AV |
84 | struct perf_event_header header; |
85 | u64 array[]; | |
86 | }; | |
87 | ||
0f6a3015 | 88 | struct regs_dump { |
5b95a4a3 | 89 | u64 abi; |
352ea45a | 90 | u64 mask; |
0f6a3015 JO |
91 | u64 *regs; |
92 | }; | |
93 | ||
94 | struct stack_dump { | |
95 | u16 offset; | |
96 | u64 size; | |
97 | char *data; | |
98 | }; | |
99 | ||
9ede473c JO |
100 | struct sample_read_value { |
101 | u64 value; | |
102 | u64 id; | |
103 | }; | |
104 | ||
105 | struct sample_read { | |
106 | u64 time_enabled; | |
107 | u64 time_running; | |
108 | union { | |
109 | struct { | |
110 | u64 nr; | |
111 | struct sample_read_value *values; | |
112 | } group; | |
113 | struct sample_read_value one; | |
114 | }; | |
115 | }; | |
116 | ||
0776eb59 JO |
117 | struct ip_callchain { |
118 | u64 nr; | |
119 | u64 ips[0]; | |
120 | }; | |
121 | ||
122 | struct branch_flags { | |
123 | u64 mispred:1; | |
124 | u64 predicted:1; | |
125 | u64 in_tx:1; | |
126 | u64 abort:1; | |
127 | u64 reserved:60; | |
128 | }; | |
129 | ||
130 | struct branch_entry { | |
131 | u64 from; | |
132 | u64 to; | |
133 | struct branch_flags flags; | |
134 | }; | |
135 | ||
136 | struct branch_stack { | |
137 | u64 nr; | |
138 | struct branch_entry entries[0]; | |
139 | }; | |
140 | ||
8d50e5b4 | 141 | struct perf_sample { |
180f95e2 OH |
142 | u64 ip; |
143 | u32 pid, tid; | |
144 | u64 time; | |
145 | u64 addr; | |
146 | u64 id; | |
147 | u64 stream_id; | |
180f95e2 | 148 | u64 period; |
05484298 | 149 | u64 weight; |
475eeab9 | 150 | u64 transaction; |
eed05fe7 | 151 | u32 cpu; |
180f95e2 | 152 | u32 raw_size; |
98a3b32c | 153 | u64 data_src; |
180f95e2 | 154 | void *raw_data; |
eed05fe7 | 155 | struct ip_callchain *callchain; |
b5387528 | 156 | struct branch_stack *branch_stack; |
0f6a3015 JO |
157 | struct regs_dump user_regs; |
158 | struct stack_dump user_stack; | |
9ede473c | 159 | struct sample_read read; |
180f95e2 OH |
160 | }; |
161 | ||
98a3b32c SE |
162 | #define PERF_MEM_DATA_SRC_NONE \ |
163 | (PERF_MEM_S(OP, NA) |\ | |
164 | PERF_MEM_S(LVL, NA) |\ | |
165 | PERF_MEM_S(SNOOP, NA) |\ | |
166 | PERF_MEM_S(LOCK, NA) |\ | |
167 | PERF_MEM_S(TLB, NA)) | |
168 | ||
8d06367f ACM |
169 | struct build_id_event { |
170 | struct perf_event_header header; | |
a1645ce1 | 171 | pid_t pid; |
9ac3e487 | 172 | u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))]; |
8d06367f ACM |
173 | char filename[]; |
174 | }; | |
fd39e055 | 175 | |
98402807 | 176 | enum perf_user_event_type { /* above any possible kernel type */ |
9aefcab0 | 177 | PERF_RECORD_USER_TYPE_START = 64, |
2c46dbb5 | 178 | PERF_RECORD_HEADER_ATTR = 64, |
6065210d | 179 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ |
9215545e | 180 | PERF_RECORD_HEADER_TRACING_DATA = 66, |
c7929e47 | 181 | PERF_RECORD_HEADER_BUILD_ID = 67, |
98402807 | 182 | PERF_RECORD_FINISHED_ROUND = 68, |
2c46dbb5 TZ |
183 | PERF_RECORD_HEADER_MAX |
184 | }; | |
185 | ||
186 | struct attr_event { | |
187 | struct perf_event_header header; | |
188 | struct perf_event_attr attr; | |
189 | u64 id[]; | |
8dc58101 TZ |
190 | }; |
191 | ||
cd19a035 TZ |
192 | #define MAX_EVENT_NAME 64 |
193 | ||
194 | struct perf_trace_event_type { | |
195 | u64 event_id; | |
196 | char name[MAX_EVENT_NAME]; | |
197 | }; | |
198 | ||
199 | struct event_type_event { | |
200 | struct perf_event_header header; | |
201 | struct perf_trace_event_type event_type; | |
202 | }; | |
203 | ||
9215545e TZ |
204 | struct tracing_data_event { |
205 | struct perf_event_header header; | |
206 | u32 size; | |
207 | }; | |
208 | ||
8115d60c | 209 | union perf_event { |
1fe2c106 | 210 | struct perf_event_header header; |
1fe2c106 | 211 | struct mmap_event mmap; |
5c5e854b | 212 | struct mmap2_event mmap2; |
1fe2c106 FW |
213 | struct comm_event comm; |
214 | struct fork_event fork; | |
215 | struct lost_event lost; | |
216 | struct read_event read; | |
dd96c46b | 217 | struct throttle_event throttle; |
fd39e055 | 218 | struct sample_event sample; |
2c46dbb5 | 219 | struct attr_event attr; |
cd19a035 | 220 | struct event_type_event event_type; |
9215545e | 221 | struct tracing_data_event tracing_data; |
c7929e47 | 222 | struct build_id_event build_id; |
8115d60c | 223 | }; |
66e274f3 | 224 | |
8115d60c | 225 | void perf_event__print_totals(void); |
62daacb5 | 226 | |
45694aa7 | 227 | struct perf_tool; |
401b8e13 | 228 | struct thread_map; |
4aa65636 | 229 | |
45694aa7 | 230 | typedef int (*perf_event__handler_t)(struct perf_tool *tool, |
d20deb64 | 231 | union perf_event *event, |
8115d60c | 232 | struct perf_sample *sample, |
743eb868 | 233 | struct machine *machine); |
cf553114 | 234 | |
45694aa7 | 235 | int perf_event__synthesize_thread_map(struct perf_tool *tool, |
d20deb64 | 236 | struct thread_map *threads, |
7c940c18 | 237 | perf_event__handler_t process, |
62605dc5 | 238 | struct machine *machine, bool mmap_data); |
45694aa7 | 239 | int perf_event__synthesize_threads(struct perf_tool *tool, |
d20deb64 | 240 | perf_event__handler_t process, |
62605dc5 | 241 | struct machine *machine, bool mmap_data); |
45694aa7 | 242 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, |
d20deb64 | 243 | perf_event__handler_t process, |
0ae617be | 244 | struct machine *machine); |
8115d60c | 245 | |
45694aa7 | 246 | int perf_event__synthesize_modules(struct perf_tool *tool, |
d20deb64 | 247 | perf_event__handler_t process, |
8115d60c ACM |
248 | struct machine *machine); |
249 | ||
45694aa7 | 250 | int perf_event__process_comm(struct perf_tool *tool, |
d20deb64 ACM |
251 | union perf_event *event, |
252 | struct perf_sample *sample, | |
743eb868 | 253 | struct machine *machine); |
45694aa7 | 254 | int perf_event__process_lost(struct perf_tool *tool, |
d20deb64 ACM |
255 | union perf_event *event, |
256 | struct perf_sample *sample, | |
743eb868 | 257 | struct machine *machine); |
45694aa7 | 258 | int perf_event__process_mmap(struct perf_tool *tool, |
d20deb64 ACM |
259 | union perf_event *event, |
260 | struct perf_sample *sample, | |
743eb868 | 261 | struct machine *machine); |
5c5e854b SE |
262 | int perf_event__process_mmap2(struct perf_tool *tool, |
263 | union perf_event *event, | |
264 | struct perf_sample *sample, | |
265 | struct machine *machine); | |
f62d3f0f ACM |
266 | int perf_event__process_fork(struct perf_tool *tool, |
267 | union perf_event *event, | |
268 | struct perf_sample *sample, | |
269 | struct machine *machine); | |
270 | int perf_event__process_exit(struct perf_tool *tool, | |
d20deb64 ACM |
271 | union perf_event *event, |
272 | struct perf_sample *sample, | |
743eb868 | 273 | struct machine *machine); |
45694aa7 | 274 | int perf_event__process(struct perf_tool *tool, |
d20deb64 ACM |
275 | union perf_event *event, |
276 | struct perf_sample *sample, | |
743eb868 | 277 | struct machine *machine); |
62daacb5 | 278 | |
1ed091c4 | 279 | struct addr_location; |
316c7136 ACM |
280 | |
281 | int perf_event__preprocess_sample(const union perf_event *event, | |
743eb868 | 282 | struct machine *machine, |
8115d60c | 283 | struct addr_location *al, |
e44baa3e | 284 | struct perf_sample *sample); |
1ed091c4 | 285 | |
8115d60c | 286 | const char *perf_event__name(unsigned int id); |
c8446b9b | 287 | |
b1cf6f65 | 288 | size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, |
352ea45a | 289 | u64 read_format); |
74eec26f | 290 | int perf_event__synthesize_sample(union perf_event *event, u64 type, |
352ea45a | 291 | u64 read_format, |
74eec26f AV |
292 | const struct perf_sample *sample, |
293 | bool swapped); | |
d0dd74e8 | 294 | |
a18382b6 JO |
295 | int perf_event__synthesize_mmap_events(struct perf_tool *tool, |
296 | union perf_event *event, | |
297 | pid_t pid, pid_t tgid, | |
298 | perf_event__handler_t process, | |
299 | struct machine *machine, | |
300 | bool mmap_data); | |
301 | ||
482ad897 ACM |
302 | size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp); |
303 | size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp); | |
5c5e854b | 304 | size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp); |
482ad897 ACM |
305 | size_t perf_event__fprintf_task(union perf_event *event, FILE *fp); |
306 | size_t perf_event__fprintf(union perf_event *event, FILE *fp); | |
307 | ||
29b596b5 AH |
308 | u64 kallsyms__get_function_start(const char *kallsyms_filename, |
309 | const char *symbol_name); | |
310 | ||
8b40f521 | 311 | #endif /* __PERF_RECORD_H */ |