From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1610 invoked by alias); 20 Dec 2013 10:08:43 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 1544 invoked by uid 89); 20 Dec 2013 10:08:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail7.hitachi.co.jp Received: from mail7.hitachi.co.jp (HELO mail7.hitachi.co.jp) (133.145.228.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Dec 2013 10:08:41 +0000 Received: from mlsv5.hitachi.co.jp (unknown [133.144.234.166]) by mail7.hitachi.co.jp (Postfix) with ESMTP id 5AE5737AC3; Fri, 20 Dec 2013 19:08:39 +0900 (JST) Received: from mfilter06.hitachi.co.jp by mlsv5.hitachi.co.jp (8.13.1/8.13.1) id rBKA8dsM029360; Fri, 20 Dec 2013 19:08:39 +0900 Received: from vshuts04.hitachi.co.jp (vshuts04.hitachi.co.jp [10.201.6.86]) by mfilter06.hitachi.co.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id rBKA8bCP012388; Fri, 20 Dec 2013 19:08:38 +0900 Received: from gmml27.itg.hitachi.co.jp (unknown [158.213.165.130]) by vshuts04.hitachi.co.jp (Postfix) with ESMTP id 906D114003D; Fri, 20 Dec 2013 19:08:37 +0900 (JST) Received: from kbuild-fedora.novalocal by gmml27.itg.hitachi.co.jp (AIX5.2/8.11.6p2/8.11.0) id rBKA8bK9687188; Fri, 20 Dec 2013 19:08:37 +0900 Subject: [PATCH -tip 1/3] [CLEANUP] perf-probe: Expand given path to absolute path To: Ingo Molnar , Arnaldo Carvalho de Melo From: Masami Hiramatsu Cc: Srikar Dronamraju , David Ahern , lkml , "Steven Rostedt (Red Hat)" , Oleg Nesterov , "David A. Long" , systemtap@sourceware.org, yrl.pp-manager.tt@hitachi.com, Namhyung Kim Date: Fri, 20 Dec 2013 10:08:00 -0000 Message-ID: <20131220100257.7169.60537.stgit@kbuild-fedora.novalocal> In-Reply-To: <20131220100255.7169.19384.stgit@kbuild-fedora.novalocal> References: <20131220100255.7169.19384.stgit@kbuild-fedora.novalocal> User-Agent: StGit/0.16 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-q4/txt/msg00463.txt.bz2 Expand given path to absolute path in option parser, except for a module name. Instead of expanding it later, this get the absolute path in early stage. Signed-off-by: Masami Hiramatsu --- tools/perf/builtin-probe.c | 9 +++++++++ tools/perf/util/probe-event.c | 11 ++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 6ea9e85..b40d064 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -180,6 +180,15 @@ static int opt_set_target(const struct option *opt, const char *str, else return ret; + /* Expand given path to absolute path, except for modulename */ + if (params.uprobes || strchr(str, '/')) { + str = realpath(str, NULL); + if (!str) { + pr_warning("Failed to find the path of %s.\n", + str); + return ret; + } + } params.target = str; ret = 0; } diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index d7cff57..05be5de 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -2281,7 +2281,7 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec) struct perf_probe_point *pp = &pev->point; struct symbol *sym; struct map *map = NULL; - char *function = NULL, *name = NULL; + char *function = NULL; int ret = -EINVAL; unsigned long long vaddr = 0; @@ -2297,12 +2297,7 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec) goto out; } - name = realpath(exec, NULL); - if (!name) { - pr_warning("Cannot find realpath for %s.\n", exec); - goto out; - } - map = dso__new_map(name); + map = dso__new_map(exec); if (!map) { pr_warning("Cannot find appropriate DSO for %s.\n", exec); goto out; @@ -2367,7 +2362,5 @@ out: } if (function) free(function); - if (name) - free(name); return ret; }