Commit 2b433fad authored by Changbin Du's avatar Changbin Du Committed by Arnaldo Carvalho de Melo

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: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarChangbin Du <changbin.du@huawei.com>
Acked-by: default avatarAdrian 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2d4c5397
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment