diff options
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r-- | tools/perf/util/event.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 1dae7e3b400d..70b4aa03b472 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "event.h" | 2 | #include "event.h" |
3 | #include "debug.h" | 3 | #include "debug.h" |
4 | #include "string.h" | 4 | #include "string.h" |
5 | #include "thread.h" | ||
5 | 6 | ||
6 | static pid_t event__synthesize_comm(pid_t pid, int full, | 7 | static pid_t event__synthesize_comm(pid_t pid, int full, |
7 | int (*process)(event_t *event)) | 8 | int (*process)(event_t *event)) |
@@ -175,3 +176,76 @@ void event__synthesize_threads(int (*process)(event_t *event)) | |||
175 | 176 | ||
176 | closedir(proc); | 177 | closedir(proc); |
177 | } | 178 | } |
179 | |||
180 | char *event__cwd; | ||
181 | int event__cwdlen; | ||
182 | |||
183 | struct events_stats event__stats; | ||
184 | |||
185 | int event__process_comm(event_t *self) | ||
186 | { | ||
187 | struct thread *thread = threads__findnew(self->comm.pid); | ||
188 | |||
189 | dump_printf("PERF_RECORD_COMM: %s:%d\n", | ||
190 | self->comm.comm, self->comm.pid); | ||
191 | |||
192 | if (thread == NULL || thread__set_comm(thread, self->comm.comm)) { | ||
193 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); | ||
194 | return -1; | ||
195 | } | ||
196 | |||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | int event__process_lost(event_t *self) | ||
201 | { | ||
202 | dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); | ||
203 | event__stats.lost += self->lost.lost; | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | int event__process_mmap(event_t *self) | ||
208 | { | ||
209 | struct thread *thread = threads__findnew(self->mmap.pid); | ||
210 | struct map *map = map__new(&self->mmap, MAP__FUNCTION, | ||
211 | event__cwd, event__cwdlen); | ||
212 | |||
213 | dump_printf(" %d/%d: [%p(%p) @ %p]: %s\n", | ||
214 | self->mmap.pid, self->mmap.tid, | ||
215 | (void *)(long)self->mmap.start, | ||
216 | (void *)(long)self->mmap.len, | ||
217 | (void *)(long)self->mmap.pgoff, | ||
218 | self->mmap.filename); | ||
219 | |||
220 | if (thread == NULL || map == NULL) | ||
221 | dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n"); | ||
222 | else | ||
223 | thread__insert_map(thread, map); | ||
224 | |||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | int event__process_task(event_t *self) | ||
229 | { | ||
230 | struct thread *thread = threads__findnew(self->fork.pid); | ||
231 | struct thread *parent = threads__findnew(self->fork.ppid); | ||
232 | |||
233 | dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, | ||
234 | self->fork.ppid, self->fork.ptid); | ||
235 | /* | ||
236 | * A thread clone will have the same PID for both parent and child. | ||
237 | */ | ||
238 | if (thread == parent) | ||
239 | return 0; | ||
240 | |||
241 | if (self->header.type == PERF_RECORD_EXIT) | ||
242 | return 0; | ||
243 | |||
244 | if (thread == NULL || parent == NULL || | ||
245 | thread__fork(thread, parent) < 0) { | ||
246 | dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n"); | ||
247 | return -1; | ||
248 | } | ||
249 | |||
250 | return 0; | ||
251 | } | ||