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 | \ | |
56 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) | |
57 | ||
180f95e2 | 58 | struct sample_event { |
fd39e055 AV |
59 | struct perf_event_header header; |
60 | u64 array[]; | |
61 | }; | |
62 | ||
0f6a3015 JO |
63 | struct regs_dump { |
64 | u64 *regs; | |
65 | }; | |
66 | ||
67 | struct stack_dump { | |
68 | u16 offset; | |
69 | u64 size; | |
70 | char *data; | |
71 | }; | |
72 | ||
9ede473c JO |
73 | struct sample_read_value { |
74 | u64 value; | |
75 | u64 id; | |
76 | }; | |
77 | ||
78 | struct sample_read { | |
79 | u64 time_enabled; | |
80 | u64 time_running; | |
81 | union { | |
82 | struct { | |
83 | u64 nr; | |
84 | struct sample_read_value *values; | |
85 | } group; | |
86 | struct sample_read_value one; | |
87 | }; | |
88 | }; | |
89 | ||
8d50e5b4 | 90 | struct perf_sample { |
180f95e2 OH |
91 | u64 ip; |
92 | u32 pid, tid; | |
93 | u64 time; | |
94 | u64 addr; | |
95 | u64 id; | |
96 | u64 stream_id; | |
180f95e2 | 97 | u64 period; |
05484298 | 98 | u64 weight; |
eed05fe7 | 99 | u32 cpu; |
180f95e2 | 100 | u32 raw_size; |
98a3b32c | 101 | u64 data_src; |
180f95e2 | 102 | void *raw_data; |
eed05fe7 | 103 | struct ip_callchain *callchain; |
b5387528 | 104 | struct branch_stack *branch_stack; |
0f6a3015 JO |
105 | struct regs_dump user_regs; |
106 | struct stack_dump user_stack; | |
9ede473c | 107 | struct sample_read read; |
180f95e2 OH |
108 | }; |
109 | ||
98a3b32c SE |
110 | #define PERF_MEM_DATA_SRC_NONE \ |
111 | (PERF_MEM_S(OP, NA) |\ | |
112 | PERF_MEM_S(LVL, NA) |\ | |
113 | PERF_MEM_S(SNOOP, NA) |\ | |
114 | PERF_MEM_S(LOCK, NA) |\ | |
115 | PERF_MEM_S(TLB, NA)) | |
116 | ||
8d06367f ACM |
117 | struct build_id_event { |
118 | struct perf_event_header header; | |
a1645ce1 | 119 | pid_t pid; |
9ac3e487 | 120 | u8 build_id[PERF_ALIGN(BUILD_ID_SIZE, sizeof(u64))]; |
8d06367f ACM |
121 | char filename[]; |
122 | }; | |
fd39e055 | 123 | |
98402807 | 124 | enum perf_user_event_type { /* above any possible kernel type */ |
9aefcab0 | 125 | PERF_RECORD_USER_TYPE_START = 64, |
2c46dbb5 | 126 | PERF_RECORD_HEADER_ATTR = 64, |
6065210d | 127 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ |
9215545e | 128 | PERF_RECORD_HEADER_TRACING_DATA = 66, |
c7929e47 | 129 | PERF_RECORD_HEADER_BUILD_ID = 67, |
98402807 | 130 | PERF_RECORD_FINISHED_ROUND = 68, |
2c46dbb5 TZ |
131 | PERF_RECORD_HEADER_MAX |
132 | }; | |
133 | ||
134 | struct attr_event { | |
135 | struct perf_event_header header; | |
136 | struct perf_event_attr attr; | |
137 | u64 id[]; | |
8dc58101 TZ |
138 | }; |
139 | ||
cd19a035 TZ |
140 | #define MAX_EVENT_NAME 64 |
141 | ||
142 | struct perf_trace_event_type { | |
143 | u64 event_id; | |
144 | char name[MAX_EVENT_NAME]; | |
145 | }; | |
146 | ||
147 | struct event_type_event { | |
148 | struct perf_event_header header; | |
149 | struct perf_trace_event_type event_type; | |
150 | }; | |
151 | ||
9215545e TZ |
152 | struct tracing_data_event { |
153 | struct perf_event_header header; | |
154 | u32 size; | |
155 | }; | |
156 | ||
8115d60c | 157 | union perf_event { |
1fe2c106 | 158 | struct perf_event_header header; |
1fe2c106 FW |
159 | struct mmap_event mmap; |
160 | struct comm_event comm; | |
161 | struct fork_event fork; | |
162 | struct lost_event lost; | |
163 | struct read_event read; | |
fd39e055 | 164 | struct sample_event sample; |
2c46dbb5 | 165 | struct attr_event attr; |
cd19a035 | 166 | struct event_type_event event_type; |
9215545e | 167 | struct tracing_data_event tracing_data; |
c7929e47 | 168 | struct build_id_event build_id; |
8115d60c | 169 | }; |
66e274f3 | 170 | |
8115d60c | 171 | void perf_event__print_totals(void); |
62daacb5 | 172 | |
45694aa7 | 173 | struct perf_tool; |
401b8e13 | 174 | struct thread_map; |
4aa65636 | 175 | |
45694aa7 | 176 | typedef int (*perf_event__handler_t)(struct perf_tool *tool, |
d20deb64 | 177 | union perf_event *event, |
8115d60c | 178 | struct perf_sample *sample, |
743eb868 | 179 | struct machine *machine); |
cf553114 | 180 | |
45694aa7 | 181 | int perf_event__synthesize_thread_map(struct perf_tool *tool, |
d20deb64 | 182 | struct thread_map *threads, |
7c940c18 | 183 | perf_event__handler_t process, |
743eb868 | 184 | struct machine *machine); |
45694aa7 | 185 | int perf_event__synthesize_threads(struct perf_tool *tool, |
d20deb64 | 186 | perf_event__handler_t process, |
743eb868 | 187 | struct machine *machine); |
45694aa7 | 188 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, |
d20deb64 | 189 | perf_event__handler_t process, |
8115d60c ACM |
190 | struct machine *machine, |
191 | const char *symbol_name); | |
192 | ||
45694aa7 | 193 | int perf_event__synthesize_modules(struct perf_tool *tool, |
d20deb64 | 194 | perf_event__handler_t process, |
8115d60c ACM |
195 | struct machine *machine); |
196 | ||
45694aa7 | 197 | int perf_event__process_comm(struct perf_tool *tool, |
d20deb64 ACM |
198 | union perf_event *event, |
199 | struct perf_sample *sample, | |
743eb868 | 200 | struct machine *machine); |
45694aa7 | 201 | int perf_event__process_lost(struct perf_tool *tool, |
d20deb64 ACM |
202 | union perf_event *event, |
203 | struct perf_sample *sample, | |
743eb868 | 204 | struct machine *machine); |
45694aa7 | 205 | int perf_event__process_mmap(struct perf_tool *tool, |
d20deb64 ACM |
206 | union perf_event *event, |
207 | struct perf_sample *sample, | |
743eb868 | 208 | struct machine *machine); |
f62d3f0f ACM |
209 | int perf_event__process_fork(struct perf_tool *tool, |
210 | union perf_event *event, | |
211 | struct perf_sample *sample, | |
212 | struct machine *machine); | |
213 | int perf_event__process_exit(struct perf_tool *tool, | |
d20deb64 ACM |
214 | union perf_event *event, |
215 | struct perf_sample *sample, | |
743eb868 | 216 | struct machine *machine); |
45694aa7 | 217 | int perf_event__process(struct perf_tool *tool, |
d20deb64 ACM |
218 | union perf_event *event, |
219 | struct perf_sample *sample, | |
743eb868 | 220 | struct machine *machine); |
62daacb5 | 221 | |
1ed091c4 | 222 | struct addr_location; |
8115d60c | 223 | int perf_event__preprocess_sample(const union perf_event *self, |
743eb868 | 224 | struct machine *machine, |
8115d60c | 225 | struct addr_location *al, |
e44baa3e | 226 | struct perf_sample *sample); |
1ed091c4 | 227 | |
8115d60c | 228 | const char *perf_event__name(unsigned int id); |
c8446b9b | 229 | |
74eec26f AV |
230 | int perf_event__synthesize_sample(union perf_event *event, u64 type, |
231 | const struct perf_sample *sample, | |
232 | bool swapped); | |
d0dd74e8 | 233 | |
482ad897 ACM |
234 | size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp); |
235 | size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp); | |
236 | size_t perf_event__fprintf_task(union perf_event *event, FILE *fp); | |
237 | size_t perf_event__fprintf(union perf_event *event, FILE *fp); | |
238 | ||
8b40f521 | 239 | #endif /* __PERF_RECORD_H */ |