linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: "Frank Ch. Eigler" <fche@redhat.com>,
	Mark Wielaard <mjw@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Milian Wolff <milian.wolff@kdab.com>,
	John Levon <levon@movementarian.org>,
	Namhyung Kim <namhyung@kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: libdw dwarf unwind issue
Date: Sat, 28 Nov 2020 05:07:40 +0100	[thread overview]
Message-ID: <20201128040740.GA446287@host1.jankratochvil.net> (raw)
In-Reply-To: <20201123221247.GC2003988@krava>

[-- Attachment #1: Type: text/plain, Size: 685 bytes --]

On Mon, 23 Nov 2020 23:12:47 +0100, Jiri Olsa wrote:
> it fixes the issue for me, but it breaks the dwarf test:
> 
> 72: DWARF unwind                                                    : FAILED!
> [jolsa@krava perf]$ sudo ./perf test dwarf -v
> 72: DWARF unwind                                                    :
> --- start ---
> test child forked, pid 2084484
> unwind: failed with 'No such file or directory'
> got wrong number of stack entries 0 != 8
> test child finished with -1
> ---- end ----
> DWARF unwind: FAILED!

The previous patch required ~/.debug/ build-id symlink, fixed.

I hope dso->symsrc_filename is always already set if a separate debug info is
present.


Jan

[-- Attachment #2: libdw-unwind2.patch --]
[-- Type: text/plain, Size: 2115 bytes --]

diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 7a3dbc259cec..400e4832b50e 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -20,10 +20,25 @@
 
 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 __maybe_unused,
+			    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)
+		*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 +61,24 @@ static int __report_module(struct addr_location *al, u64 ip,
 	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;
 }

  reply	other threads:[~2020-11-28 17:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201103221709.GL3597846@krava>
2020-11-22 22:27 ` libdw dwarf unwind issue Jan Kratochvil
2020-11-23 22:12   ` Jiri Olsa
2020-11-28  4:07     ` Jan Kratochvil [this message]
2020-12-01 19:41       ` Jiri Olsa
2020-12-02 10:06         ` Jan Kratochvil
2020-12-02 10:56           ` Jiri Olsa

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=20201128040740.GA446287@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=acme@kernel.org \
    --cc=fche@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=levon@movementarian.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=milian.wolff@kdab.com \
    --cc=mjw@redhat.com \
    --cc=namhyung@kernel.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).