diff options
author | 2023-04-18 11:18:24 +0800 | |
---|---|---|
committer | 2023-05-12 15:21:48 -0300 | |
commit | 2b433fadb1db6f64a9edf22de668118de7e287ed (patch) | |
tree | d8b477b3ef940be15390998cab3a52cdb55ca31a /tools/perf/util/map.c | |
parent | perf tools riscv: Add support for riscv lookup_binutils_path (diff) | |
download | linux-2b433fadb1db6f64a9edf22de668118de7e287ed.tar.gz linux-2b433fadb1db6f64a9edf22de668118de7e287ed.tar.bz2 linux-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/util/map.c')
-rw-r--r-- | tools/perf/util/map.c | 13 |
1 files changed, 13 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) |