aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-08-11 16:22:43 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-10-05 16:59:49 -0400
commitc6c3c02dea4034431110923ffd8e296ebfbdbe1b (patch)
treefae4a8279f9fc2b8b5506ca901086b1e2bb4ece4 /tools
parentfaae6f690eecb82b6d9d9f2112f5b51ac37d4acb (diff)
perf hists browser: Implement horizontal scrolling
Do it using the recently introduced ui_brower scrolling mode, setting ui_browser.columns to the number of sort columns and then, when rendering each line, skipping as many initial columns as the user pressed the right arrow. As the user presses the left arrow, the ui_browser code will remove the scrolling counter and the left scrolling takes place. The right arrow key was an alias for ENTER, so people used to press it may get a bit annoyed at first, sorry! Ditto for ESC and the left key. Callchains can be left as is or we can, when rendering the Symbol column, store the at what position on the screen it is and then using ui_browser__gotorc() to print it from there, i.e. the callchain would move around with the symbol. Leaving it as is, i.e. at a fixed position, close to the left, saves precious screen real state for it, so I'm inclined to leave it as is now. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: Chandler Carruth <chandlerc@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-ccqq9sabgfge5dwbqjwh71ij@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/ui/browsers/hists.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a4e9b370c037..9b7346a881cf 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -784,11 +784,12 @@ static int hist_browser__show_entry(struct hist_browser *browser,
784 .size = sizeof(s), 784 .size = sizeof(s),
785 .ptr = &arg, 785 .ptr = &arg,
786 }; 786 };
787 int column = 0;
787 788
788 hist_browser__gotorc(browser, row, 0); 789 hist_browser__gotorc(browser, row, 0);
789 790
790 perf_hpp__for_each_format(fmt) { 791 perf_hpp__for_each_format(fmt) {
791 if (perf_hpp__should_skip(fmt)) 792 if (perf_hpp__should_skip(fmt) || column++ < browser->b.horiz_scroll)
792 continue; 793 continue;
793 794
794 if (current_entry && browser->b.navkeypressed) { 795 if (current_entry && browser->b.navkeypressed) {
@@ -861,14 +862,16 @@ static int advance_hpp_check(struct perf_hpp *hpp, int inc)
861 return hpp->size <= 0; 862 return hpp->size <= 0;
862} 863}
863 864
864static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists) 865static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *buf, size_t size)
865{ 866{
867 struct hists *hists = browser->hists;
866 struct perf_hpp dummy_hpp = { 868 struct perf_hpp dummy_hpp = {
867 .buf = buf, 869 .buf = buf,
868 .size = size, 870 .size = size,
869 }; 871 };
870 struct perf_hpp_fmt *fmt; 872 struct perf_hpp_fmt *fmt;
871 size_t ret = 0; 873 size_t ret = 0;
874 int column = 0;
872 875
873 if (symbol_conf.use_callchain) { 876 if (symbol_conf.use_callchain) {
874 ret = scnprintf(buf, size, " "); 877 ret = scnprintf(buf, size, " ");
@@ -877,7 +880,7 @@ static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists)
877 } 880 }
878 881
879 perf_hpp__for_each_format(fmt) { 882 perf_hpp__for_each_format(fmt) {
880 if (perf_hpp__should_skip(fmt)) 883 if (perf_hpp__should_skip(fmt) || column++ < browser->b.horiz_scroll)
881 continue; 884 continue;
882 885
883 ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists)); 886 ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
@@ -896,7 +899,7 @@ static void hist_browser__show_headers(struct hist_browser *browser)
896{ 899{
897 char headers[1024]; 900 char headers[1024];
898 901
899 hists__scnprintf_headers(headers, sizeof(headers), browser->hists); 902 hists_browser__scnprintf_headers(browser, headers, sizeof(headers));
900 ui_browser__gotorc(&browser->b, 0, 0); 903 ui_browser__gotorc(&browser->b, 0, 0);
901 ui_browser__set_color(&browser->b, HE_COLORSET_ROOT); 904 ui_browser__set_color(&browser->b, HE_COLORSET_ROOT);
902 ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1); 905 ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1);
@@ -1806,8 +1809,17 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1806 memset(options, 0, sizeof(options)); 1809 memset(options, 0, sizeof(options));
1807 memset(actions, 0, sizeof(actions)); 1810 memset(actions, 0, sizeof(actions));
1808 1811
1809 perf_hpp__for_each_format(fmt) 1812 perf_hpp__for_each_format(fmt) {
1810 perf_hpp__reset_width(fmt, hists); 1813 perf_hpp__reset_width(fmt, hists);
1814 /*
1815 * This is done just once, and activates the horizontal scrolling
1816 * code in the ui_browser code, it would be better to have a the
1817 * counter in the perf_hpp code, but I couldn't find doing it here
1818 * works, FIXME by setting this in hist_browser__new, for now, be
1819 * clever 8-)
1820 */
1821 ++browser->b.columns;
1822 }
1811 1823
1812 if (symbol_conf.col_width_list_str) 1824 if (symbol_conf.col_width_list_str)
1813 perf_hpp__set_user_width(symbol_conf.col_width_list_str); 1825 perf_hpp__set_user_width(symbol_conf.col_width_list_str);