diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-05-26 12:48:58 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-26 12:48:58 -0400 |
commit | 97b07b699b11d4bd1218a841e5dfed16bd53de06 (patch) | |
tree | 117a11e9c0acf77b92e030bcb53138d4d268e2c9 /Documentation/perf_counter/builtin-report.c | |
parent | abd54f68629fa73ed4fa040d433196211a9bbed2 (diff) |
perf report: add --dump-raw-trace option
To help the inspection of various data files, implement an ASCII dump
method that just dumps the records as they are read in - then we exit.
[ Impact: new feature ]
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter/builtin-report.c')
-rw-r--r-- | Documentation/perf_counter/builtin-report.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index e17819001dd5..8ea8aaa05af5 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c | |||
@@ -20,6 +20,8 @@ static char const *input_name = "output.perf"; | |||
20 | static int input; | 20 | static int input; |
21 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; | 21 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; |
22 | 22 | ||
23 | static int dump_trace = 0; | ||
24 | |||
23 | static unsigned long page_size; | 25 | static unsigned long page_size; |
24 | static unsigned long mmap_window = 32; | 26 | static unsigned long mmap_window = 32; |
25 | 27 | ||
@@ -643,7 +645,7 @@ static int __cmd_report(void) | |||
643 | char *buf; | 645 | char *buf; |
644 | event_t *event; | 646 | event_t *event; |
645 | int ret, rc = EXIT_FAILURE; | 647 | int ret, rc = EXIT_FAILURE; |
646 | unsigned long total = 0; | 648 | unsigned long total = 0, total_mmap = 0, total_comm = 0; |
647 | 649 | ||
648 | input = open(input_name, O_RDONLY); | 650 | input = open(input_name, O_RDONLY); |
649 | if (input < 0) { | 651 | if (input < 0) { |
@@ -706,6 +708,13 @@ more: | |||
706 | struct thread *thread = threads__findnew(event->ip.pid); | 708 | struct thread *thread = threads__findnew(event->ip.pid); |
707 | uint64_t ip = event->ip.ip; | 709 | uint64_t ip = event->ip.ip; |
708 | 710 | ||
711 | if (dump_trace) { | ||
712 | fprintf(stderr, "PERF_EVENT (IP, %d): %d: %p\n", | ||
713 | event->header.misc, | ||
714 | event->ip.pid, | ||
715 | (void *)event->ip.ip); | ||
716 | } | ||
717 | |||
709 | if (thread == NULL) { | 718 | if (thread == NULL) { |
710 | fprintf(stderr, "problem processing %d event, bailing out\n", | 719 | fprintf(stderr, "problem processing %d event, bailing out\n", |
711 | event->header.type); | 720 | event->header.type); |
@@ -743,23 +752,40 @@ more: | |||
743 | struct thread *thread = threads__findnew(event->mmap.pid); | 752 | struct thread *thread = threads__findnew(event->mmap.pid); |
744 | struct map *map = map__new(&event->mmap); | 753 | struct map *map = map__new(&event->mmap); |
745 | 754 | ||
755 | if (dump_trace) { | ||
756 | fprintf(stderr, "PERF_EVENT_MMAP: [%p(%p) @ %p]: %s\n", | ||
757 | (void *)event->mmap.start, | ||
758 | (void *)event->mmap.len, | ||
759 | (void *)event->mmap.pgoff, | ||
760 | event->mmap.filename); | ||
761 | } | ||
746 | if (thread == NULL || map == NULL) { | 762 | if (thread == NULL || map == NULL) { |
747 | fprintf(stderr, "problem processing PERF_EVENT_MMAP, bailing out\n"); | 763 | fprintf(stderr, "problem processing PERF_EVENT_MMAP, bailing out\n"); |
748 | goto done; | 764 | goto done; |
749 | } | 765 | } |
750 | thread__insert_map(thread, map); | 766 | thread__insert_map(thread, map); |
767 | total_mmap++; | ||
751 | break; | 768 | break; |
752 | } | 769 | } |
753 | case PERF_EVENT_COMM: { | 770 | case PERF_EVENT_COMM: { |
754 | struct thread *thread = threads__findnew(event->comm.pid); | 771 | struct thread *thread = threads__findnew(event->comm.pid); |
755 | 772 | ||
773 | if (dump_trace) { | ||
774 | fprintf(stderr, "PERF_EVENT_COMM: %s:%d\n", | ||
775 | event->comm.comm, event->comm.pid); | ||
776 | } | ||
756 | if (thread == NULL || | 777 | if (thread == NULL || |
757 | thread__set_comm(thread, event->comm.comm)) { | 778 | thread__set_comm(thread, event->comm.comm)) { |
758 | fprintf(stderr, "problem processing PERF_EVENT_COMM, bailing out\n"); | 779 | fprintf(stderr, "problem processing PERF_EVENT_COMM, bailing out\n"); |
759 | goto done; | 780 | goto done; |
760 | } | 781 | } |
782 | total_comm++; | ||
761 | break; | 783 | break; |
762 | } | 784 | } |
785 | default: { | ||
786 | fprintf(stderr, "skipping unknown header type: %d\n", | ||
787 | event->header.type); | ||
788 | } | ||
763 | } | 789 | } |
764 | 790 | ||
765 | if (offset + head < stat.st_size) | 791 | if (offset + head < stat.st_size) |
@@ -768,6 +794,15 @@ more: | |||
768 | rc = EXIT_SUCCESS; | 794 | rc = EXIT_SUCCESS; |
769 | done: | 795 | done: |
770 | close(input); | 796 | close(input); |
797 | |||
798 | if (dump_trace) { | ||
799 | fprintf(stderr, " IP events: %10ld\n", total); | ||
800 | fprintf(stderr, " mmap events: %10ld\n", total_mmap); | ||
801 | fprintf(stderr, " comm events: %10ld\n", total_comm); | ||
802 | |||
803 | return 0; | ||
804 | } | ||
805 | |||
771 | //dsos__fprintf(stdout); | 806 | //dsos__fprintf(stdout); |
772 | threads__fprintf(stdout); | 807 | threads__fprintf(stdout); |
773 | #if 0 | 808 | #if 0 |
@@ -796,6 +831,8 @@ static const char * const report_usage[] = { | |||
796 | static const struct option options[] = { | 831 | static const struct option options[] = { |
797 | OPT_STRING('i', "input", &input_name, "file", | 832 | OPT_STRING('i', "input", &input_name, "file", |
798 | "input file name"), | 833 | "input file name"), |
834 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | ||
835 | "dump raw trace in ASCII"), | ||
799 | OPT_END() | 836 | OPT_END() |
800 | }; | 837 | }; |
801 | 838 | ||