aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2012-03-08 17:47:48 -0500
committerIngo Molnar <mingo@elte.hu>2012-03-09 02:26:08 -0500
commita68c2c58171391ef368fced32a555b2f0ff106e5 (patch)
tree9952e5bb45d3890e67f9f81ad704489d5a114d94 /tools/perf/builtin-report.c
parent993ac88d5892629fbe1f8a54857f9947f49f0d96 (diff)
perf report: Enable TUI in branch view mode
This patch updates perf report to support TUI mode when the perf.data file contains samples with branch stacks. For each row in the report, it is possible to annotate either the source or target of each branch. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331246868-19905-5-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c73
1 files changed, 50 insertions, 23 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 66e852376a05..8e91c6eba18a 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -64,7 +64,7 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool,
64 int err = 0; 64 int err = 0;
65 unsigned i; 65 unsigned i;
66 struct hist_entry *he; 66 struct hist_entry *he;
67 struct branch_info *bi; 67 struct branch_info *bi, *bx;
68 68
69 if ((sort__has_parent || symbol_conf.use_callchain) 69 if ((sort__has_parent || symbol_conf.use_callchain)
70 && sample->callchain) { 70 && sample->callchain) {
@@ -87,13 +87,45 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool,
87 * and not events sampled. Thus we use a pseudo period of 1. 87 * and not events sampled. Thus we use a pseudo period of 1.
88 */ 88 */
89 he = __hists__add_branch_entry(&evsel->hists, al, parent, 89 he = __hists__add_branch_entry(&evsel->hists, al, parent,
90 &bi[i], 1); 90 &bi[i], 1);
91 if (he) { 91 if (he) {
92 struct annotation *notes;
93 err = -ENOMEM;
94 bx = he->branch_info;
95 if (bx->from.sym && use_browser > 0) {
96 notes = symbol__annotation(bx->from.sym);
97 if (!notes->src
98 && symbol__alloc_hist(bx->from.sym) < 0)
99 goto out;
100
101 err = symbol__inc_addr_samples(bx->from.sym,
102 bx->from.map,
103 evsel->idx,
104 bx->from.al_addr);
105 if (err)
106 goto out;
107 }
108
109 if (bx->to.sym && use_browser > 0) {
110 notes = symbol__annotation(bx->to.sym);
111 if (!notes->src
112 && symbol__alloc_hist(bx->to.sym) < 0)
113 goto out;
114
115 err = symbol__inc_addr_samples(bx->to.sym,
116 bx->to.map,
117 evsel->idx,
118 bx->to.al_addr);
119 if (err)
120 goto out;
121 }
92 evsel->hists.stats.total_period += 1; 122 evsel->hists.stats.total_period += 1;
93 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); 123 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
124 err = 0;
94 } else 125 } else
95 return -ENOMEM; 126 return -ENOMEM;
96 } 127 }
128out:
97 return err; 129 return err;
98} 130}
99 131
@@ -615,32 +647,19 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
615 if (sort__branch_mode == -1 && has_br_stack) 647 if (sort__branch_mode == -1 && has_br_stack)
616 sort__branch_mode = 1; 648 sort__branch_mode = 1;
617 649
650 /* sort__branch_mode could be 0 if --no-branch-stack */
618 if (sort__branch_mode == 1) { 651 if (sort__branch_mode == 1) {
619 if (use_browser)
620 fprintf(stderr, "Warning: TUI interface not supported"
621 " in branch mode\n");
622 if (symbol_conf.dso_list_str != NULL)
623 fprintf(stderr, "Warning: dso filtering not supported"
624 " in branch mode\n");
625 if (symbol_conf.sym_list_str != NULL)
626 fprintf(stderr, "Warning: symbol filtering not"
627 " supported in branch mode\n");
628
629 report.use_stdio = true;
630 use_browser = 0;
631 setup_browser(true);
632 symbol_conf.dso_list_str = NULL;
633 symbol_conf.sym_list_str = NULL;
634
635 /* 652 /*
636 * if no sort_order is provided, then specify branch-mode 653 * if no sort_order is provided, then specify
637 * specific order 654 * branch-mode specific order
638 */ 655 */
639 if (sort_order == default_sort_order) 656 if (sort_order == default_sort_order)
640 sort_order = "comm,dso_from,symbol_from," 657 sort_order = "comm,dso_from,symbol_from,"
641 "dso_to,symbol_to"; 658 "dso_to,symbol_to";
642 659
643 } else if (strcmp(report.input_name, "-") != 0) { 660 }
661
662 if (strcmp(report.input_name, "-") != 0) {
644 setup_browser(true); 663 setup_browser(true);
645 } else { 664 } else {
646 use_browser = 0; 665 use_browser = 0;
@@ -696,9 +715,17 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
696 if (argc) 715 if (argc)
697 usage_with_options(report_usage, options); 716 usage_with_options(report_usage, options);
698 717
699 sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
700 sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); 718 sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);
701 sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout); 719
720 if (sort__branch_mode == 1) {
721 sort_entry__setup_elide(&sort_dso_from, symbol_conf.dso_from_list, "dso_from", stdout);
722 sort_entry__setup_elide(&sort_dso_to, symbol_conf.dso_to_list, "dso_to", stdout);
723 sort_entry__setup_elide(&sort_sym_from, symbol_conf.sym_from_list, "sym_from", stdout);
724 sort_entry__setup_elide(&sort_sym_to, symbol_conf.sym_to_list, "sym_to", stdout);
725 } else {
726 sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
727 sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
728 }
702 729
703 ret = __cmd_report(&report); 730 ret = __cmd_report(&report);
704error: 731error: