From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org,
Masami Hiramatsu <mhiramat@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH v2 2/8] perf tools: Factor out dso__find_dbginfo_type()
Date: Mon, 28 Sep 2026 18:11:33 -0700 [thread overview]
Message-ID: <20260929011139.53242-3-namhyung@kernel.org> (raw)
In-Reply-To: <20260929011139.53242-1-namhyung@kernel.org>
It tries to find a file with working debug info by checking all possible
debug types. It checks if the file has one of known debug info sections.
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/debuginfo.c | 23 ++++++-----------------
tools/perf/util/dso.c | 29 +++++++++++++++++++++++++++++
tools/perf/util/dso.h | 2 ++
3 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/tools/perf/util/debuginfo.c b/tools/perf/util/debuginfo.c
index 84a78b30ceac1066..d6bd0fcc22648f0e 100644
--- a/tools/perf/util/debuginfo.c
+++ b/tools/perf/util/debuginfo.c
@@ -93,15 +93,6 @@ static struct debuginfo *__debuginfo__new(const char *path)
struct debuginfo *debuginfo__new(const char *path)
{
- static const enum dso_binary_type distro_dwarf_types[] = {
- DSO_BINARY_TYPE__FEDORA_DEBUGINFO,
- DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
- DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
- DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
- DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO,
- DSO_BINARY_TYPE__NOT_FOUND,
- };
- const enum dso_binary_type *type;
char buf[PATH_MAX], nil = '\0';
struct dso *dso;
struct debuginfo *dinfo = NULL;
@@ -120,14 +111,12 @@ struct debuginfo *debuginfo__new(const char *path)
if (filename__read_build_id(path, &bid) > 0)
dso__set_build_id(dso, &bid);
- for (type = distro_dwarf_types;
- !dinfo && *type != DSO_BINARY_TYPE__NOT_FOUND;
- type++) {
- if (dso__read_binary_type_filename(dso, *type, &nil,
- buf, PATH_MAX) < 0)
- continue;
- dinfo = __debuginfo__new(buf);
- }
+ dso__find_dbginfo_type(dso);
+ if (dso__read_binary_type_filename(dso, dso__dbginfo_type(dso), &nil,
+ buf, PATH_MAX) < 0)
+ goto out;
+
+ dinfo = __debuginfo__new(buf);
dso__put(dso);
out:
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 90a6f661278a9c81..44cfc16cfbe49600 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -2108,3 +2108,32 @@ void dso__set_symsrc_filename(struct dso *dso, char *val)
dso__set_has_srcline(dso, true);
dso__set_a2l_fails(dso, 0);
}
+
+void dso__find_dbginfo_type(struct dso *dso)
+{
+ static const enum dso_binary_type dbginfo_types[] = {
+ DSO_BINARY_TYPE__FEDORA_DEBUGINFO,
+ DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
+ DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO,
+ DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
+ DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
+ DSO_BINARY_TYPE__NOT_FOUND,
+ };
+ const enum dso_binary_type *type;
+ char buf[PATH_MAX];
+
+ if (dso__dbginfo_type(dso) != DSO_BINARY_TYPE__NOT_FOUND)
+ return;
+
+ for (type = dbginfo_types; *type != DSO_BINARY_TYPE__NOT_FOUND; type++) {
+ if (dso__read_binary_type_filename(dso, *type, "",
+ buf, PATH_MAX) < 0)
+ continue;
+
+ if (filename__has_section(buf, ".debug_info") ||
+ filename__has_section(buf, ".zdebug_info"))
+ break;
+ }
+
+ dso__set_dbginfo_type(dso, *type);
+}
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 34d187d1fc00efdc..a152957322f6b31c 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -1013,6 +1013,8 @@ static inline void dso__set_dbginfo_type(struct dso *dso, enum dso_binary_type b
RC_CHK_ACCESS(dso)->dbginfo_type = bt;
}
+void dso__find_dbginfo_type(struct dso *dso);
+
bool dso__is_object_file(const struct dso *dso);
void dso__free_a2l(struct dso *dso);
--
2.55.0
next prev parent reply other threads:[~2026-09-29 1:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 1:11 [PATCH v2 0/8] perf tools: Cleanup dso debug info access Namhyung Kim
2026-09-29 1:11 ` [PATCH v2 1/8] perf tools: Add dso->dbginfo_type field Namhyung Kim
2026-09-29 1:11 ` Namhyung Kim [this message]
2026-09-29 1:11 ` [PATCH v2 3/8] perf tools: Check system path when check debuginfo Namhyung Kim
2026-09-29 1:11 ` [PATCH v2 4/8] perf tools: Export dso__get_filename() with type argument Namhyung Kim
2026-09-29 1:11 ` [PATCH v2 5/8] perf tools: Add dso__put_filename() Namhyung Kim
2026-09-29 1:11 ` [PATCH v2 6/8] perf tools: Avoid repeated failing search for debuginfo Namhyung Kim
2026-09-29 1:11 ` [PATCH v2 7/8] perf tools: Looks symbol file first when check debuginfo Namhyung Kim
2026-09-29 1:11 ` [PATCH v2 8/8] perf tools: Update debuginfo__new() to take DSO Namhyung Kim
2026-09-29 18:58 ` [PATCH v2 0/8] perf tools: Cleanup dso debug info access Arnaldo Carvalho de Melo
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=20260929011139.53242-3-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®