All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, He Kuang <hekuang@huawei.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Wang Nan <wangnan0@huawei.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 4/5] perf probe: Make --source avaiable when probe with lazy_line
Date: Mon, 13 Apr 2015 19:15:01 -0300	[thread overview]
Message-ID: <1428963302-31538-5-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1428963302-31538-1-git-send-email-acme@kernel.org>

From: He Kuang <hekuang@huawei.com>

Use get_real_path() to enable --source option when probe with lazy_line
pattern.

Before this patch:

  $ perf probe -s ./kernel_src/ -k ./vmlinux --add='fs/super.c;s->s_count=1;'
  Failed to open fs/super.c: No such file or directory
    Error: Failed to add events.

After this patch:

  $ perf probe -s ./kernel_src/ -k ./vmlinux  --add='fs/super.c;s->s_count=1;'
  Added new events:
    probe:_stext         (on @fs/super.c)
    probe:_stext_1       (on @fs/super.c)
  ...

Signed-off-by: He Kuang <hekuang@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1428925290-5623-2-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c  |  2 +-
 tools/perf/util/probe-event.h  |  2 ++
 tools/perf/util/probe-finder.c | 18 +++++++++++++++---
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 5483d98236d3..35ee51a8724f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -661,7 +661,7 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
  * a newly allocated path on success.
  * Return 0 if file was found and readable, -errno otherwise.
  */
-static int get_real_path(const char *raw_path, const char *comp_dir,
+int get_real_path(const char *raw_path, const char *comp_dir,
 			 char **new_path)
 {
 	const char *prefix = symbol_conf.source_prefix;
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index d6b783447be9..21809ea9b2b4 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -135,6 +135,8 @@ extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
 			       struct strfilter *filter, bool externs);
 extern int show_available_funcs(const char *module, struct strfilter *filter,
 				bool user);
+extern int get_real_path(const char *raw_path, const char *comp_dir,
+			char **new_path);
 
 /* Maximum index number of event-name postfix */
 #define MAX_EVENT_INDEX	1024
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 7831e2d93949..431c12d299a2 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -791,11 +791,20 @@ static int find_lazy_match_lines(struct intlist *list,
 	ssize_t len;
 	int count = 0, linenum = 1;
 	char sbuf[STRERR_BUFSIZE];
+	char *realname = NULL;
+	int ret;
 
-	fp = fopen(fname, "r");
+	ret = get_real_path(fname, NULL, &realname);
+	if (ret < 0) {
+		pr_warning("Failed to find source file %s.\n", fname);
+		return ret;
+	}
+
+	fp = fopen(realname, "r");
 	if (!fp) {
-		pr_warning("Failed to open %s: %s\n", fname,
+		pr_warning("Failed to open %s: %s\n", realname,
 			   strerror_r(errno, sbuf, sizeof(sbuf)));
+		free(realname);
 		return -errno;
 	}
 
@@ -817,7 +826,10 @@ static int find_lazy_match_lines(struct intlist *list,
 	fclose(fp);
 
 	if (count == 0)
-		pr_debug("No matched lines found in %s.\n", fname);
+		pr_debug("No matched lines found in %s.\n", realname);
+
+	free(realname);
+
 	return count;
 }
 
-- 
1.9.3


  parent reply	other threads:[~2015-04-13 22:15 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13 22:14 [GIT PULL 0/5] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-04-13 22:14 ` Arnaldo Carvalho de Melo
2015-04-13 22:14 ` [PATCH 1/5] tracing, mm: Record pfn instead of pointer to struct page Arnaldo Carvalho de Melo
2015-04-13 22:14   ` Arnaldo Carvalho de Melo
2017-07-31  7:43   ` Vlastimil Babka
2017-07-31  7:43     ` Vlastimil Babka
2017-08-31 11:38     ` Vlastimil Babka
2017-08-31 11:38       ` Vlastimil Babka
2017-08-31 13:43     ` Steven Rostedt
2017-08-31 13:43       ` Steven Rostedt
2017-08-31 14:31       ` Vlastimil Babka
2017-08-31 14:31         ` Vlastimil Babka
2017-08-31 14:44         ` Steven Rostedt
2017-08-31 14:44           ` Steven Rostedt
2017-09-01  8:16           ` Vlastimil Babka
2017-09-01  8:16             ` Vlastimil Babka
2017-09-01 11:15             ` Steven Rostedt
2017-09-01 11:15               ` Steven Rostedt
2015-04-13 22:14 ` [PATCH 2/5] perf kmem: Analyze page allocator events also Arnaldo Carvalho de Melo
2015-04-13 22:14   ` Arnaldo Carvalho de Melo
2015-04-13 22:15 ` [PATCH 3/5] perf probe: Set retprobe flag when probe in address-based alternative mode Arnaldo Carvalho de Melo
2015-04-13 22:15 ` Arnaldo Carvalho de Melo [this message]
2015-04-13 22:15 ` [PATCH 5/5] perf probe: Fix segfault when probe with lazy_line to file Arnaldo Carvalho de Melo
2015-04-13 22:33 ` [GIT PULL 0/5] perf/core improvements and fixes Masami Hiramatsu
2015-04-13 22:33   ` Masami Hiramatsu
2015-04-13 23:09   ` Arnaldo Carvalho de Melo
2015-04-13 23:09     ` Arnaldo Carvalho de Melo
2015-04-13 23:19     ` Arnaldo Carvalho de Melo
2015-04-13 23:19       ` Arnaldo Carvalho de Melo
2015-04-14  7:04       ` Masami Hiramatsu
2015-04-14  7:04         ` Masami Hiramatsu
2015-04-14 12:17         ` Arnaldo Carvalho de Melo
2015-04-14 12:17           ` Arnaldo Carvalho de Melo
2015-04-14 12:12       ` Ingo Molnar
2015-04-14 12:12         ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428963302-31538-5-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=hekuang@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.