aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/event.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r--tools/perf/util/event.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 437f8ca679a0..4800f38c7277 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -44,7 +44,8 @@ static struct perf_sample synth_sample = {
44 .period = 1, 44 .period = 1,
45}; 45};
46 46
47static pid_t perf_event__synthesize_comm(union perf_event *event, pid_t pid, 47static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops,
48 union perf_event *event, pid_t pid,
48 int full, perf_event__handler_t process, 49 int full, perf_event__handler_t process,
49 struct perf_session *session) 50 struct perf_session *session)
50{ 51{
@@ -99,7 +100,7 @@ out_race:
99 if (!full) { 100 if (!full) {
100 event->comm.tid = pid; 101 event->comm.tid = pid;
101 102
102 process(event, &synth_sample, session); 103 process(ops, event, &synth_sample, session);
103 goto out; 104 goto out;
104 } 105 }
105 106
@@ -117,7 +118,7 @@ out_race:
117 118
118 event->comm.tid = pid; 119 event->comm.tid = pid;
119 120
120 process(event, &synth_sample, session); 121 process(ops, event, &synth_sample, session);
121 } 122 }
122 123
123 closedir(tasks); 124 closedir(tasks);
@@ -127,7 +128,8 @@ out:
127 return tgid; 128 return tgid;
128} 129}
129 130
130static int perf_event__synthesize_mmap_events(union perf_event *event, 131static int perf_event__synthesize_mmap_events(struct perf_event_ops *ops,
132 union perf_event *event,
131 pid_t pid, pid_t tgid, 133 pid_t pid, pid_t tgid,
132 perf_event__handler_t process, 134 perf_event__handler_t process,
133 struct perf_session *session) 135 struct perf_session *session)
@@ -198,7 +200,7 @@ static int perf_event__synthesize_mmap_events(union perf_event *event,
198 event->mmap.pid = tgid; 200 event->mmap.pid = tgid;
199 event->mmap.tid = pid; 201 event->mmap.tid = pid;
200 202
201 process(event, &synth_sample, session); 203 process(ops, event, &synth_sample, session);
202 } 204 }
203 } 205 }
204 206
@@ -206,7 +208,8 @@ static int perf_event__synthesize_mmap_events(union perf_event *event,
206 return 0; 208 return 0;
207} 209}
208 210
209int perf_event__synthesize_modules(perf_event__handler_t process, 211int perf_event__synthesize_modules(struct perf_event_ops *ops,
212 perf_event__handler_t process,
210 struct perf_session *session, 213 struct perf_session *session,
211 struct machine *machine) 214 struct machine *machine)
212{ 215{
@@ -251,7 +254,7 @@ int perf_event__synthesize_modules(perf_event__handler_t process,
251 254
252 memcpy(event->mmap.filename, pos->dso->long_name, 255 memcpy(event->mmap.filename, pos->dso->long_name,
253 pos->dso->long_name_len + 1); 256 pos->dso->long_name_len + 1);
254 process(event, &synth_sample, session); 257 process(ops, event, &synth_sample, session);
255 } 258 }
256 259
257 free(event); 260 free(event);
@@ -261,17 +264,19 @@ int perf_event__synthesize_modules(perf_event__handler_t process,
261static int __event__synthesize_thread(union perf_event *comm_event, 264static int __event__synthesize_thread(union perf_event *comm_event,
262 union perf_event *mmap_event, 265 union perf_event *mmap_event,
263 pid_t pid, perf_event__handler_t process, 266 pid_t pid, perf_event__handler_t process,
267 struct perf_event_ops *ops,
264 struct perf_session *session) 268 struct perf_session *session)
265{ 269{
266 pid_t tgid = perf_event__synthesize_comm(comm_event, pid, 1, process, 270 pid_t tgid = perf_event__synthesize_comm(ops, comm_event, pid, 1, process,
267 session); 271 session);
268 if (tgid == -1) 272 if (tgid == -1)
269 return -1; 273 return -1;
270 return perf_event__synthesize_mmap_events(mmap_event, pid, tgid, 274 return perf_event__synthesize_mmap_events(ops, mmap_event, pid, tgid,
271 process, session); 275 process, session);
272} 276}
273 277
274int perf_event__synthesize_thread_map(struct thread_map *threads, 278int perf_event__synthesize_thread_map(struct perf_event_ops *ops,
279 struct thread_map *threads,
275 perf_event__handler_t process, 280 perf_event__handler_t process,
276 struct perf_session *session) 281 struct perf_session *session)
277{ 282{
@@ -290,7 +295,7 @@ int perf_event__synthesize_thread_map(struct thread_map *threads,
290 for (thread = 0; thread < threads->nr; ++thread) { 295 for (thread = 0; thread < threads->nr; ++thread) {
291 if (__event__synthesize_thread(comm_event, mmap_event, 296 if (__event__synthesize_thread(comm_event, mmap_event,
292 threads->map[thread], 297 threads->map[thread],
293 process, session)) { 298 process, ops, session)) {
294 err = -1; 299 err = -1;
295 break; 300 break;
296 } 301 }
@@ -302,7 +307,8 @@ out:
302 return err; 307 return err;
303} 308}
304 309
305int perf_event__synthesize_threads(perf_event__handler_t process, 310int perf_event__synthesize_threads(struct perf_event_ops *ops,
311 perf_event__handler_t process,
306 struct perf_session *session) 312 struct perf_session *session)
307{ 313{
308 DIR *proc; 314 DIR *proc;
@@ -330,7 +336,7 @@ int perf_event__synthesize_threads(perf_event__handler_t process,
330 continue; 336 continue;
331 337
332 __event__synthesize_thread(comm_event, mmap_event, pid, 338 __event__synthesize_thread(comm_event, mmap_event, pid,
333 process, session); 339 process, ops, session);
334 } 340 }
335 341
336 closedir(proc); 342 closedir(proc);
@@ -365,7 +371,8 @@ static int find_symbol_cb(void *arg, const char *name, char type,
365 return 1; 371 return 1;
366} 372}
367 373
368int perf_event__synthesize_kernel_mmap(perf_event__handler_t process, 374int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops,
375 perf_event__handler_t process,
369 struct perf_session *session, 376 struct perf_session *session,
370 struct machine *machine, 377 struct machine *machine,
371 const char *symbol_name) 378 const char *symbol_name)
@@ -423,13 +430,14 @@ int perf_event__synthesize_kernel_mmap(perf_event__handler_t process,
423 event->mmap.len = map->end - event->mmap.start; 430 event->mmap.len = map->end - event->mmap.start;
424 event->mmap.pid = machine->pid; 431 event->mmap.pid = machine->pid;
425 432
426 err = process(event, &synth_sample, session); 433 err = process(ops, event, &synth_sample, session);
427 free(event); 434 free(event);
428 435
429 return err; 436 return err;
430} 437}
431 438
432int perf_event__process_comm(union perf_event *event, 439int perf_event__process_comm(struct perf_event_ops *ops __used,
440 union perf_event *event,
433 struct perf_sample *sample __used, 441 struct perf_sample *sample __used,
434 struct perf_session *session) 442 struct perf_session *session)
435{ 443{
@@ -445,7 +453,8 @@ int perf_event__process_comm(union perf_event *event,
445 return 0; 453 return 0;
446} 454}
447 455
448int perf_event__process_lost(union perf_event *event, 456int perf_event__process_lost(struct perf_event_ops *ops __used,
457 union perf_event *event,
449 struct perf_sample *sample __used, 458 struct perf_sample *sample __used,
450 struct perf_session *session) 459 struct perf_session *session)
451{ 460{
@@ -468,7 +477,8 @@ static void perf_event__set_kernel_mmap_len(union perf_event *event,
468 maps[MAP__FUNCTION]->end = ~0ULL; 477 maps[MAP__FUNCTION]->end = ~0ULL;
469} 478}
470 479
471static int perf_event__process_kernel_mmap(union perf_event *event, 480static int perf_event__process_kernel_mmap(struct perf_event_ops *ops __used,
481 union perf_event *event,
472 struct perf_session *session) 482 struct perf_session *session)
473{ 483{
474 struct map *map; 484 struct map *map;
@@ -567,7 +577,8 @@ out_problem:
567 return -1; 577 return -1;
568} 578}
569 579
570int perf_event__process_mmap(union perf_event *event, 580int perf_event__process_mmap(struct perf_event_ops *ops,
581 union perf_event *event,
571 struct perf_sample *sample __used, 582 struct perf_sample *sample __used,
572 struct perf_session *session) 583 struct perf_session *session)
573{ 584{
@@ -583,7 +594,7 @@ int perf_event__process_mmap(union perf_event *event,
583 594
584 if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL || 595 if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
585 cpumode == PERF_RECORD_MISC_KERNEL) { 596 cpumode == PERF_RECORD_MISC_KERNEL) {
586 ret = perf_event__process_kernel_mmap(event, session); 597 ret = perf_event__process_kernel_mmap(ops, event, session);
587 if (ret < 0) 598 if (ret < 0)
588 goto out_problem; 599 goto out_problem;
589 return 0; 600 return 0;
@@ -610,7 +621,8 @@ out_problem:
610 return 0; 621 return 0;
611} 622}
612 623
613int perf_event__process_task(union perf_event *event, 624int perf_event__process_task(struct perf_event_ops *ops __used,
625 union perf_event *event,
614 struct perf_sample *sample __used, 626 struct perf_sample *sample __used,
615 struct perf_session *session) 627 struct perf_session *session)
616{ 628{
@@ -634,22 +646,22 @@ int perf_event__process_task(union perf_event *event,
634 return 0; 646 return 0;
635} 647}
636 648
637int perf_event__process(union perf_event *event, struct perf_sample *sample, 649int perf_event__process(struct perf_event_ops *ops, union perf_event *event,
638 struct perf_session *session) 650 struct perf_sample *sample, struct perf_session *session)
639{ 651{
640 switch (event->header.type) { 652 switch (event->header.type) {
641 case PERF_RECORD_COMM: 653 case PERF_RECORD_COMM:
642 perf_event__process_comm(event, sample, session); 654 perf_event__process_comm(ops, event, sample, session);
643 break; 655 break;
644 case PERF_RECORD_MMAP: 656 case PERF_RECORD_MMAP:
645 perf_event__process_mmap(event, sample, session); 657 perf_event__process_mmap(ops, event, sample, session);
646 break; 658 break;
647 case PERF_RECORD_FORK: 659 case PERF_RECORD_FORK:
648 case PERF_RECORD_EXIT: 660 case PERF_RECORD_EXIT:
649 perf_event__process_task(event, sample, session); 661 perf_event__process_task(ops, event, sample, session);
650 break; 662 break;
651 case PERF_RECORD_LOST: 663 case PERF_RECORD_LOST:
652 perf_event__process_lost(event, sample, session); 664 perf_event__process_lost(ops, event, sample, session);
653 default: 665 default:
654 break; 666 break;
655 } 667 }