[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fU=P-ib+n+OfqJAbm8gS2RY-W-KcBskoSHkC+aCmXYcXQ@mail.gmail.com>
Date: Fri, 2 Feb 2024 17:41:55 -0800
From: Ian Rogers <irogers@...gle.com>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>, Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
linux-perf-users@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>, Stephane Eranian <eranian@...gle.com>,
Masami Hiramatsu <mhiramat@...nel.org>, linux-toolchains@...r.kernel.org,
linux-trace-devel@...r.kernel.org
Subject: Re: [PATCH 04/14] perf map: Add map__objdump_2rip()
On Fri, Feb 2, 2024 at 2:05 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> Sometimes we want to convert an address in objdump output to
> map-relative address to match with a sample data. Let's add
> map__objdump_2rip() for that.
Hi Namhyung,
I think the naming can be better here. Aren't the objdump addresses
DSO relative offsets? Is the relative IP relative to the map or the
DSO?
Thanks,
Ian
> Cc: Adrian Hunter <adrian.hunter@...el.com>
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> ---
> tools/perf/util/map.c | 20 ++++++++++++++++++++
> tools/perf/util/map.h | 3 +++
> 2 files changed, 23 insertions(+)
>
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index 54c67cb7ecef..66542864b7b5 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -594,6 +594,26 @@ u64 map__objdump_2mem(struct map *map, u64 ip)
> return ip + map__reloc(map);
> }
>
> +u64 map__objdump_2rip(struct map *map, u64 ip)
> +{
> + const struct dso *dso = map__dso(map);
> +
> + if (!dso->adjust_symbols)
> + return ip;
> +
> + if (dso->rel)
> + return ip + map__pgoff(map);
> +
> + /*
> + * kernel modules also have DSO_TYPE_USER in dso->kernel,
> + * but all kernel modules are ET_REL, so won't get here.
> + */
> + if (dso->kernel == DSO_SPACE__USER)
> + return ip - dso->text_offset;
> +
> + return map__map_ip(map, ip + map__reloc(map));
> +}
> +
> bool map__contains_symbol(const struct map *map, const struct symbol *sym)
> {
> u64 ip = map__unmap_ip(map, sym->start);
> diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
> index 49756716cb13..65e2609fa1b1 100644
> --- a/tools/perf/util/map.h
> +++ b/tools/perf/util/map.h
> @@ -132,6 +132,9 @@ u64 map__rip_2objdump(struct map *map, u64 rip);
> /* objdump address -> memory address */
> u64 map__objdump_2mem(struct map *map, u64 ip);
>
> +/* objdump address -> rip */
> +u64 map__objdump_2rip(struct map *map, u64 ip);
> +
> struct symbol;
> struct thread;
>
> --
> 2.43.0.594.gd9cf4e227d-goog
>
Powered by blists - more mailing lists