diff options
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r-- | tools/perf/util/event.c | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 7260db75b93d..34510f441975 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -24,6 +24,15 @@ const char *event__name[] = { | |||
24 | [PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID", | 24 | [PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID", |
25 | }; | 25 | }; |
26 | 26 | ||
27 | static struct sample_data synth_sample = { | ||
28 | .pid = -1, | ||
29 | .tid = -1, | ||
30 | .time = -1, | ||
31 | .stream_id = -1, | ||
32 | .cpu = -1, | ||
33 | .period = 1, | ||
34 | }; | ||
35 | |||
27 | static pid_t event__synthesize_comm(pid_t pid, int full, | 36 | static pid_t event__synthesize_comm(pid_t pid, int full, |
28 | event__handler_t process, | 37 | event__handler_t process, |
29 | struct perf_session *session) | 38 | struct perf_session *session) |
@@ -75,7 +84,7 @@ out_race: | |||
75 | if (!full) { | 84 | if (!full) { |
76 | ev.comm.tid = pid; | 85 | ev.comm.tid = pid; |
77 | 86 | ||
78 | process(&ev, session); | 87 | process(&ev, &synth_sample, session); |
79 | goto out_fclose; | 88 | goto out_fclose; |
80 | } | 89 | } |
81 | 90 | ||
@@ -93,7 +102,7 @@ out_race: | |||
93 | 102 | ||
94 | ev.comm.tid = pid; | 103 | ev.comm.tid = pid; |
95 | 104 | ||
96 | process(&ev, session); | 105 | process(&ev, &synth_sample, session); |
97 | } | 106 | } |
98 | closedir(tasks); | 107 | closedir(tasks); |
99 | 108 | ||
@@ -173,7 +182,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid, | |||
173 | ev.mmap.pid = tgid; | 182 | ev.mmap.pid = tgid; |
174 | ev.mmap.tid = pid; | 183 | ev.mmap.tid = pid; |
175 | 184 | ||
176 | process(&ev, session); | 185 | process(&ev, &synth_sample, session); |
177 | } | 186 | } |
178 | } | 187 | } |
179 | 188 | ||
@@ -219,7 +228,7 @@ int event__synthesize_modules(event__handler_t process, | |||
219 | 228 | ||
220 | memcpy(ev.mmap.filename, pos->dso->long_name, | 229 | memcpy(ev.mmap.filename, pos->dso->long_name, |
221 | pos->dso->long_name_len + 1); | 230 | pos->dso->long_name_len + 1); |
222 | process(&ev, session); | 231 | process(&ev, &synth_sample, session); |
223 | } | 232 | } |
224 | 233 | ||
225 | return 0; | 234 | return 0; |
@@ -331,7 +340,7 @@ int event__synthesize_kernel_mmap(event__handler_t process, | |||
331 | ev.mmap.len = map->end - ev.mmap.start; | 340 | ev.mmap.len = map->end - ev.mmap.start; |
332 | ev.mmap.pid = machine->pid; | 341 | ev.mmap.pid = machine->pid; |
333 | 342 | ||
334 | return process(&ev, session); | 343 | return process(&ev, &synth_sample, session); |
335 | } | 344 | } |
336 | 345 | ||
337 | static void thread__comm_adjust(struct thread *self, struct hists *hists) | 346 | static void thread__comm_adjust(struct thread *self, struct hists *hists) |
@@ -361,7 +370,8 @@ static int thread__set_comm_adjust(struct thread *self, const char *comm, | |||
361 | return 0; | 370 | return 0; |
362 | } | 371 | } |
363 | 372 | ||
364 | int event__process_comm(event_t *self, struct perf_session *session) | 373 | int event__process_comm(event_t *self, struct sample_data *sample __used, |
374 | struct perf_session *session) | ||
365 | { | 375 | { |
366 | struct thread *thread = perf_session__findnew(session, self->comm.tid); | 376 | struct thread *thread = perf_session__findnew(session, self->comm.tid); |
367 | 377 | ||
@@ -376,7 +386,8 @@ int event__process_comm(event_t *self, struct perf_session *session) | |||
376 | return 0; | 386 | return 0; |
377 | } | 387 | } |
378 | 388 | ||
379 | int event__process_lost(event_t *self, struct perf_session *session) | 389 | int event__process_lost(event_t *self, struct sample_data *sample __used, |
390 | struct perf_session *session) | ||
380 | { | 391 | { |
381 | dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); | 392 | dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); |
382 | session->hists.stats.total_lost += self->lost.lost; | 393 | session->hists.stats.total_lost += self->lost.lost; |
@@ -485,7 +496,8 @@ out_problem: | |||
485 | return -1; | 496 | return -1; |
486 | } | 497 | } |
487 | 498 | ||
488 | int event__process_mmap(event_t *self, struct perf_session *session) | 499 | int event__process_mmap(event_t *self, struct sample_data *sample __used, |
500 | struct perf_session *session) | ||
489 | { | 501 | { |
490 | struct machine *machine; | 502 | struct machine *machine; |
491 | struct thread *thread; | 503 | struct thread *thread; |
@@ -526,7 +538,8 @@ out_problem: | |||
526 | return 0; | 538 | return 0; |
527 | } | 539 | } |
528 | 540 | ||
529 | int event__process_task(event_t *self, struct perf_session *session) | 541 | int event__process_task(event_t *self, struct sample_data *sample __used, |
542 | struct perf_session *session) | ||
530 | { | 543 | { |
531 | struct thread *thread = perf_session__findnew(session, self->fork.tid); | 544 | struct thread *thread = perf_session__findnew(session, self->fork.tid); |
532 | struct thread *parent = perf_session__findnew(session, self->fork.ptid); | 545 | struct thread *parent = perf_session__findnew(session, self->fork.ptid); |
@@ -548,18 +561,19 @@ int event__process_task(event_t *self, struct perf_session *session) | |||
548 | return 0; | 561 | return 0; |
549 | } | 562 | } |
550 | 563 | ||
551 | int event__process(event_t *event, struct perf_session *session) | 564 | int event__process(event_t *event, struct sample_data *sample, |
565 | struct perf_session *session) | ||
552 | { | 566 | { |
553 | switch (event->header.type) { | 567 | switch (event->header.type) { |
554 | case PERF_RECORD_COMM: | 568 | case PERF_RECORD_COMM: |
555 | event__process_comm(event, session); | 569 | event__process_comm(event, sample, session); |
556 | break; | 570 | break; |
557 | case PERF_RECORD_MMAP: | 571 | case PERF_RECORD_MMAP: |
558 | event__process_mmap(event, session); | 572 | event__process_mmap(event, sample, session); |
559 | break; | 573 | break; |
560 | case PERF_RECORD_FORK: | 574 | case PERF_RECORD_FORK: |
561 | case PERF_RECORD_EXIT: | 575 | case PERF_RECORD_EXIT: |
562 | event__process_task(event, session); | 576 | event__process_task(event, sample, session); |
563 | break; | 577 | break; |
564 | default: | 578 | default: |
565 | break; | 579 | break; |
@@ -674,32 +688,8 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session, | |||
674 | symbol_filter_t filter) | 688 | symbol_filter_t filter) |
675 | { | 689 | { |
676 | u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 690 | u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
677 | struct thread *thread; | 691 | struct thread *thread = perf_session__findnew(session, self->ip.pid); |
678 | |||
679 | event__parse_sample(self, session->sample_type, data); | ||
680 | 692 | ||
681 | dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld cpu:%d\n", | ||
682 | self->header.misc, data->pid, data->tid, data->ip, | ||
683 | data->period, data->cpu); | ||
684 | |||
685 | if (session->sample_type & PERF_SAMPLE_CALLCHAIN) { | ||
686 | unsigned int i; | ||
687 | |||
688 | dump_printf("... chain: nr:%Lu\n", data->callchain->nr); | ||
689 | |||
690 | if (!ip_callchain__valid(data->callchain, self)) { | ||
691 | pr_debug("call-chain problem with event, " | ||
692 | "skipping it.\n"); | ||
693 | goto out_filtered; | ||
694 | } | ||
695 | |||
696 | if (dump_trace) { | ||
697 | for (i = 0; i < data->callchain->nr; i++) | ||
698 | dump_printf("..... %2d: %016Lx\n", | ||
699 | i, data->callchain->ips[i]); | ||
700 | } | ||
701 | } | ||
702 | thread = perf_session__findnew(session, self->ip.pid); | ||
703 | if (thread == NULL) | 693 | if (thread == NULL) |
704 | return -1; | 694 | return -1; |
705 | 695 | ||