diff options
Diffstat (limited to 'tools/perf/util/process_events.c')
-rw-r--r-- | tools/perf/util/process_events.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tools/perf/util/process_events.c b/tools/perf/util/process_events.c new file mode 100644 index 000000000000..a9204363efd8 --- /dev/null +++ b/tools/perf/util/process_events.c | |||
@@ -0,0 +1,64 @@ | |||
1 | #include "process_events.h" | ||
2 | |||
3 | char *cwd; | ||
4 | int cwdlen; | ||
5 | |||
6 | int | ||
7 | process_mmap_event(event_t *event, unsigned long offset, unsigned long head) | ||
8 | { | ||
9 | struct map *map = map__new(&event->mmap, cwd, cwdlen); | ||
10 | struct thread *thread = threads__findnew(event->mmap.pid); | ||
11 | |||
12 | dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n", | ||
13 | (void *)(offset + head), | ||
14 | (void *)(long)(event->header.size), | ||
15 | event->mmap.pid, | ||
16 | event->mmap.tid, | ||
17 | (void *)(long)event->mmap.start, | ||
18 | (void *)(long)event->mmap.len, | ||
19 | (void *)(long)event->mmap.pgoff, | ||
20 | event->mmap.filename); | ||
21 | |||
22 | if (thread == NULL || map == NULL) { | ||
23 | dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n"); | ||
24 | return 0; | ||
25 | } | ||
26 | |||
27 | thread__insert_map(thread, map); | ||
28 | total_mmap++; | ||
29 | |||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | int | ||
34 | process_task_event(event_t *event, unsigned long offset, unsigned long head) | ||
35 | { | ||
36 | struct thread *thread = threads__findnew(event->fork.pid); | ||
37 | struct thread *parent = threads__findnew(event->fork.ppid); | ||
38 | |||
39 | dump_printf("%p [%p]: PERF_RECORD_%s: (%d:%d):(%d:%d)\n", | ||
40 | (void *)(offset + head), | ||
41 | (void *)(long)(event->header.size), | ||
42 | event->header.type == PERF_RECORD_FORK ? "FORK" : "EXIT", | ||
43 | event->fork.pid, event->fork.tid, | ||
44 | event->fork.ppid, event->fork.ptid); | ||
45 | |||
46 | /* | ||
47 | * A thread clone will have the same PID for both | ||
48 | * parent and child. | ||
49 | */ | ||
50 | if (thread == parent) | ||
51 | return 0; | ||
52 | |||
53 | if (event->header.type == PERF_RECORD_EXIT) | ||
54 | return 0; | ||
55 | |||
56 | if (!thread || !parent || thread__fork(thread, parent)) { | ||
57 | dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n"); | ||
58 | return -1; | ||
59 | } | ||
60 | total_fork++; | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||