Re: [PATCH v6 16/25] perf ui/stdio: Implement hierarchy output mode

From: Jiri Olsa
Date: Sat Feb 20 2016 - 18:19:17 EST


On Tue, Feb 16, 2016 at 11:08:34PM +0900, Namhyung Kim wrote:

SNIP

> +static int hist_entry__hierarchy_fprintf(struct hist_entry *he,
> + struct perf_hpp *hpp,
> + int nr_sort_key, struct hists *hists,
> + FILE *fp)
> +{
> + const char *sep = symbol_conf.field_sep;
> + struct perf_hpp_fmt *fmt;
> + char *buf = hpp->buf;
> + int ret, printed = 0;
> + bool first = true;
> +
> + if (symbol_conf.exclude_other && !he->parent)
> + return 0;
> +
> + ret = scnprintf(hpp->buf, hpp->size, "%*s", he->depth * HIERARCHY_INDENT, "");
> + advance_hpp(hpp, ret);
> +
> + hists__for_each_format(he->hists, fmt) {
> + if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt))
> + break;
> +
> + /*
> + * If there's no field_sep, we still need
> + * to display initial ' '.
> + */
> + if (!sep || !first) {
> + ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
> + advance_hpp(hpp, ret);
> + } else
> + first = false;
> +
> + if (perf_hpp__use_color() && fmt->color)
> + ret = fmt->color(fmt, hpp, he);
> + else
> + ret = fmt->entry(fmt, hpp, he);
> +
> + advance_hpp(hpp, ret);

there's new hist_entry__snprintf_alignment function for
proper alignment now used in hist_entry__hierarchy_fprintf

you might wat to use it in here as well

jirka