From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: "Georg Müller" <georgmueller@gmx.net>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Ian Rogers" <irogers@google.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
regressions@lists.linux.dev,
"Arnaldo Carvalho de Melo" <acme@redhat.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf probe: read DWARF files from the correct CU
Date: Tue, 11 Jul 2023 22:20:00 +0900 [thread overview]
Message-ID: <20230711222000.d316cf7fd643cb4203ea1204@kernel.org> (raw)
In-Reply-To: <ZK1RyVue7OMXzVl4@kernel.org>
On Tue, 11 Jul 2023 09:57:45 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Em Thu, Jun 15, 2023 at 10:01:37PM +0200, Georg Müller escreveu:
> > After switching from dwarf_decl_file() to die_get_decl_file(), it is not
> > possible to add probes for certain functions of certain binaries:
> >
> > $ perf probe -x /usr/lib/systemd/systemd-logind match_unit_removed
> > A function DIE doesn't have decl_line. Maybe broken DWARF?
> > A function DIE doesn't have decl_line. Maybe broken DWARF?
> > Probe point 'match_unit_removed' not found.
> > Error: Failed to add events.
> >
> > The problem is that die_get_decl_file() uses the wrong CU to search for
> > the file. elfutils commit e1db5cdc9f has some good explanation for this:
> >
> > dwarf_decl_file uses dwarf_attr_integrate to get the DW_AT_decl_file
> > attribute. This means the attribute might come from a different DIE
> > in a different CU. If so, we need to use the CU associated with the
> > attribute, not the original DIE, to resolve the file name.
> >
> > This patch uses the same source of information as elfutils: use attribute
> > DW_AT_decl_file and use this CU to search for the file.
>
> Thanks, applied to the perf-tools branch, that will be submitted for
> Linux v6.5.
Thanks Arnaldo and Georg,
It sounds perfect reason why that happened. I didn't expect the case that
the attribute comes from another CU...
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> - Arnaldo
>
> > Fixes: dc9a5d2ccd5c ("perf probe: Fix to get declared file name from clang DWARF5")
> > Signed-off-by: Georg Müller <georgmueller@gmx.net>
> > Link: https://lore.kernel.org/r/5a00d5a5-7be7-ef8a-4044-9a16249fff25@gmx.net/
> > ---
> > tools/perf/util/dwarf-aux.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> > index b07414409771..137b3ed9897b 100644
> > --- a/tools/perf/util/dwarf-aux.c
> > +++ b/tools/perf/util/dwarf-aux.c
> > @@ -478,8 +478,10 @@ static const char *die_get_file_name(Dwarf_Die *dw_die, int idx)
> > {
> > Dwarf_Die cu_die;
> > Dwarf_Files *files;
> > + Dwarf_Attribute attr_mem;
> >
> > - if (idx < 0 || !dwarf_diecu(dw_die, &cu_die, NULL, NULL) ||
> > + if (idx < 0 || !dwarf_attr_integrate(dw_die, DW_AT_decl_file, &attr_mem) ||
> > + !dwarf_cu_die(attr_mem.cu, &cu_die, NULL, NULL, NULL, NULL, NULL, NULL) ||
> > dwarf_getsrcfiles(&cu_die, &files, NULL) != 0)
> > return NULL;
> >
> > --
> > 2.41.0
> >
>
> --
>
> - Arnaldo
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2023-07-11 13:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 13:48 [PATCH v2 0/3] tools/perf: Fix perf probe crash by clang DWARF5 file Masami Hiramatsu (Google)
2022-11-01 13:48 ` [PATCH v2 1/3] tools/perf: Fix to avoid crashing if DW_AT_decl_file is NULL Masami Hiramatsu (Google)
2022-11-01 13:48 ` [PATCH v2 2/3] tools/perf: Fix to use dwarf_attr_integrate for generic attr accessor Masami Hiramatsu (Google)
2022-11-01 13:48 ` [PATCH v2 3/3] tools/perf: Fix to get declared file name from clang DWARF5 Masami Hiramatsu (Google)
2023-06-09 12:21 ` Georg Müller
2023-06-15 11:42 ` Linux regression tracking #adding (Thorsten Leemhuis)
2023-08-29 13:41 ` Linux regression tracking #update (Thorsten Leemhuis)
2023-06-15 14:02 ` Georg Müller
2023-06-15 20:01 ` [PATCH] perf probe: read DWARF files from the correct CU Georg Müller
2023-06-22 22:04 ` Georg Müller
2023-07-11 12:57 ` Arnaldo Carvalho de Melo
2023-07-11 13:20 ` Masami Hiramatsu [this message]
2023-07-11 14:41 ` Arnaldo Carvalho de Melo
2023-06-28 8:23 ` [PATCH v2 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Georg Müller
2023-06-28 8:23 ` [PATCH v2 1/2] perf probe: add test for " Georg Müller
2023-07-27 17:45 ` Ian Rogers
2023-07-28 14:41 ` Georg Müller
2023-06-28 8:23 ` [PATCH v2 2/2] perf probe: read DWARF files from the correct CU Georg Müller
2023-06-28 8:41 ` [PATCH v2 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Linux regression tracking (Thorsten Leemhuis)
2022-11-02 0:03 ` [PATCH v2 0/3] tools/perf: Fix perf probe crash by clang DWARF5 file Namhyung Kim
2022-11-03 12:31 ` Arnaldo Carvalho de Melo
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=20230711222000.d316cf7fd643cb4203ea1204@kernel.org \
--to=mhiramat@kernel.org \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=georgmueller@gmx.net \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=regressions@lists.linux.dev \
/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).