Skip to contentSkip to conversation

perf: fix the probe finder location (.dwo files)

PATCH Superseded Henry Castro 3 participants 7 messages Oct 3, 2022 – Feb 2, 2023 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf: fix the probe finder location (.dwo files)

If the file object is compiled using -gsplit-dwarf, the probe finder location will fail.

---

Quoted 4 lines

Anyway I think it'd be safer to do

   if (dwarf_cu_info() == 0 && unit_type == skeleton)
       pf->cu_die = subdie;

Thank you, I have modifed the patch :)

 tools/perf/util/probe-finder.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tools/perf/util/probe-finder.c +10 -1
index 50d861a80f57..b27039f5f04b 100644
@@ -1161,7 +1161,8 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
 	struct perf_probe_point *pp = &pf->pev->point;
 	Dwarf_Off off, noff;
 	size_t cuhl;
-	Dwarf_Die *diep;
+	Dwarf_Die *diep, cudie, subdie;
+	uint8_t unit_type;
 	int ret = 0;
 
 	off = 0;
@@ -1200,6 +1201,14 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
 			continue;
 		}
 
+#if _ELFUTILS_VERSION >= 171
+		/* Check separate debug information file. */
+		if (dwarf_cu_info(pf->cu_die.cu, NULL, &unit_type,
+				  &cudie, &subdie, NULL, NULL, NULL) == 0
+		    && unit_type == DW_UT_skeleton)
+			pf->cu_die = subdie;
+#endif
+
 		/* Check if target file is included. */
 		if (pp->file)
 			pf->fname = cu_find_realpath(&pf->cu_die, pp->file);

--
2.20.1

maintainer
#1 lore raw

Cc + Masami

Quoted 23 lines · Henry Castro

If the file object is compiled using -gsplit-dwarf, the probe finder location will fail.

---

Quoted 4 lines

Anyway I think it'd be safer to do

   if (dwarf_cu_info() == 0 && unit_type == skeleton)
       pf->cu_die = subdie;

Thank you, I have modifed the patch :)

 tools/perf/util/probe-finder.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tools/perf/util/probe-finder.c +0 -0
index 50d861a80f57..b27039f5f04b 100644

tools/perf/util/probe-finder.c static int debuginfo__find_probe_location(struct debuginfo *dbg, · line 1165

Quoted 6 lines
tools/perf/util/probe-finder.c +2 -1
@@ -1161,7 +1161,8 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
        struct perf_probe_point *pp = &pf->pev->point;
        Dwarf_Off off, noff;
        size_t cuhl;
-       Dwarf_Die *diep;
+       Dwarf_Die *diep, cudie, subdie;
+       uint8_t unit_type;

They will be unused for earlier elfutils.

tools/perf/util/probe-finder.c static int debuginfo__find_probe_location(struct debuginfo *dbg, · line 1204

Quoted 8 lines
tools/perf/util/probe-finder.c +1 -0
        int ret = 0;
 
        off = 0;
@@ -1200,6 +1201,14 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
                        continue;
                }
 
+#if _ELFUTILS_VERSION >= 171

Nit, I think we use _ELFUTILS_PREREQ(0, 171).

tools/perf/util/probe-finder.c static int debuginfo__find_probe_location(struct debuginfo *dbg, · line 1210

Quoted 6 lines
tools/perf/util/probe-finder.c +6 -0
+               /* Check separate debug information file. */
+               if (dwarf_cu_info(pf->cu_die.cu, NULL, &unit_type,
+                                 &cudie, &subdie, NULL, NULL, NULL) == 0
+                   && unit_type == DW_UT_skeleton)
+                       pf->cu_die = subdie;
+#endif

How about making it a separate function with 2 versions depending on the elfutils? Then you can have the variables only if they are used.

Something like get_source_from_debuginfod() in the same file.

Thanks,
Namhyung

Quoted 7 lines
tools/perf/util/probe-finder.c +1 -1
+
                /* Check if target file is included. */
                if (pp->file)
                        pf->fname = cu_find_realpath(&pf->cu_die, pp->file);
--

2.20.1

#2 lore raw

PATCH v3 1/1 perf: fix the probe finder location (.dwo files)

If the file object is compiled using -gsplit-dwarf, the probe finder location will fail.

---

Quoted 1 line

Nit, I think we use _ELFUTILS_PREREQ(0, 171).

Thank you

Quoted 6 lines

How about making it a separate function with 2 versions depending on the elfutils? Then you can have the variables only if they are used.

Something like get_source_from_debuginfod() in the same file.

Sounds good, but I prefer simplicity in the patch =), what do you think about

{
	Dwarf_Die cudie, subdie;
	if (dwarf_cu_info() ..)
	..
}

to resolve unused variable?
}

 tools/perf/util/probe-finder.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tools/perf/util/probe-finder.c +14 -0
index 50d861a80f57..5f6781e712db 100644
@@ -1200,6 +1200,20 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
 			continue;
 		}
 
+#if _ELFUTILS_PREREQ(0, 171)
+		{
+			uint8_t unit_type;
+			Dwarf_Die cudie, subdie;
+
+			/* Check separate debug information file. */
+			if (dwarf_cu_info(pf->cu_die.cu, NULL,
+					  &unit_type, &cudie,
+					  &subdie, NULL,
+					  NULL, NULL) == 0
+			    && unit_type == DW_UT_skeleton)
+				pf->cu_die = subdie;
+		}
+#endif
 		/* Check if target file is included. */
 		if (pp->file)
 			pf->fname = cu_find_realpath(&pf->cu_die, pp->file);

--
2.20.1

#3 lore raw

Em Wed, Oct 05, 2022 at 08:47:02AM -0400, Henry Castro escreveu:

