From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>, Andi Kleen <andi@firstfloor.org>
Subject: [PATCH v2 2/2] perf hists browser: Support horizontal scrolling for callchains
Date: Sun, 9 Aug 2015 17:21:02 +0900 [thread overview]
Message-ID: <1439108462-16391-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1439108462-16391-1-git-send-email-namhyung@kernel.org>
In the previous patch, horizontal scrolling was added to TUI browser.
However it lacks support for callchains. This patch adds it.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/browsers/hists.c | 46 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 41 insertions(+), 5 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 9f6e960be3a6..10af42f5283e 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -526,6 +526,7 @@ struct callchain_print_arg {
/* for file dump */
FILE *fp;
int printed;
+ int skip_cols;
};
typedef void (*print_callchain_entry_fn)(struct hist_browser *browser,
@@ -534,6 +535,30 @@ typedef void (*print_callchain_entry_fn)(struct hist_browser *browser,
unsigned short row,
struct callchain_print_arg *arg);
+static int callchain_print_skip(struct callchain_print_arg *arg,
+ const char *str, int width)
+{
+ if (arg->skip_cols) {
+ int len = strlen(str);
+
+ if (width <= arg->skip_cols) {
+ arg->skip_cols -= width;
+ return 0;
+ }
+
+ if (arg->skip_cols < len)
+ str += arg->skip_cols;
+ else
+ str = " ";
+
+ width -= arg->skip_cols;
+ arg->skip_cols = 0;
+ }
+
+ slsmg_write_nstring(str, width);
+ return width;
+}
+
static void hist_browser__show_callchain_entry(struct hist_browser *browser,
struct callchain_list *chain,
const char *str, int offset,
@@ -543,9 +568,10 @@ static void hist_browser__show_callchain_entry(struct hist_browser *browser,
int color, width;
char folded_sign = callchain_list__folded(chain);
bool show_annotated = browser->show_dso && chain->ms.sym && symbol__annotation(chain->ms.sym)->src;
+ char buf[2] = { folded_sign, 0 };
color = HE_COLORSET_NORMAL;
- width = browser->b.width - (offset + 2);
+ width = browser->b.width;
if (ui_browser__is_current_entry(&browser->b, row)) {
browser->selection = &chain->ms;
color = HE_COLORSET_SELECTED;
@@ -554,10 +580,17 @@ static void hist_browser__show_callchain_entry(struct hist_browser *browser,
ui_browser__set_color(&browser->b, color);
hist_browser__gotorc(browser, row, 0);
- slsmg_write_nstring(" ", offset);
- slsmg_printf("%c", folded_sign);
- ui_browser__write_graph(&browser->b, show_annotated ? SLSMG_RARROW_CHAR : ' ');
- slsmg_write_nstring(str, width);
+ width -= callchain_print_skip(arg, " ", offset);
+ width -= callchain_print_skip(arg, buf, 1);
+ if (arg->skip_cols > 0)
+ arg->skip_cols--;
+ else {
+ ui_browser__write_graph(&browser->b,
+ show_annotated ? SLSMG_RARROW_CHAR : ' ');
+ width--;
+ }
+ width -= callchain_print_skip(arg, str, width);
+ slsmg_write_nstring("", width);
}
static void hist_browser__fprintf_callchain_entry(struct hist_browser *b __maybe_unused,
@@ -642,6 +675,7 @@ static int hist_browser__show_callchain(struct hist_browser *browser,
str = alloc_str;
}
+ arg->skip_cols = browser->skip_cols;
print(browser, chain, str, offset + extra_offset, row, arg);
free(alloc_str);
@@ -661,6 +695,7 @@ do_next:
else
new_total = total;
+ arg->skip_cols = browser->skip_cols;
row += hist_browser__show_callchain(browser, &child->rb_root,
new_level, row, new_total,
print, arg, is_output_full);
@@ -867,6 +902,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
struct callchain_print_arg arg = {
.row_offset = row_offset,
.is_current_entry = current_entry,
+ .skip_cols = browser->skip_cols,
};
if (callchain_param.mode == CHAIN_GRAPH_REL) {
--
2.5.0
next prev parent reply other threads:[~2015-08-09 8:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-09 8:21 [PATCH v2 1/2] perf hists browser: Support horizontal scrolling with '<' and '>' key Namhyung Kim
2015-08-09 8:21 ` Namhyung Kim [this message]
2015-08-09 9:30 ` Jiri Olsa
2015-08-09 10:35 ` Namhyung Kim
2015-08-09 11:21 ` Jiri Olsa
2015-08-10 15:50 ` Arnaldo Carvalho de Melo
2015-08-10 22:46 ` Jiri Olsa
2015-08-10 22:58 ` Arnaldo Carvalho de Melo
2015-08-10 23:02 ` Jiri Olsa
2015-08-10 23:14 ` Arnaldo Carvalho de Melo
2015-08-10 23:15 ` Jiri Olsa
2015-08-11 20:59 ` Arnaldo Carvalho de Melo
2015-08-12 5:41 ` Namhyung Kim
2015-08-12 9:15 ` Jiri Olsa
2015-08-12 13:17 ` Arnaldo Carvalho de Melo
2015-08-11 2:05 ` Namhyung Kim
2015-08-11 2:00 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439108462-16391-2-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®