linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	 Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	 linux-perf-users@vger.kernel.org,
	 Linus Torvalds <torvalds@linux-foundation.org>,
	Stephane Eranian <eranian@google.com>,
	 Masami Hiramatsu <mhiramat@kernel.org>,
	linux-toolchains@vger.kernel.org,
	 linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH 04/14] perf map: Add map__objdump_2rip()
Date: Tue, 6 Feb 2024 15:04:37 -0800	[thread overview]
Message-ID: <CAM9d7chvEw6r8_7agxOpWxufTo+dLaNForSFFShCFGd9KDBtoA@mail.gmail.com> (raw)
In-Reply-To: <CAP-5=fU=P-ib+n+OfqJAbm8gS2RY-W-KcBskoSHkC+aCmXYcXQ@mail.gmail.com>

Hi Ian,

On Fri, Feb 2, 2024 at 5:42 PM Ian Rogers <irogers@google.com> wrote:
>
> On Fri, Feb 2, 2024 at 2:05 PM Namhyung Kim <namhyung@kernel.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?

AFAIK the objdump addresses are DSO-relative and rip is to map.
They are mostly the same but sometimes different due to kASLR
for the kernel.

>
> > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.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.
> > +        */

Hmm.. This comment is not true anymore.  Will remove
in other places too.

Thanks,
Namhyung


> > +       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
> >

  reply	other threads:[~2024-02-06 23:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 22:04 [PATCHSET 00/14] perf tools: Remaining bits of data type profiling (v5) Namhyung Kim
2024-02-02 22:04 ` [PATCH 01/14] perf dwarf-aux: Add die_collect_vars() Namhyung Kim
2024-02-02 22:04 ` [PATCH 02/14] perf dwarf-aux: Handle type transfer for memory access Namhyung Kim
2024-02-02 22:04 ` [PATCH 03/14] perf annotate-data: Introduce struct data_loc_info Namhyung Kim
2024-02-02 22:04 ` [PATCH 04/14] perf map: Add map__objdump_2rip() Namhyung Kim
2024-02-03  1:41   ` Ian Rogers
2024-02-06 23:04     ` Namhyung Kim [this message]
2024-02-06 23:33       ` Ian Rogers
2024-02-07 19:04         ` Namhyung Kim
2024-02-07 19:56           ` Ian Rogers
2024-02-07 20:43             ` Namhyung Kim
2024-02-02 22:04 ` [PATCH 05/14] perf annotate: Add annotate_get_basic_blocks() Namhyung Kim
2024-02-02 22:04 ` [PATCH 06/14] perf annotate-data: Maintain variable type info Namhyung Kim
2024-02-03  2:44   ` Ian Rogers
2024-02-06 23:06     ` Namhyung Kim
2024-02-02 22:04 ` [PATCH 07/14] perf annotate-data: Add update_insn_state() Namhyung Kim
2024-02-03  2:49   ` Ian Rogers
2024-02-06 23:07     ` Namhyung Kim
2024-02-02 22:04 ` [PATCH 08/14] perf annotate-data: Handle global variable access Namhyung Kim
2024-02-02 22:04 ` [PATCH 09/14] perf annotate-data: Handle call instructions Namhyung Kim
2024-02-03  3:09   ` Ian Rogers
2024-02-06 23:17     ` Namhyung Kim
2024-02-06 23:36       ` Ian Rogers
     [not found]         ` <CA+JHD91q4vA5z0g4AMPJpXV-+_ppmg6+jVu=YWcxY4hARn5LRw@mail.gmail.com>
2024-02-07  1:29           ` Namhyung Kim
2024-02-02 22:04 ` [PATCH 10/14] perf annotate-data: Implement instruction tracking Namhyung Kim
2024-02-02 22:04 ` [PATCH 11/14] perf annotate: Parse x86 segment register location Namhyung Kim
2024-02-02 22:04 ` [PATCH 12/14] perf annotate-data: Handle this-cpu variables in kernel Namhyung Kim
2024-02-02 22:04 ` [PATCH 13/14] perf annotate-data: Track instructions with a this-cpu variable Namhyung Kim
2024-02-02 22:04 ` [PATCH 14/14] perf annotate-data: Add stack canary type Namhyung Kim
2024-02-03  3:21   ` Ian Rogers
2024-02-06 23:18     ` Namhyung Kim
2024-02-06 23:40       ` Ian Rogers
2024-02-07 19:08         ` Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2024-02-16 23:54 [PATCHSET 00/14] perf tools: Remaining bits of data type profiling (v6) Namhyung Kim
2024-02-16 23:54 ` [PATCH 04/14] perf map: Add map__objdump_2rip() Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM9d7chvEw6r8_7agxOpWxufTo+dLaNForSFFShCFGd9KDBtoA@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).