Re: [PATCH 3/8] perf, tools: Enable printing the srcline in the history

From: Jiri Olsa
Date: Mon Oct 20 2014 - 13:57:38 EST


On Fri, Sep 26, 2014 at 04:37:11PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

SNIP

> - if (chain->ms.sym)
> - ret += fprintf(fp, " %s\n", chain->ms.sym->name);
> - else
> - ret += fprintf(fp, " %p\n",
> - (void *)(long)chain->ip);
> + ret += fprintf(fp, " %s\n", callchain_list__sym_name(chain,
> + bf, sizeof(bf), false));
> }
>
> return ret;
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index 265457c..b7ee210 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -655,3 +655,32 @@ int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *
> out:
> return 1;
> }
> +
> +char *callchain_list__sym_name(struct callchain_list *cl,
> + char *bf, size_t bfsize, bool show_dso)
> +{
> + int printed;
> +
> + if (cl->ms.sym) {
> + if (callchain_param.key == CCKEY_ADDRESS &&
> + cl->ms.map && !cl->srcline)
> + cl->srcline = get_srcline(cl->ms.map->dso,
> + map__rip_2objdump(cl->ms.map,
> + cl->ip));
> + if (cl->srcline)
> + printed = scnprintf(bf, bfsize, "%s %s",
> + cl->ms.sym->name, cl->srcline);
> + else
> + printed = scnprintf(bf, bfsize, "%s",
> + cl->ms.sym->name);
> + } else
> + printed = scnprintf(bf, bfsize, "%#" PRIx64, cl->ip);
> +
> + if (show_dso)
> + scnprintf(bf + printed, bfsize - printed, " %s",
> + cl->ms.map ?
> + cl->ms.map->dso->short_name :
> + "unknown");
> +
> + return bf;

could you please get the callchain_list__sym_name factoring code
separated of the new changes you introduce?

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/