From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752506AbdBFX6T (ORCPT ); Mon, 6 Feb 2017 18:58:19 -0500 Received: from rcdn-iport-3.cisco.com ([173.37.86.74]:35989 "EHLO rcdn-iport-3.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751164AbdBFX6R (ORCPT ); Mon, 6 Feb 2017 18:58:17 -0500 X-Greylist: delayed 575 seconds by postgrey-1.27 at vger.kernel.org; Mon, 06 Feb 2017 18:58:17 EST X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0ARAQAmCplY/4YNJK1dGQEBAQEBAQEBA?= =?us-ascii?q?QEBBwEBAQEBg1OBao1gmhmLHIIPggyGIoJWPxgBAgEBAQEBAQFiKIUXUkg6PAE?= =?us-ascii?q?SiVsDFbFOOoc6DYQKAQEBAQEBBAEBAQEBIxONeYJChQcfBYkAhj1+SIorOI1yh?= =?us-ascii?q?BcCgXmIZIYhAoouiF4fOH4yHRWFQ4FcHzUBiR0BAQE?= X-IronPort-AV: E=Sophos;i="5.33,342,1477958400"; d="scan'208";a="195049458" From: Victor Kamensky To: Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org Cc: xe-linux-external@cisco.com, Dima Kogan , Kan Liang , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Masami Hiramatsu , Wang Nan , Namhyung Kim , Chris Phlipot , He Kuang , Adrian Hunter Subject: [PATCH] perf symbols: take in account symfs setting when reading file build ID Date: Mon, 6 Feb 2017 15:48:28 -0800 Message-Id: <1486424908-17094-1-git-send-email-kamensky@cisco.com> X-Mailer: git-send-email 2.7.4 X-Auto-Response-Suppress: DR, OOF, AutoReply X-Authenticated-User: kamensky@cisco.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After 5baecbc 'perf symbols: we can now read separate debug-info files based on a build ID' and when --symfs option is used perf failed to pick up symbols for file with the same name between host and sysroot specified by --symfs option. One can see message like this: bin/bash with build id 26f0062cb6950d4d1ab0fd9c43eae8b10ca42062 not found, continuing without symbols It happens because code added by 5baecbc opens files directly by dso->long_name without symbol_conf.symfs consideration, which as result picks one from the host. It reads its build ID and later even code finds another proper file in directory pointed by --symfs perf ignores it because build id mismatches. Fix is to use __symbol__join_symfs to adjust file name according to --symfs setting. If no --symfs passed the operation would noop and picks the same host file as before. Also note in latter tree after 5baecbc commit additional check for '!dso->has_build_id' was added, so to observe error condition 'perf record' should run with --no-buildid, so perf.data itself would not have build id for target binary in buildid perf section and 'perf report' will pass '!dso->has_build_id' condition. Or target binary should not have build id, but the same binary on host has build id, again '!dso->has_build_id' will pass in this case and incorrect build id could be read if --symfs is used. Fixes: 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID") Signed-off-by: Victor Kamensky Cc: xe-linux-external@cisco.com Cc: Arnaldo Carvalho de Melo Cc: Dima Kogan Cc: Kan Liang Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Alexander Shishkin Cc: Masami Hiramatsu Cc: Wang Nan Cc: Namhyung Kim Cc: Chris Phlipot Cc: He Kuang Cc: Adrian Hunter Cc: linux-kernel@vger.kernel.org --- tools/perf/util/symbol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index dc93940..70e389bc 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1460,9 +1460,11 @@ int dso__load(struct dso *dso, struct map *map) * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work */ if (!dso->has_build_id && - is_regular_file(dso->long_name) && - filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0) + is_regular_file(dso->long_name)) { + __symbol__join_symfs(name, PATH_MAX, dso->long_name); + if (filename__read_build_id(name, build_id, BUILD_ID_SIZE) > 0) dso__set_build_id(dso, build_id); + } /* * Iterate over candidate debug images. -- 2.7.4