public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Jan Kratochvil <jan.kratochvil@redhat.com>,
	Jiri Olsa <jolsa@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Ian Rogers <irogers@google.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	"Tommi Rantala" <tommi.t.rantala@nokia.com>
Subject: [PATCH 5.10 7/9] perf unwind: Fix separate debug info files when using elfutils libdws unwinder
Date: Thu, 27 May 2021 17:12:59 +0200	[thread overview]
Message-ID: <20210527151139.473431614@linuxfoundation.org> (raw)
In-Reply-To: <20210527151139.242182390@linuxfoundation.org>

From: Jan Kratochvil <jan.kratochvil@redhat.com>

commit bf53fc6b5f415cddc7118091cb8fd6a211b2320d upstream.

elfutils needs to be provided main binary and separate debug info file
respectively. Providing separate debug info file instead of the main
binary is not sufficient.

One needs to try both supplied filename and its possible cache by its
build-id depending on the use case.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: "Tommi Rantala" <tommi.t.rantala@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 tools/perf/util/unwind-libdw.c |   32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -20,10 +20,24 @@
 
 static char *debuginfo_path;
 
+static int __find_debuginfo(Dwfl_Module *mod __maybe_unused, void **userdata,
+			    const char *modname __maybe_unused, Dwarf_Addr base __maybe_unused,
+			    const char *file_name, const char *debuglink_file __maybe_unused,
+			    GElf_Word debuglink_crc __maybe_unused, char **debuginfo_file_name)
+{
+	const struct dso *dso = *userdata;
+
+	assert(dso);
+	if (dso->symsrc_filename && strcmp (file_name, dso->symsrc_filename))
+		*debuginfo_file_name = strdup(dso->symsrc_filename);
+	return -1;
+}
+
 static const Dwfl_Callbacks offline_callbacks = {
-	.find_debuginfo		= dwfl_standard_find_debuginfo,
+	.find_debuginfo		= __find_debuginfo,
 	.debuginfo_path		= &debuginfo_path,
 	.section_address	= dwfl_offline_section_address,
+	// .find_elf is not set as we use dwfl_report_elf() instead.
 };
 
 static int __report_module(struct addr_location *al, u64 ip,
@@ -46,16 +60,24 @@ static int __report_module(struct addr_l
 	mod = dwfl_addrmodule(ui->dwfl, ip);
 	if (mod) {
 		Dwarf_Addr s;
+		void **userdatap;
 
-		dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL);
+		dwfl_module_info(mod, &userdatap, &s, NULL, NULL, NULL, NULL, NULL);
+		*userdatap = dso;
 		if (s != al->map->start - al->map->pgoff)
 			mod = 0;
 	}
 
 	if (!mod)
-		mod = dwfl_report_elf(ui->dwfl, dso->short_name,
-				      (dso->symsrc_filename ? dso->symsrc_filename : dso->long_name), -1, al->map->start - al->map->pgoff,
-				      false);
+		mod = dwfl_report_elf(ui->dwfl, dso->short_name, dso->long_name, -1,
+				      al->map->start - al->map->pgoff, false);
+	if (!mod) {
+		char filename[PATH_MAX];
+
+		if (dso__build_id_filename(dso, filename, sizeof(filename), false))
+			mod = dwfl_report_elf(ui->dwfl, dso->short_name, filename, -1,
+					      al->map->start - al->map->pgoff, false);
+	}
 
 	return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1;
 }



  parent reply	other threads:[~2021-05-27 15:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 15:12 [PATCH 5.10 0/9] 5.10.41-rc1 review Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 1/9] bpf: Wrap aux data inside bpf_sanitize_info container Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 2/9] bpf: Fix mask direction swap upon off reg sign change Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 3/9] bpf: No need to simulate speculative domain for immediates Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 4/9] context_tracking: Move guest exit context tracking to separate helpers Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 5/9] context_tracking: Move guest exit vtime accounting " Greg Kroah-Hartman
2021-05-27 15:12 ` [PATCH 5.10 6/9] KVM: x86: Defer vtime accounting til after IRQ handling Greg Kroah-Hartman
2021-05-27 15:12 ` Greg Kroah-Hartman [this message]
2021-05-27 15:13 ` [PATCH 5.10 8/9] perf unwind: Set userdata for all __report_module() paths Greg Kroah-Hartman
2021-05-27 15:13 ` [PATCH 5.10 9/9] NFC: nci: fix memory leak in nci_allocate_device Greg Kroah-Hartman
2021-05-27 19:03 ` [PATCH 5.10 0/9] 5.10.41-rc1 review Jon Hunter
2021-05-27 19:57 ` Fox Chen
2021-05-27 20:34 ` Pavel Machek
2021-05-28  0:01 ` Shuah Khan
2021-05-28  3:08 ` Florian Fainelli
2021-05-28  6:00 ` Guenter Roeck
2021-05-28  6:22 ` Naresh Kamboju
2021-05-28 16:51 ` Sudip Mukherjee
2021-05-29  0:42 ` Samuel Zou

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=20210527151139.473431614@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=irogers@google.com \
    --cc=jan.kratochvil@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tommi.t.rantala@nokia.com \
    /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