lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1428963302-31538-5-git-send-email-acme@kernel.org>
Date:	Mon, 13 Apr 2015 19:15:01 -0300
From:	Arnaldo Carvalho de Melo <acme@...nel.org>
To:	Ingo Molnar <mingo@...nel.org>
Cc:	linux-kernel@...r.kernel.org, He Kuang <hekuang@...wei.com>,
	Namhyung Kim <namhyung@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Wang Nan <wangnan0@...wei.com>,
	Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: [PATCH 4/5] perf probe: Make --source avaiable when probe with lazy_line

From: He Kuang <hekuang@...wei.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@...wei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Wang Nan <wangnan0@...wei.com>
Link: http://lkml.kernel.org/r/1428925290-5623-2-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