Re: [PATCH] perf, tools: Support srccode output

From: Jiri Olsa
Date: Sun May 07 2017 - 17:54:52 EST


On Fri, May 05, 2017 at 04:00:29PM -0700, Andi Kleen wrote:

SNIP

>
> +int map__fprintf_srccode(struct map *map, u64 addr,
> + const char *prefix, FILE *fp)
> +{
> + char *srcline;
> + int ret = 0;
> +
> + if (map && map->dso) {
> + srcline_full_filename = true;
> + srcline = get_srcline(map->dso,
> + map__rip_2objdump(map, addr), NULL,
> + true, true);
> + if (srcline != SRCLINE_UNKNOWN) {
> + char srcfile[1024];
> + int line, len;
> + char *srccode;
> + if (sscanf(srcline, "%1023[^:]:%d", srcfile, &line)

so get_srcline formats srcline and you parse it out back in here,
I think it'd be better to factor __get_srcline and get the file
and line directly

thanks,
jirka