Re: [PATCH v6 20/25] perf hists browser: Implement hierarchy output

Jiri Olsa
2016-02-20T23:19:21Z

On Tue, Feb 16, 2016 at 11:08:38PM +0900, Namhyung Kim wrote:
> Implement hierarchy mode in TUI. The output is look like stdio but it
> also supports to fold/unfold children dynamically.
>
> Acked-by: Pekka Enberg <penberg@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/ui/browsers/hists.c | 269 +++++++++++++++++++++++++++++++++++++----
> 1 file changed, 247 insertions(+), 22 deletions(-)
>
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index 857b9beb0aab..d209cf07bd12 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -1260,6 +1260,137 @@ static int hist_browser__show_entry(struct hist_browser *browser,
> return printed;
> }
>
> +static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
> + struct hist_entry *entry,
> + unsigned short row,
> + int level, int nr_sort_keys)
> +{

SNIP

> +
> + hists__for_each_format(entry->hists, fmt) {
> + if (perf_hpp__should_skip(fmt, entry->hists) ||
> + column++ < browser->b.horiz_scroll)
> + continue;
> +
> + if (perf_hpp__is_sort_entry(fmt) ||
> + perf_hpp__is_dynamic_entry(fmt))
> + break;
> +
> + if (current_entry && browser->b.navkeypressed) {
> + ui_browser__set_color(&browser->b,
> + HE_COLORSET_SELECTED);
> + } else {
> + ui_browser__set_color(&browser->b,
> + HE_COLORSET_NORMAL);
> + }
> +
> + if (first) {
> + ui_browser__printf(&browser->b, "%c", folded_sign);
> + width--;
> + first = false;
> + } else {
> + ui_browser__printf(&browser->b, " ");
> + width -= 2;
> + }
> +
> + if (fmt->color) {
> + width -= fmt->color(fmt, &hpp, entry);
> + } else {
> + width -= fmt->entry(fmt, &hpp, entry);
> + ui_browser__printf(&browser->b, "%s", s);
> + }

same as for stdio patch comment, you might want to use
hist_entry__snprintf_alignment in here

jirka