aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <jolsa@kernel.org>2014-06-14 09:44:52 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-07-07 11:36:55 -0400
commit025bf7ea0aca26df4a4b28f0b12afe1aaf91e4bd (patch)
treeaf0a12b7d768ba513809c25f208798eaaf465f9a /tools/perf/ui
parent357cfff1c2173b7aedc0e521a2146b78396171e0 (diff)
perf hists browser: Add support for showing columns header
Open up space to show a one-line header text whenever 'H' is pressed, hide it on another key press. Follow up patch will format this line from the set of headers used. Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-m894d6qk30h3qofw4k8neq4q@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r--tools/perf/ui/browsers/hists.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index ef7abf896f5a..2be71bf17b71 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -26,6 +26,7 @@ struct hist_browser {
26 struct map_symbol *selection; 26 struct map_symbol *selection;
27 int print_seq; 27 int print_seq;
28 bool show_dso; 28 bool show_dso;
29 bool show_headers;
29 float min_pcnt; 30 float min_pcnt;
30 u64 nr_non_filtered_entries; 31 u64 nr_non_filtered_entries;
31 u64 nr_callchain_rows; 32 u64 nr_callchain_rows;
@@ -56,6 +57,21 @@ static u32 hist_browser__nr_entries(struct hist_browser *hb)
56 return nr_entries + hb->nr_callchain_rows; 57 return nr_entries + hb->nr_callchain_rows;
57} 58}
58 59
60static void hist_browser__update_rows(struct hist_browser *hb)
61{
62 struct ui_browser *browser = &hb->b;
63 u16 header_offset = hb->show_headers ? 1 : 0, index_row;
64
65 browser->rows = browser->height - header_offset;
66 /*
67 * Verify if we were at the last line and that line isn't
68 * visibe because we now show the header line(s).
69 */
70 index_row = browser->index - browser->top_idx;
71 if (index_row >= browser->rows)
72 browser->index -= index_row - browser->rows + 1;
73}
74
59static void hist_browser__refresh_dimensions(struct ui_browser *browser) 75static void hist_browser__refresh_dimensions(struct ui_browser *browser)
60{ 76{
61 struct hist_browser *hb = container_of(browser, struct hist_browser, b); 77 struct hist_browser *hb = container_of(browser, struct hist_browser, b);
@@ -69,11 +85,14 @@ static void hist_browser__refresh_dimensions(struct ui_browser *browser)
69 * changeset. 85 * changeset.
70 */ 86 */
71 ui_browser__refresh_dimensions(browser); 87 ui_browser__refresh_dimensions(browser);
88 hist_browser__update_rows(hb);
72} 89}
73 90
74static void hist_browser__gotorc(struct hist_browser *browser, int row, int column) 91static void hist_browser__gotorc(struct hist_browser *browser, int row, int column)
75{ 92{
76 ui_browser__gotorc(&browser->b, row, column); 93 u16 header_offset = browser->show_headers ? 1 : 0;
94
95 ui_browser__gotorc(&browser->b, row + header_offset, column);
77} 96}
78 97
79static void hist_browser__reset(struct hist_browser *browser) 98static void hist_browser__reset(struct hist_browser *browser)
@@ -421,6 +440,10 @@ static int hist_browser__run(struct hist_browser *browser,
421 /* Expand the whole world. */ 440 /* Expand the whole world. */
422 hist_browser__set_folding(browser, true); 441 hist_browser__set_folding(browser, true);
423 break; 442 break;
443 case 'H':
444 browser->show_headers = !browser->show_headers;
445 hist_browser__update_rows(browser);
446 break;
424 case K_ENTER: 447 case K_ENTER:
425 if (hist_browser__toggle_fold(browser)) 448 if (hist_browser__toggle_fold(browser))
426 break; 449 break;
@@ -799,6 +822,13 @@ static int hist_browser__show_entry(struct hist_browser *browser,
799 return printed; 822 return printed;
800} 823}
801 824
825static void hist_browser__show_headers(struct hist_browser *browser)
826{
827 ui_browser__gotorc(&browser->b, 0, 0);
828 ui_browser__set_color(&browser->b, HE_COLORSET_ROOT);
829 slsmg_write_nstring(" ", browser->b.width + 1);
830}
831
802static void ui_browser__hists_init_top(struct ui_browser *browser) 832static void ui_browser__hists_init_top(struct ui_browser *browser)
803{ 833{
804 if (browser->top == NULL) { 834 if (browser->top == NULL) {
@@ -812,9 +842,15 @@ static void ui_browser__hists_init_top(struct ui_browser *browser)
812static unsigned int hist_browser__refresh(struct ui_browser *browser) 842static unsigned int hist_browser__refresh(struct ui_browser *browser)
813{ 843{
814 unsigned row = 0; 844 unsigned row = 0;
845 u16 header_offset = 0;
815 struct rb_node *nd; 846 struct rb_node *nd;
816 struct hist_browser *hb = container_of(browser, struct hist_browser, b); 847 struct hist_browser *hb = container_of(browser, struct hist_browser, b);
817 848
849 if (hb->show_headers) {
850 hist_browser__show_headers(hb);
851 header_offset = 1;
852 }
853
818 ui_browser__hists_init_top(browser); 854 ui_browser__hists_init_top(browser);
819 855
820 for (nd = browser->top; nd; nd = rb_next(nd)) { 856 for (nd = browser->top; nd; nd = rb_next(nd)) {
@@ -833,7 +869,7 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
833 break; 869 break;
834 } 870 }
835 871
836 return row; 872 return row + header_offset;
837} 873}
838 874
839static struct rb_node *hists__filter_entries(struct rb_node *nd, 875static struct rb_node *hists__filter_entries(struct rb_node *nd,
@@ -1205,6 +1241,7 @@ static struct hist_browser *hist_browser__new(struct hists *hists)
1205 browser->b.refresh_dimensions = hist_browser__refresh_dimensions; 1241 browser->b.refresh_dimensions = hist_browser__refresh_dimensions;
1206 browser->b.seek = ui_browser__hists_seek; 1242 browser->b.seek = ui_browser__hists_seek;
1207 browser->b.use_navkeypressed = true; 1243 browser->b.use_navkeypressed = true;
1244 browser->show_headers = false;
1208 } 1245 }
1209 1246
1210 return browser; 1247 return browser;
@@ -1434,6 +1471,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1434 "d Zoom into current DSO\n" \ 1471 "d Zoom into current DSO\n" \
1435 "E Expand all callchains\n" \ 1472 "E Expand all callchains\n" \
1436 "F Toggle percentage of filtered entries\n" \ 1473 "F Toggle percentage of filtered entries\n" \
1474 "H Display column headers\n" \
1437 1475
1438 /* help messages are sorted by lexical order of the hotkey */ 1476 /* help messages are sorted by lexical order of the hotkey */
1439 const char report_help[] = HIST_BROWSER_HELP_COMMON 1477 const char report_help[] = HIST_BROWSER_HELP_COMMON