aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/process_event.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/process_event.c')
-rw-r--r--tools/perf/util/process_event.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/perf/util/process_event.c b/tools/perf/util/process_event.c
new file mode 100644
index 000000000000..a970789581a2
--- /dev/null
+++ b/tools/perf/util/process_event.c
@@ -0,0 +1,53 @@
1#include "process_event.h"
2
3char *cwd;
4int cwdlen;
5
6int
7process_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
34int
35process_comm_event(event_t *event, unsigned long offset, unsigned long head)
36{
37 struct thread *thread = threads__findnew(event->comm.pid);
38
39 dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n",
40 (void *)(offset + head),
41 (void *)(long)(event->header.size),
42 event->comm.comm, event->comm.pid);
43
44 if (thread == NULL ||
45 thread__set_comm_adjust(thread, event->comm.comm)) {
46 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
47 return -1;
48 }
49 total_comm++;
50
51 return 0;
52}
53