summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorChangbin Du <changbin.du@huawei.com>2023-04-18 11:18:24 +0800
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-05-12 15:21:48 -0300
commit2b433fadb1db6f64a9edf22de668118de7e287ed (patch)
treed8b477b3ef940be15390998cab3a52cdb55ca31a /tools/perf
parent2d4c53973f014983d59a7aa4e980007db315fee0 (diff)
downloadlinux-stable-2b433fadb1db6f64a9edf22de668118de7e287ed.tar.gz
linux-stable-2b433fadb1db6f64a9edf22de668118de7e287ed.tar.bz2
linux-stable-2b433fadb1db6f64a9edf22de668118de7e287ed.zip
perf map: Add helper map__fprintf_dsoname_dsoff
This adds a helper function map__fprintf_dsoname_dsoff() to print dsoname with optional dso offset. Suggested-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Changbin Du <changbin.du@huawei.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Hui Wang <hw.huiwang@huawei.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20230418031825.1262579-3-changbin.du@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/map.c13
-rw-r--r--tools/perf/util/map.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index b7f890950909..8c96ce6bfc51 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -452,6 +452,19 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)
return fprintf(fp, "%s", dsoname);
}
+size_t map__fprintf_dsoname_dsoff(struct map *map, bool print_off, u64 addr, FILE *fp)
+{
+ int printed = 0;
+
+ printed += fprintf(fp, " (");
+ printed += map__fprintf_dsoname(map, fp);
+ if (print_off && map && map__dso(map) && !map__dso(map)->kernel)
+ printed += fprintf(fp, "+0x%" PRIx64, addr);
+ printed += fprintf(fp, ")");
+
+ return printed;
+}
+
char *map__srcline(struct map *map, u64 addr, struct symbol *sym)
{
if (map == NULL)
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 823ab7fc0acf..66a87b3d9965 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -194,6 +194,7 @@ static inline void __map__zput(struct map **map)
size_t map__fprintf(struct map *map, FILE *fp);
size_t map__fprintf_dsoname(struct map *map, FILE *fp);
+size_t map__fprintf_dsoname_dsoff(struct map *map, bool print_off, u64 addr, FILE *fp);
char *map__srcline(struct map *map, u64 addr, struct symbol *sym);
int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix,
FILE *fp);