[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240816105811.1812897-8-changbin.du@huawei.com>
Date: Fri, 16 Aug 2024 18:58:10 +0800
From: Changbin Du <changbin.du@...wei.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim
<namhyung@...nel.org>, Nathan Chancellor <nathan@...nel.org>
CC: Mark Rutland <mark.rutland@....com>, Alexander Shishkin
<alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>, Ian
Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>, "Liang,
Kan" <kan.liang@...ux.intel.com>, Nick Desaulniers <ndesaulniers@...gle.com>,
Bill Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>,
<linux-perf-users@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<llvm@...ts.linux.dev>, Hui Wang <hw.huiwang@...wei.com>, Changbin Du
<changbin.du@...wei.com>
Subject: [PATCH v6 7/8] perf: disasm: prefer debugging files in build-id cache
The build-id cache might have both debugging and non-debugging files. Here
we prefer the debugging version for annotation.
Cc: Adrian Hunter <adrian.hunter@...el.com>
Signed-off-by: Changbin Du <changbin.du@...wei.com>
---
tools/perf/util/disasm.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index 6af9fbec3a95..5f66b3632770 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -1162,18 +1162,25 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
!dso__is_kcore(dso))
return SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX;
- build_id_filename = dso__build_id_filename(dso, NULL, 0, false);
- if (build_id_filename) {
- __symbol__join_symfs(filename, filename_size, build_id_filename);
- free(build_id_filename);
- } else {
- if (dso__has_build_id(dso))
- return ENOMEM;
- return fallback_filename(dso, filename, filename_size);
- }
+ /* Prefer debugging file if exists, otherwise non-debugging one is used. */
+ for (int i = 0; i < 2; i++) {
+ build_id_filename = dso__build_id_filename(dso, NULL, 0, !i);
+ if (build_id_filename) {
+ __symbol__join_symfs(filename, filename_size, build_id_filename);
+ free(build_id_filename);
+ } else {
+ if (dso__has_build_id(dso))
+ return ENOMEM;
+ return fallback_filename(dso, filename, filename_size);
+ }
- if (access(filename, R_OK))
- return fallback_filename(dso, filename, filename_size);
+ if (!access(filename, R_OK))
+ break;
+ else if (i != 0) {
+ /* nor debugging or non-debugging is found */
+ return fallback_filename(dso, filename, filename_size);
+ }
+ }
if (dso__is_kcore(dso) || dso__is_vdso(dso))
goto fallback;
--
2.34.1
Powered by blists - more mailing lists