diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2010-12-07 07:48:47 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-12-09 08:18:06 -0500 |
commit | 9aefcab0de472ee2b3ab195a6827ddd4b170e3a7 (patch) | |
tree | 2747c4c5cfd42ba3b761ec233982b974ddda0a64 /tools/perf/util/session.c | |
parent | 79a14c1f458d598642bf11f09512c83d33a114e6 (diff) |
perf session: Consolidate the dump code
The dump code used by perf report -D is scattered all over the place.
Move it to separate functions.
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ian Munsie <imunsie@au1.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <20101207124550.625434869@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r-- | tools/perf/util/session.c | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index e5d0ed9603ee..12761d5bc92a 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -665,6 +665,35 @@ static void perf_session__print_tstamp(struct perf_session *session, | |||
665 | printf("%Lu ", sample->time); | 665 | printf("%Lu ", sample->time); |
666 | } | 666 | } |
667 | 667 | ||
668 | static void dump_event(struct perf_session *session, event_t *event, | ||
669 | u64 file_offset, struct sample_data *sample) | ||
670 | { | ||
671 | if (!dump_trace) | ||
672 | return; | ||
673 | |||
674 | dump_printf("\n%#Lx [%#x]: event: %d\n", file_offset, | ||
675 | event->header.size, event->header.type); | ||
676 | |||
677 | trace_event(event); | ||
678 | |||
679 | if (sample) | ||
680 | perf_session__print_tstamp(session, event, sample); | ||
681 | |||
682 | dump_printf("%#Lx [%#x]: PERF_RECORD_%s", | ||
683 | file_offset, event->header.size, | ||
684 | event__get_event_name(event->header.type)); | ||
685 | } | ||
686 | |||
687 | static void dump_sample(struct perf_session *session, event_t *event, | ||
688 | struct sample_data *sample) | ||
689 | { | ||
690 | dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc, | ||
691 | sample->pid, sample->tid, sample->ip, sample->period); | ||
692 | |||
693 | if (session->sample_type & PERF_SAMPLE_CALLCHAIN) | ||
694 | callchain__dump(sample); | ||
695 | } | ||
696 | |||
668 | static int perf_session_deliver_event(struct perf_session *session, | 697 | static int perf_session_deliver_event(struct perf_session *session, |
669 | event_t *event, | 698 | event_t *event, |
670 | struct sample_data *sample, | 699 | struct sample_data *sample, |
@@ -703,32 +732,24 @@ static int perf_session__process_event(struct perf_session *session, | |||
703 | struct sample_data sample; | 732 | struct sample_data sample; |
704 | int ret; | 733 | int ret; |
705 | 734 | ||
706 | trace_event(event); | ||
707 | |||
708 | if (session->header.needs_swap && event__swap_ops[event->header.type]) | 735 | if (session->header.needs_swap && event__swap_ops[event->header.type]) |
709 | event__swap_ops[event->header.type](event); | 736 | event__swap_ops[event->header.type](event); |
710 | 737 | ||
711 | if (event->header.type >= PERF_RECORD_MMAP && | 738 | if (event->header.type >= PERF_RECORD_HEADER_MAX) |
712 | event->header.type <= PERF_RECORD_SAMPLE) { | 739 | return -EINVAL; |
713 | event__parse_sample(event, session, &sample); | ||
714 | if (dump_trace) | ||
715 | perf_session__print_tstamp(session, event, &sample); | ||
716 | } | ||
717 | 740 | ||
718 | if (event->header.type < PERF_RECORD_HEADER_MAX) { | 741 | hists__inc_nr_events(&session->hists, event->header.type); |
719 | dump_printf("%#Lx [%#x]: PERF_RECORD_%s", | 742 | |
720 | file_offset, event->header.size, | 743 | if (event->header.type >= PERF_RECORD_USER_TYPE_START) |
721 | event__get_event_name(event->header.type)); | 744 | dump_event(session, event, file_offset, NULL); |
722 | hists__inc_nr_events(&session->hists, event->header.type); | 745 | else { |
746 | event__parse_sample(event, session, &sample); | ||
747 | dump_event(session, event, file_offset, &sample); | ||
723 | } | 748 | } |
724 | 749 | ||
725 | /* These events are processed right away */ | 750 | /* These events are processed right away */ |
726 | switch (event->header.type) { | 751 | switch (event->header.type) { |
727 | case PERF_RECORD_SAMPLE: | 752 | case PERF_RECORD_SAMPLE: |
728 | dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", | ||
729 | event->header.misc, | ||
730 | sample.pid, sample.tid, sample.ip, sample.period); | ||
731 | |||
732 | if (session->sample_type & PERF_SAMPLE_CALLCHAIN) { | 753 | if (session->sample_type & PERF_SAMPLE_CALLCHAIN) { |
733 | if (!ip_callchain__valid(sample.callchain, event)) { | 754 | if (!ip_callchain__valid(sample.callchain, event)) { |
734 | pr_debug("call-chain problem with event, " | 755 | pr_debug("call-chain problem with event, " |
@@ -738,9 +759,8 @@ static int perf_session__process_event(struct perf_session *session, | |||
738 | sample.period; | 759 | sample.period; |
739 | return 0; | 760 | return 0; |
740 | } | 761 | } |
741 | |||
742 | callchain__dump(&sample); | ||
743 | } | 762 | } |
763 | dump_sample(session, event, &sample); | ||
744 | break; | 764 | break; |
745 | 765 | ||
746 | case PERF_RECORD_HEADER_ATTR: | 766 | case PERF_RECORD_HEADER_ATTR: |
@@ -870,9 +890,6 @@ more: | |||
870 | 890 | ||
871 | head += size; | 891 | head += size; |
872 | 892 | ||
873 | dump_printf("\n%#Lx [%#x]: event: %d\n", | ||
874 | head, event.header.size, event.header.type); | ||
875 | |||
876 | if (skip > 0) | 893 | if (skip > 0) |
877 | head += skip; | 894 | head += skip; |
878 | 895 | ||
@@ -961,9 +978,6 @@ more: | |||
961 | 978 | ||
962 | size = event->header.size; | 979 | size = event->header.size; |
963 | 980 | ||
964 | dump_printf("\n%#Lx [%#x]: event: %d\n", | ||
965 | file_pos, event->header.size, event->header.type); | ||
966 | |||
967 | if (size == 0 || | 981 | if (size == 0 || |
968 | perf_session__process_event(session, event, ops, file_pos) < 0) { | 982 | perf_session__process_event(session, event, ops, file_pos) < 0) { |
969 | dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n", | 983 | dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n", |