Quoted 8 lines

If the file object is compiled using -gsplit-dwarf, the probe finder location will fail.

---

Quoted 1 line

Nit, I think we use _ELFUTILS_PREREQ(0, 171).

Thank you

Masami, are you ok with this?

Namyung, how about you?

Thanks,

- Arnaldo

Quoted 49 lines
Quoted 6 lines

How about making it a separate function with 2 versions depending on the elfutils? Then you can have the variables only if they are used.

Something like get_source_from_debuginfod() in the same file.

Sounds good, but I prefer simplicity in the patch =), what do you think about

{
	Dwarf_Die cudie, subdie;
	if (dwarf_cu_info() ..)
	..
}

to resolve unused variable?
}

 tools/perf/util/probe-finder.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tools/perf/util/probe-finder.c +14 -1
index 50d861a80f57..5f6781e712db 100644
@@ -1200,6 +1200,20 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
 			continue;
 		}
 
+#if _ELFUTILS_PREREQ(0, 171)
+		{
+			uint8_t unit_type;
+			Dwarf_Die cudie, subdie;
+
+			/* Check separate debug information file. */
+			if (dwarf_cu_info(pf->cu_die.cu, NULL,
+					  &unit_type, &cudie,
+					  &subdie, NULL,
+					  NULL, NULL) == 0
+			    && unit_type == DW_UT_skeleton)
+				pf->cu_die = subdie;
+		}
+#endif
 		/* Check if target file is included. */
 		if (pp->file)
 			pf->fname = cu_find_realpath(&pf->cu_die, pp->file);
--

2.20.1

Signature · 1 line
- Arnaldo
#4 lore raw

PATCH v3 1/1 perf: fix the probe finder location (.dwo files)

If the file object is compiled using -gsplit-dwarf, the probe finder location will fail.

---

Hi,

Polite ping? Any feedback?

Regards
Henry

 tools/perf/util/probe-finder.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tools/perf/util/probe-finder.c +14 -0
index 50d861a80f57..5f6781e712db 100644
@@ -1200,6 +1200,20 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
 			continue;
 		}
 
+#if _ELFUTILS_PREREQ(0, 171)
+		{
+			uint8_t unit_type;
+			Dwarf_Die cudie, subdie;
+
+			/* Check separate debug information file. */
+			if (dwarf_cu_info(pf->cu_die.cu, NULL,
+					  &unit_type, &cudie,
+					  &subdie, NULL,
+					  NULL, NULL) == 0
+			    && unit_type == DW_UT_skeleton)
+				pf->cu_die = subdie;
+		}
+#endif
 		/* Check if target file is included. */
 		if (pp->file)
 			pf->fname = cu_find_realpath(&pf->cu_die, pp->file);

--
2.20.1

#5 lore raw

Em Sun, Jan 29, 2023 at 07:21:28PM -0400, Henry Castro escreveu:

Quoted 9 lines

If the file object is compiled using -gsplit-dwarf, the probe finder location will fail.

---

Hi,

Polite ping? Any feedback?

Namhyung, are you ok now? Masami, can you please take a look and provide an Acked-by or Reviewed-by?

- Arnaldo

Quoted 34 lines

Regards
Henry

 tools/perf/util/probe-finder.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tools/perf/util/probe-finder.c +14 -1
index 50d861a80f57..5f6781e712db 100644
@@ -1200,6 +1200,20 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
 			continue;
 		}
 
+#if _ELFUTILS_PREREQ(0, 171)
+		{
+			uint8_t unit_type;
+			Dwarf_Die cudie, subdie;
+
+			/* Check separate debug information file. */
+			if (dwarf_cu_info(pf->cu_die.cu, NULL,
+					  &unit_type, &cudie,
+					  &subdie, NULL,
+					  NULL, NULL) == 0
+			    && unit_type == DW_UT_skeleton)
+				pf->cu_die = subdie;
+		}
+#endif
 		/* Check if target file is included. */
 		if (pp->file)
 			pf->fname = cu_find_realpath(&pf->cu_die, pp->file);
--

2.20.1

Signature · 1 line
- Arnaldo
maintainer Acked-by
#6 lore raw

Hello,

Quoted 8 lines · Arnaldo Carvalho de Melo

Em Sun, Jan 29, 2023 at 07:21:28PM -0400, Henry Castro escreveu:

Quoted 6 lines

If the file object is compiled using -gsplit-dwarf, the probe finder location will fail.

---

Quoted 6 lines
Quoted 3 lines

Hi,

Polite ping? Any feedback?

Namhyung, are you ok now? Masami, can you please take a look and provide an Acked-by or Reviewed-by?

Sorry about that. I completely missed this..
Now it looks ok, but it'd be nice if Masami could review this.

Thanks,
Namhyung

Quoted 35 lines
Quoted 29 lines
 tools/perf/util/probe-finder.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tools/perf/util/probe-finder.c +14 -1
index 50d861a80f57..5f6781e712db 100644
@@ -1200,6 +1200,20 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
                      continue;
              }
 
+#if _ELFUTILS_PREREQ(0, 171)
+             {
+                     uint8_t unit_type;
+                     Dwarf_Die cudie, subdie;
+
+                     /* Check separate debug information file. */
+                     if (dwarf_cu_info(pf->cu_die.cu, NULL,
+                                       &unit_type, &cudie,
+                                       &subdie, NULL,
+                                       NULL, NULL) == 0
+                         && unit_type == DW_UT_skeleton)
+                             pf->cu_die = subdie;
+             }
+#endif
              /* Check if target file is included. */
              if (pp->file)
                      pf->fname = cu_find_realpath(&pf->cu_die, pp->file);
--
Quoted 2 lines

2.20.1

--

- Arnaldo