From patchwork Tue Jan 13 16:59:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Kamensky X-Patchwork-Id: 5622451 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 091CAC058D for ; Tue, 13 Jan 2015 17:01:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0862F202F8 for ; Tue, 13 Jan 2015 17:01:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E4F3202F2 for ; Tue, 13 Jan 2015 17:01:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YB4ox-00067D-EG; Tue, 13 Jan 2015 16:59:59 +0000 Received: from mail-pa0-f43.google.com ([209.85.220.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YB4on-00062C-Hx for linux-arm-kernel@lists.infradead.org; Tue, 13 Jan 2015 16:59:50 +0000 Received: by mail-pa0-f43.google.com with SMTP id kx10so4738286pab.2 for ; Tue, 13 Jan 2015 08:59:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aIMruV4/XcRt1btsNAtcu4Wfs7QXU7ymo2lPHCggmuc=; b=Gb0f0sO1i6Tehn6RYaYnk/zKZZf0OI0AvQbyE17YnQncVszh5gwD+5p4elCYGF51fb sZasjBv3OCUOd2sYESWmGv2xCp9z8De8flAGCY8C+uhuf+JD5c9ISEsot9d6y+f2HDf1 OEIhfPfNCI96Yaolajd1pJOgrEQVBIcHj19sm91Sh+9F0ohV/sDm1HAteVg4qTpLNXBY cLbjbI3BDJBLWFSvBKRt4C+GwO1XsEV1xiwSCJ1vGqNUqdNJyO/Kp4Io91kExXPYenoB fZXqgHaxiA9/Kndx9FtP0dpTUe4Jy1+hyiEn/G0T0iWA+ByOJwCdoSasyX/71bnoNzzH LGyA== X-Gm-Message-State: ALoCoQkzt4SmYrH1stN+cnT5K5nrRU9WTUaC+hOBXXwBJr2iBw1NZ794+rhhyQTcy1nIYpErej6R X-Received: by 10.66.55.74 with SMTP id q10mr52741839pap.94.1421168368639; Tue, 13 Jan 2015 08:59:28 -0800 (PST) Received: from kamensky-w530.cisco.com (128-107-239-233.cisco.com. [128.107.239.233]) by mx.google.com with ESMTPSA id t13sm10203590pdj.61.2015.01.13.08.59.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jan 2015 08:59:27 -0800 (PST) From: Victor Kamensky To: Arnaldo Carvalho de Melo , Namhyung Kim Subject: [PATCH 2/2] perf symbols: debuglink should take symfs option into account Date: Tue, 13 Jan 2015 08:59:04 -0800 Message-Id: <1421168344-5363-2-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1421168344-5363-1-git-send-email-victor.kamensky@linaro.org> References: <1421168344-5363-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150113_085949_614360_629D566C X-CRM114-Status: GOOD ( 11.49 ) X-Spam-Score: -0.7 (/) Cc: Waiman Long , Avi Kivity , Peter Zijlstra , Victor Kamensky , Will Deacon , Adrian Hunter , linux-kernel@vger.kernel.org, Ingo Molnar , Paul Mackerras , Anton Blanchard , Jiri Olsa , David Ahern , Masami Hiramatsu , Jiri Olsa , Dave Martin , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently code that tries to read corresponding debug symbol file from .gnu_debuglink section (DSO_BINARY_TYPE__DEBUGLINK) does not take in account symfs option, so filename__read_debuglink function cannot open ELF file, if symfs option is used. Fix is to add proper handling of symfs as it is done in other places: use __symbol__join_symfs function to get real file name of target ELF file. Created malloced copy of target filename in symfs before passing it to __symbol__join_symfs function because filename will be modified by it if corresponding debuglink is found. Signed-off-by: Victor Kamensky Cc: Peter Zijlstra Cc: Paul Mackerras Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Namhyung Kim Cc: Adrian Hunter Cc: Waiman Long Cc: David Ahern --- tools/perf/util/dso.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 45be944..6a2f663 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -42,19 +42,30 @@ int dso__read_binary_type_filename(const struct dso *dso, size_t len; switch (type) { - case DSO_BINARY_TYPE__DEBUGLINK: { + case DSO_BINARY_TYPE__DEBUGLINK: + { char *debuglink; - - strncpy(filename, dso->long_name, size); - debuglink = filename + dso->long_name_len; - while (debuglink != filename && *debuglink != '/') - debuglink--; - if (*debuglink == '/') - debuglink++; - ret = filename__read_debuglink(dso->long_name, debuglink, - size - (debuglink - filename)); - } + char *filename_copy; + + filename_copy = malloc(PATH_MAX); + if (filename_copy) { + len = __symbol__join_symfs(filename, size, + dso->long_name); + strncpy(filename_copy, filename, PATH_MAX); + debuglink = filename + len; + while (debuglink != filename && *debuglink != '/') + debuglink--; + if (*debuglink == '/') + debuglink++; + ret = filename__read_debuglink(filename_copy, debuglink, + size - (debuglink - + filename)); + free(filename_copy); + } else + ret = -1; break; + } + case DSO_BINARY_TYPE__BUILD_ID_CACHE: /* skip the locally configured cache if a symfs is given */ if (symbol_conf.symfs[0] ||