Skip to contentSkip to conversation

perf tools: Use symfs when opening debuginfo by path

PATCH Applied Namhyung Kim 3 participants 4 messages Feb 12, 2025 – Feb 13, 2025 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf tools: Use symfs when opening debuginfo by path

I found that it failed to load a binary using --symfs option. Say I have a binary in /home/user/prog/xxx and a perf data file with it. If I move them to a different machine and use --symfs, it tries to find the binary in some locations under symfs using dso__read_binary_type_filename(), but not the last one.

  ${symfs}/usr/lib/debug/home/user/prog/xxx.debug
  ${symfs}/usr/lib/debug/home/user/prog/xxx
  ${symfs}/home/user/prog/.debug/xxx
  /home/user/prog/xxx

It should check ${symfs}/home/usr/prog/xxx. Let's fix it.

Cc Masami Hiramatsu <[email protected]>
---
 tools/perf/util/debuginfo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/util/debuginfo.c +5 -1
index 19acf4775d3587a4..b5deea7cbdf24620 100644
@@ -125,8 +125,12 @@ struct debuginfo *debuginfo__new(const char *path)
 	dso__put(dso);
 
 out:
+	if (dinfo)
+		return dinfo;
+
 	/* if failed to open all distro debuginfo, open given binary */
-	return dinfo ? : __debuginfo__new(path);
+	symbol__join_symfs(buf, path);
+	return __debuginfo__new(buf);
 }
 
 void debuginfo__delete(struct debuginfo *dbg)
Signature · 1 line
2.48.1.502.g6dc24dfdaf-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Namhyung Kim

I found that it failed to load a binary using --symfs option. Say I have a binary in /home/user/prog/xxx and a perf data file with it. If I move them to a different machine and use --symfs, it tries to find the binary in some locations under symfs using dso__read_binary_type_filename(), but not the last one.

  ${symfs}/usr/lib/debug/home/user/prog/xxx.debug
  ${symfs}/usr/lib/debug/home/user/prog/xxx
  ${symfs}/home/user/prog/.debug/xxx
  /home/user/prog/xxx
Quoted 4 lines

It should check ${symfs}/home/usr/prog/xxx. Let's fix it.

Cc Masami Hiramatsu <[email protected]>

Thanks,
Ian

Quoted 25 lines
---
 tools/perf/util/debuginfo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/util/debuginfo.c +5 -2
index 19acf4775d3587a4..b5deea7cbdf24620 100644
@@ -125,8 +125,12 @@ struct debuginfo *debuginfo__new(const char *path)
        dso__put(dso);
 
 out:
+       if (dinfo)
+               return dinfo;
+
        /* if failed to open all distro debuginfo, open given binary */
-       return dinfo ? : __debuginfo__new(path);
+       symbol__join_symfs(buf, path);
+       return __debuginfo__new(buf);
 }
 
 void debuginfo__delete(struct debuginfo *dbg)
--

2.48.1.502.g6dc24dfdaf-goog

Acked-by on v1 1/1
#2 lore raw
In reply to Namhyung Kim
Quoted 11 lines · On Wed, 12 Feb 2025 14:14:45 -0800 Namhyung Kim <[email protected]> wrote:

I found that it failed to load a binary using --symfs option. Say I have a binary in /home/user/prog/xxx and a perf data file with it. If I move them to a different machine and use --symfs, it tries to find the binary in some locations under symfs using dso__read_binary_type_filename(), but not the last one.

  ${symfs}/usr/lib/debug/home/user/prog/xxx.debug
  ${symfs}/usr/lib/debug/home/user/prog/xxx
  ${symfs}/home/user/prog/.debug/xxx
  /home/user/prog/xxx
Quoted 4 lines

It should check ${symfs}/home/usr/prog/xxx. Let's fix it.

Cc Masami Hiramatsu <[email protected]>

Good catch! This looks good to me.

Thanks!

Quoted 25 lines
---
 tools/perf/util/debuginfo.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/util/debuginfo.c +5 -1
index 19acf4775d3587a4..b5deea7cbdf24620 100644
@@ -125,8 +125,12 @@ struct debuginfo *debuginfo__new(const char *path)
 	dso__put(dso);
 
 out:
+	if (dinfo)
+		return dinfo;
+
 	/* if failed to open all distro debuginfo, open given binary */
-	return dinfo ? : __debuginfo__new(path);
+	symbol__join_symfs(buf, path);
+	return __debuginfo__new(buf);
 }
 
 void debuginfo__delete(struct debuginfo *dbg)
Signature · 1 line
2.48.1.502.g6dc24dfdaf-goog
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
author maintainer Applied
#3 lore raw
In reply to Namhyung Kim
Quoted 6 lines · Namhyung Kim

I found that it failed to load a binary using --symfs option. Say I have a binary in /home/user/prog/xxx and a perf data file with it. If I move them to a different machine and use --symfs, it tries to find the binary in some locations under symfs using dso__read_binary_type_filename(), but not the last one.

Quoted 6 lines
  ${symfs}/usr/lib/debug/home/user/prog/xxx.debug
  ${symfs}/usr/lib/debug/home/user/prog/xxx
  ${symfs}/home/user/prog/.debug/xxx
  /home/user/prog/xxx

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung