From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C53A6E5ED for ; Tue, 2 Jul 2024 04:19:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719893949; cv=none; b=nbrNL2w0lbAE6n6lxc7W/sJBeRoAFo4FCJsSooClomcDAHrk1JFIwDP6JamiKcfglAEdhzdVOKDel1o3GZW2QvaW3dwwW+MVZyfOVxpa/vAFulHU9t59atkWbS0yUbuL/U8DorOKFA9lNHYyPUS4I2qp/eoY18sqZAGJKYElM6E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719893949; c=relaxed/simple; bh=ai9h6Dew9+W3mt2HzltrnE6jkw5lNXSWmYIC+kOQRyg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LUamMqGuekzULvUSb7daSQ9vl6vYZyZPJcBY8PMhfONT2C8zvKXTSqijJs8QDFHJaWpE/Uuf4CQokYgsyrFk5mJkNosye9RsAttB845U8Lq9HIz0n6c2wPpGFsIV+S1qBbt3UpKJfWm4OYFaeblwXC79eXfsO8DCXiW+J2ta1hc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WCqRF5bd5znVgP; Tue, 2 Jul 2024 12:18:49 +0800 (CST) Received: from kwepemd100011.china.huawei.com (unknown [7.221.188.204]) by mail.maildlp.com (Postfix) with ESMTPS id AFE7614037D; Tue, 2 Jul 2024 12:19:04 +0800 (CST) Received: from M910t.huawei.com (10.110.54.157) by kwepemd100011.china.huawei.com (7.221.188.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 2 Jul 2024 12:19:03 +0800 From: Changbin Du To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Nathan Chancellor CC: Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Nick Desaulniers , Bill Wendling , Justin Stitt , , , , Hui Wang , Changbin Du Subject: [PATCH v5 7/8] perf: disasm: prefer debugging files in build-id cache Date: Tue, 2 Jul 2024 12:18:36 +0800 Message-ID: <20240702041837.5306-8-changbin.du@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240702041837.5306-1-changbin.du@huawei.com> References: <20240702041837.5306-1-changbin.du@huawei.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd100011.china.huawei.com (7.221.188.204) The build-id cache might have both debugging and non-debugging files. Here we prefer the debugging version for annotation. Cc: Adrian Hunter Signed-off-by: Changbin Du --- 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 f4e94ff37e50..ecfd6a03713d 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