Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753492AbbBZIIj (ORCPT ); Thu, 26 Feb 2015 03:08:39 -0500 Received: from mail9.hitachi.co.jp ([133.145.228.44]:48245 "EHLO mail9.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbbBZIIh (ORCPT ); Thu, 26 Feb 2015 03:08:37 -0500 Message-ID: <54EED47D.1010306@hitachi.com> Date: Thu, 26 Feb 2015 17:08:29 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Naohiro Aota Cc: Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] perf probe: Find compilation directory path for lazy matching References: <1424934769-19481-1-git-send-email-naota@elisp.net> <1424934769-19481-2-git-send-email-naota@elisp.net> In-Reply-To: <1424934769-19481-2-git-send-email-naota@elisp.net> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2321 Lines: 74 (2015/02/26 16:12), Naohiro Aota wrote: > If we use lazy matching, it failed to open a souce file if perf command > is invoked outside of compilation directory: > > $ perf probe -a '__schedule;clear_*' > Failed to open kernel/sched/core.c: No such file or directory > Error: Failed to add events. (-2) > > OTOH, other commands like "probe -L" can solve the souce directory by > themselves. Let's make it possible for lazy matching too! > > Signed-off-by: Naohiro Aota > --- > tools/perf/util/probe-finder.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c > index b5247d7..8e0714c 100644 > --- a/tools/perf/util/probe-finder.c > +++ b/tools/perf/util/probe-finder.c > @@ -39,6 +39,7 @@ > #include "util.h" > #include "symbol.h" > #include "probe-finder.h" > +#include "probe-event.h" > > /* Kprobe tracer basic type is up to u64 */ > #define MAX_BASIC_TYPE_BITS 64 > @@ -849,11 +850,23 @@ static int probe_point_lazy_walker(const char *fname, int lineno, > static int find_probe_point_lazy(Dwarf_Die *sp_die, struct probe_finder *pf) > { > int ret = 0; > + char *fpath; > > if (intlist__empty(pf->lcache)) { > + const char *comp_dir; > + > + comp_dir = cu_get_comp_dir(&pf->cu_die); > + ret = get_real_path(pf->fname, comp_dir, &fpath); > + if (ret < 0) { > + free(fpath); Here, if the get_real_path is failed, fpath should be freed before returning. If not, there is a bug, and yeah, there is a bug... Thank you! > + pr_warning("Failed to find source file path.\n"); > + return ret; > + } > + > /* Matching lazy line pattern */ > - ret = find_lazy_match_lines(pf->lcache, pf->fname, > + ret = find_lazy_match_lines(pf->lcache, fpath, > pf->pev->point.lazy_line); > + free(fpath); > if (ret <= 0) > return ret; > } > -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/