[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7chc9uyj-gZT0_a6aca6UMqjiXGNiSB8MGUXchg5VGrKrw@mail.gmail.com>
Date: Wed, 13 Dec 2023 14:13:57 -0800
From: Namhyung Kim <namhyung@...nel.org>
To: Ian Rogers <irogers@...gle.com>
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,
Milian Wolff <milian.wolff@...b.com>,
Pablo Galindo <pablogsal@...il.com>,
Fangrui Song <maskray@...gle.com>
Subject: Re: [PATCH 2/3] perf unwind-libdw: Handle JIT-generated DSOs properly
On Tue, Dec 12, 2023 at 10:07 AM Ian Rogers <irogers@...gle.com> wrote:
>
> On Mon, Dec 11, 2023 at 11:05 PM Namhyung Kim <namhyung@...nel.org> wrote:
> >
> > Usually DSOs are mapped from the beginning of the file, so the base
> > address of the DSO can be calculated by map->start - map->pgoff.
> >
> > However, JIT DSOs which are generated by `perf inject -j`, are mapped
> > only the code segment. This makes unwind-libdw code confusing and
> > rejects processing unwinds in the JIT DSOs. It should use the map
> > start address as base for them to fix the confusion.
> >
> > Fixes: 1fe627da3033 ("perf unwind: Take pgoff into account when reporting elf to libdwfl")
> > Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> > ---
> > tools/perf/util/unwind-libdw.c | 21 +++++++++++++++++----
> > 1 file changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
> > index 8554db3fc0d7..6013335a8dae 100644
> > --- a/tools/perf/util/unwind-libdw.c
> > +++ b/tools/perf/util/unwind-libdw.c
> > @@ -46,6 +46,7 @@ static int __report_module(struct addr_location *al, u64 ip,
> > {
> > Dwfl_Module *mod;
> > struct dso *dso = NULL;
> > + Dwarf_Addr base;
> > /*
> > * Some callers will use al->sym, so we can't just use the
> > * cheaper thread__find_map() here.
> > @@ -58,13 +59,25 @@ static int __report_module(struct addr_location *al, u64 ip,
> > if (!dso)
> > return 0;
> >
> > + /*
> > + * The generated JIT DSO files only map the code segment without
> > + * ELF headers. Since JIT codes used to be packed in a memory
> > + * segment, calculating the base address using pgoff falls into
> > + * a different code in another DSO. So just use the map->start
> > + * directly to pick the correct one.
> > + */
> > + if (!strncmp(dso->long_name, "/tmp/jitted-", 12))
>
> Perhaps it would be better to test:
> dso->symtab_type == DSO_BINARY_TYPE__JAVA_JIT
Well.. it's a little different. The JAVA_JIT type files have
"/tmp/perf-" prefix and it's a plain text file (for symbols).
While this is an ELF file generated by `perf inject -j`.
Thanks,
Namhyung
Powered by blists - more mailing lists