aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/util/map.c
diff options
context:
space:
mode:
authorGravatar Adrian Hunter <adrian.hunter@intel.com> 2023-04-24 08:51:07 +0300
committerGravatar Arnaldo Carvalho de Melo <acme@redhat.com> 2023-05-12 15:21:49 -0300
commitd3b52f71d18513c209465ba65e0c524b9733351b (patch)
tree9220aef7c2583089712c25ce20b2759c2d7c16b0 /tools/perf/util/map.c
parentperf dso: Declare dso const as needed (diff)
downloadlinux-d3b52f71d18513c209465ba65e0c524b9733351b.tar.gz
linux-d3b52f71d18513c209465ba65e0c524b9733351b.tar.bz2
linux-d3b52f71d18513c209465ba65e0c524b9733351b.zip
perf script: Refine printing of dso offset (dsoff)
Print dso offset only for object files, and in those cases force using the dso->long_name if the dso->name starts with '[' or the dso is kcore, in order to avoid special names such as [vdso], or mixing up kcore with vmlinux. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Changbin Du <changbin.du@huawei.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20230424055107.12105-3-adrian.hunter@intel.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.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 8c96ce6bfc51..4d9944bbf5e4 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -431,14 +431,21 @@ size_t map__fprintf(struct map *map, FILE *fp)
map__start(map), map__end(map), map__pgoff(map), dso->name);
}
-size_t map__fprintf_dsoname(struct map *map, FILE *fp)
+static bool prefer_dso_long_name(const struct dso *dso, bool print_off)
+{
+ return dso->long_name &&
+ (symbol_conf.show_kernel_path ||
+ (print_off && (dso->name[0] == '[' || dso__is_kcore(dso))));
+}
+
+static size_t __map__fprintf_dsoname(struct map *map, bool print_off, FILE *fp)
{
char buf[symbol_conf.pad_output_len_dso + 1];
const char *dsoname = "[unknown]";
const struct dso *dso = map ? map__dso(map) : NULL;
if (dso) {
- if (symbol_conf.show_kernel_path && dso->long_name)
+ if (prefer_dso_long_name(dso, print_off))
dsoname = dso->long_name;
else
dsoname = dso->name;
@@ -452,13 +459,21 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)
return fprintf(fp, "%s", dsoname);
}
+size_t map__fprintf_dsoname(struct map *map, FILE *fp)
+{
+ return __map__fprintf_dsoname(map, false, fp);
+}
+
size_t map__fprintf_dsoname_dsoff(struct map *map, bool print_off, u64 addr, FILE *fp)
{
+ const struct dso *dso = map ? map__dso(map) : NULL;
int printed = 0;
+ if (print_off && (!dso || !dso__is_object_file(dso)))
+ print_off = false;
printed += fprintf(fp, " (");
- printed += map__fprintf_dsoname(map, fp);
- if (print_off && map && map__dso(map) && !map__dso(map)->kernel)
+ printed += __map__fprintf_dsoname(map, print_off, fp);
+ if (print_off)
printed += fprintf(fp, "+0x%" PRIx64, addr);
printed += fprintf(fp, ")");