[PATCH v2 7/8] perf tools: Looks symbol file first when check debuginfo

From: Namhyung Kim

Date: Mon Sep 28 2026 - 21:14:32 EST


There's a high chance that the file containing the symbol table also has
debug information. Let's check that first before other locations.

Reviewed-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/util/dso.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index f7a786e0c3cf6a29..e4a2a0ea38823b5f 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -2133,6 +2133,20 @@ void dso__find_dbginfo_type(struct dso *dso)
return;
dso__set_debuginfo_searched(dso);

+ /* Maybe debug info is in the same file with the symbol table */
+ path = dso__get_filename(dso, "", &decomp, dso__symtab_type(dso));
+ if (path) {
+ found = filename__has_section(path, ".debug_info") ||
+ filename__has_section(path, ".zdebug_info");
+
+ dso__put_filename(dso, path, decomp);
+ if (found) {
+ dso__set_dbginfo_type(dso, dso__symtab_type(dso));
+ return;
+ }
+ }
+
+ /* Otherwise check distro debug locations */
for (type = dbginfo_types; *type != DSO_BINARY_TYPE__NOT_FOUND; type++) {
path = dso__get_filename(dso, "", &decomp, *type);
if (path == NULL)
--
2.55.0