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: vkamensky X-Patchwork-Id: 43071 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7E22020DE8 for ; Tue, 13 Jan 2015 16:59:48 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id t10sf1774235eei.2 for ; Tue, 13 Jan 2015 08:59:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Kmd/Th6IUKF4Ku8Tm5g+dzpQOCu4FaCcegpk8NSmmts=; b=eXXDbXdedFrBFIa7CCgNnNt+fXYQcQHg5YJhz/2bdT+dv+KlDOH9K51A1xV72Ldnsk WwiJsWse9/ZpKJWZYG0H6KFMxVNWOCPayB4Qwpuwolsw6UA2UH+vAde7Sr+EIdu5zKJF QFGq9NuIfHb6JI4Q7edGQ3NYRnNzSfmpO1R2TKCexv4jSkoPdTGLKj+jmmTXPcVcEIAA Bky9Qk9X6zfV9Tk23kMU+7716M/kXeAlUInjNfRdTzU6mp0DT6+Wc6MRHFMQQvoF9IHD 5wtW22LFRgNL0rf/fAa9HlZM3Q3FhpMHu8zdNj4B+fLVsIS3neHaECELOaCHAzQT7z6N ZZqQ== X-Gm-Message-State: ALoCoQnjcetHVU8eRByQvTKGxPYs4io0gcbZoQ0MgUzDru6m4p+oY3VpTKyj7GBfk+dx0a2zG9a0 X-Received: by 10.180.98.199 with SMTP id ek7mr2118195wib.1.1421168387755; Tue, 13 Jan 2015 08:59:47 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.66 with SMTP id x2ls17394laa.88.gmail; Tue, 13 Jan 2015 08:59:47 -0800 (PST) X-Received: by 10.152.6.8 with SMTP id w8mr43870428law.41.1421168387568; Tue, 13 Jan 2015 08:59:47 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id bb5si3468644lab.36.2015.01.13.08.59.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 08:59:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id q1so3731747lam.5 for ; Tue, 13 Jan 2015 08:59:47 -0800 (PST) X-Received: by 10.112.104.4 with SMTP id ga4mr43231238lbb.24.1421168387423; Tue, 13 Jan 2015 08:59:47 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1441427lbb; Tue, 13 Jan 2015 08:59:46 -0800 (PST) X-Received: by 10.66.248.163 with SMTP id yn3mr51886922pac.5.1421168385580; Tue, 13 Jan 2015 08:59:45 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd4si27557393pdb.204.2015.01.13.08.59.44; Tue, 13 Jan 2015 08:59:45 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752611AbbAMQ7b (ORCPT + 27 others); Tue, 13 Jan 2015 11:59:31 -0500 Received: from mail-pd0-f176.google.com ([209.85.192.176]:65391 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752526AbbAMQ73 (ORCPT ); Tue, 13 Jan 2015 11:59:29 -0500 Received: by mail-pd0-f176.google.com with SMTP id r10so4420662pdi.7 for ; Tue, 13 Jan 2015 08:59:28 -0800 (PST) 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 Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Adrian Hunter , Jiri Olsa , Avi Kivity , Masami Hiramatsu , Anton Blanchard , David Ahern , Will Deacon , Dave Martin , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Victor Kamensky , Jiri Olsa , Waiman Long 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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] ||