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 | ||
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; | |
393b2ad8 | 30 | u64 time; |
1fe2c106 FW |
31 | }; |
32 | ||
33 | struct lost_event { | |
34 | struct perf_event_header header; | |
35 | u64 id; | |
36 | u64 lost; | |
37 | }; | |
38 | ||
18408ddc PZ |
39 | /* |
40 | * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID | |
41 | */ | |
1fe2c106 FW |
42 | struct read_event { |
43 | struct perf_event_header header; | |
dc02bf71 | 44 | u32 pid, tid; |
1fe2c106 FW |
45 | u64 value; |
46 | u64 time_enabled; | |
47 | u64 time_running; | |
48 | u64 id; | |
49 | }; | |
50 | ||
a2854124 FW |
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 | \ | |
75562573 AH |
56 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \ |
57 | PERF_SAMPLE_IDENTIFIER) | |
a2854124 | 58 | |
180f95e2 | 59 | struct sample_event { |
fd39e055 AV |
60 | struct perf_event_header header; |
61 | u64 array[]; | |
62 | }; | |
63 | ||
0f6a3015 JO |
64 | struct regs_dump { |
65 | u64 *regs; | |
66 | }; | |
67 | ||
68 | struct stack_dump { | |
69 | u16 offset; | |
70 | u64 size; | |
71 | char *data; | |
72 | }; | |
73 | ||
9ede473c JO |
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 | ||
8d50e5b4 | 91 | struct perf_sample { |
180f95e2 OH |
92 | u64 ip; |
93 | u32 pid, tid; | |
94 | u64 time; | |
95 | u64 addr; | |
96 | u64 id; | |
97 | u64 stream_id; | |
180f95e2 | 98 | u64 period; |
05484298 | 99 | u64 weight; |
eed05fe7 | 100 | u32 cpu; |
180f95e2 | 101 | u32 raw_size; |
98a3b32c | 102 | u64 data_src; |
180f95e2 | 103 | void *raw_data; |
eed05fe7 | 104 | struct ip_callchain *callchain; |
b5387528 | 105 | struct branch_stack *branch_stack; |
0f6a3015 JO |
106 | struct regs_dump user_regs; |
107 | struct stack_dump user_stack; | |
9ede473c | 108 | struct sample_read read; |
180f95e2 OH |
109 | }; |
110 | ||
98a3b32c SE |
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 | ||
8d06367f ACM |
118 | struct build_id_event { |
119 | struct perf_event_header header; | |
a1645ce1 | 120 | pid_t pid; |
9ac3e487 | 121 | u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))]; |
8d06367f ACM |
122 | char filename[]; |
123 | }; | |
fd39e055 | 124 | |
98402807 | 125 | enum perf_user_event_type { /* above any possible kernel type */ |
9aefcab0 | 126 | PERF_RECORD_USER_TYPE_START = 64, |
2c46dbb5 | 127 | PERF_RECORD_HEADER_ATTR = 64, |
6065210d | 128 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ |
9215545e | 129 | PERF_RECORD_HEADER_TRACING_DATA = 66, |
c7929e47 | 130 | PERF_RECORD_HEADER_BUILD_ID = 67, |
98402807 | 131 | PERF_RECORD_FINISHED_ROUND = 68, |
2c46dbb5 TZ |
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[]; | |
8dc58101 TZ |
139 | }; |
140 | ||
cd19a035 TZ |
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 | ||
9215545e TZ |
153 | struct tracing_data_event { |
154 | struct perf_event_header header; | |
155 | u32 size; | |
156 | }; | |
157 | ||
8115d60c | 158 | union perf_event { |
1fe2c106 | 159 | struct perf_event_header header; |
1fe2c106 FW |
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; | |
fd39e055 | 165 | struct sample_event sample; |
2c46dbb5 | 166 | struct attr_event attr; |
cd19a035 | 167 | struct event_type_event event_type; |
9215545e | 168 | struct tracing_data_event tracing_data; |
c7929e47 | 169 | struct build_id_event build_id; |
8115d60c | 170 | }; |
66e274f3 | 171 | |
8115d60c | 172 | void perf_event__print_totals(void); |
62daacb5 | 173 | |
45694aa7 | 174 | struct perf_tool; |
401b8e13 | 175 | struct thread_map; |
4aa65636 | 176 | |
45694aa7 | 177 | typedef int (*perf_event__handler_t)(struct perf_tool *tool, |
d20deb64 | 178 | union perf_event *event, |
8115d60c | 179 | struct perf_sample *sample, |
743eb868 | 180 | struct machine *machine); |
cf553114 | 181 | |
45694aa7 | 182 | int perf_event__synthesize_thread_map(struct perf_tool *tool, |
d20deb64 | 183 | struct thread_map *threads, |
7c940c18 | 184 | perf_event__handler_t process, |
743eb868 | 185 | struct machine *machine); |
45694aa7 | 186 | int perf_event__synthesize_threads(struct perf_tool *tool, |
d20deb64 | 187 | perf_event__handler_t process, |
743eb868 | 188 | struct machine *machine); |
45694aa7 | 189 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, |
d20deb64 | 190 | perf_event__handler_t process, |
8115d60c ACM |
191 | struct machine *machine, |
192 | const char *symbol_name); | |
193 | ||
45694aa7 | 194 | int perf_event__synthesize_modules(struct perf_tool *tool, |
d20deb64 | 195 | perf_event__handler_t process, |
8115d60c ACM |
196 | struct machine *machine); |
197 | ||
45694aa7 | 198 | int perf_event__process_comm(struct perf_tool *tool, |
d20deb64 ACM |
199 | union perf_event *event, |
200 | struct perf_sample *sample, | |
743eb868 | 201 | struct machine *machine); |
45694aa7 | 202 | int perf_event__process_lost(struct perf_tool *tool, |
d20deb64 ACM |
203 | union perf_event *event, |
204 | struct perf_sample *sample, | |
743eb868 | 205 | struct machine *machine); |
45694aa7 | 206 | int perf_event__process_mmap(struct perf_tool *tool, |
d20deb64 ACM |
207 | union perf_event *event, |
208 | struct perf_sample *sample, | |
743eb868 | 209 | struct machine *machine); |
f62d3f0f ACM |
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, | |
d20deb64 ACM |
215 | union perf_event *event, |
216 | struct perf_sample *sample, | |
743eb868 | 217 | struct machine *machine); |
45694aa7 | 218 | int perf_event__process(struct perf_tool *tool, |
d20deb64 ACM |
219 | union perf_event *event, |
220 | struct perf_sample *sample, | |
743eb868 | 221 | struct machine *machine); |
62daacb5 | 222 | |
1ed091c4 | 223 | struct addr_location; |
8115d60c | 224 | int perf_event__preprocess_sample(const union perf_event *self, |
743eb868 | 225 | struct machine *machine, |
8115d60c | 226 | struct addr_location *al, |
e44baa3e | 227 | struct perf_sample *sample); |
1ed091c4 | 228 | |
8115d60c | 229 | const char *perf_event__name(unsigned int id); |
c8446b9b | 230 | |
74eec26f AV |
231 | int perf_event__synthesize_sample(union perf_event *event, u64 type, |
232 | const struct perf_sample *sample, | |
233 | bool swapped); | |
d0dd74e8 | 234 | |
482ad897 ACM |
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 | ||
8b40f521 | 240 | #endif /* __PERF_RECORD_H */ |