perf srcline: Introduce map__srcline() to make code more compact
Replacing a common open coded sequence. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-2d7d1nzd3ksqornloqeer99r@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -415,16 +415,20 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)
|
||||
return fprintf(fp, "%s", dsoname);
|
||||
}
|
||||
|
||||
char *map__srcline(struct map *map, u64 addr, struct symbol *sym)
|
||||
{
|
||||
if (map == NULL)
|
||||
return SRCLINE_UNKNOWN;
|
||||
return get_srcline(map->dso, map__rip_2objdump(map, addr), sym, true, true, addr);
|
||||
}
|
||||
|
||||
int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix,
|
||||
FILE *fp)
|
||||
{
|
||||
char *srcline;
|
||||
int ret = 0;
|
||||
|
||||
if (map && map->dso) {
|
||||
srcline = get_srcline(map->dso,
|
||||
map__rip_2objdump(map, addr), NULL,
|
||||
true, true, addr);
|
||||
char *srcline = map__srcline(map, addr, NULL);
|
||||
if (srcline != SRCLINE_UNKNOWN)
|
||||
ret = fprintf(fp, "%s%s", prefix, srcline);
|
||||
free_srcline(srcline);
|
||||
|
Reference in New Issue
Block a user