diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-05-28 11:05:20 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-04 10:28:52 -0300 |
commit | e2d88aaa649e65851463426b133d87b61d3accbd (patch) | |
tree | c0cc4ebd2f25f237e668b12f2ed561beba3974a0 /tools/perf/util/map.c | |
parent | 982d410bc6b405a75086236d3c1da1f18c40d6dd (diff) | |
download | linux-e2d88aaa649e65851463426b133d87b61d3accbd.tar.bz2 |
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>
Diffstat (limited to 'tools/perf/util/map.c')
-rw-r--r-- | tools/perf/util/map.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 6ae97eda370b..92abc8e248c5 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -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); |