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

Namhyung Kim
2016-02-21T18:09:29Z

On Sun, Feb 21, 2016 at 12:18:56AM +0100, Jiri Olsa wrote:
> 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

Ah missed that, will change.

Btw it seems it's not strictly needed here since the hierarchy mode
makes each column as the last though. But I agree that it's a general
change and can be applied here as well.

Thanks,
Namhyung