On Mon, Nov 26, 2018 at 05:40:54PM +0800, Jin Yao wrote:

SNIP

> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index f96c005..94f62c8 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -13,6 +13,7 @@
>  #include "strlist.h"
>  #include <traceevent/event-parse.h>
>  #include "mem-events.h"
> +#include "annotate.h"
>  #include <linux/kernel.h>
>  
>  regex_t              parent_regex;
> @@ -422,6 +423,47 @@ struct sort_entry sort_srcline_to = {
>       .se_width_idx   = HISTC_SRCLINE_TO,
>  };
>  
> +static int hist_entry__sym_ipc_snprintf(struct hist_entry *he, char *bf,
> +                                     size_t size, unsigned int width)
> +{
> +
> +     struct symbol *sym = he->ms.sym;
> +     struct map *map = he->ms.map;
> +     struct perf_evsel *evsel = hists_to_evsel(he->hists);
> +     struct annotation *notes;
> +     double ipc = 0.0, coverage = 0.0;
> +     char tmp[64];
> +
> +     if (!sym)
> +             return repsep_snprintf(bf, size, "%-*s", width, "-");
> +
> +     if (!sym->annotated &&
> +         symbol__annotate2(sym, map, evsel, &annotation__default_options,
> +                           NULL) < 0) {
> +             return 0;
> +     }
> +
> +     sym->annotated = true;

I don't like this being set in here.. please move it to
symbol__annotate2 or symbol__annotate, not sure which
one of these is the best fit

> +     notes = symbol__annotation(sym);
> +
> +     if (notes->hit_cycles)
> +             ipc = notes->hit_insn / ((double)notes->hit_cycles);
> +
> +     if (notes->total_insn)
> +             coverage = notes->cover_insn * 100.0 /
> +                     ((double)notes->total_insn);

missing { } for multiline code in 'if' condition

thanks,
jirka

Reply via email to