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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-73eff9f56e15598c8399c0b86899fd889b97f085@git.kernel.org>
Date:	Mon, 14 May 2012 06:41:15 -0700
From:	tip-bot for Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	acme@...hat.com, mingo@...nel.org, torvalds@...ux-foundation.org,
	peterz@...radead.org, anton@...hat.com, rostedt@...dmis.org,
	jkenisto@...ux.vnet.ibm.com, akpm@...ux-foundation.org,
	oleg@...hat.com, tglx@...utronix.de, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, hpa@...or.com, andi@...stfloor.org,
	hch@...radead.org, ananth@...ibm.com,
	masami.hiramatsu.pt@...achi.com, srikar@...ux.vnet.ibm.com,
	mingo@...e.hu
Subject: [tip:perf/uprobes] perf probe: Detect probe target when m/
 x options are absent

Commit-ID:  73eff9f56e15598c8399c0b86899fd889b97f085
Gitweb:     http://git.kernel.org/tip/73eff9f56e15598c8399c0b86899fd889b97f085
Author:     Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
AuthorDate: Mon, 16 Apr 2012 17:39:25 +0530
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Fri, 11 May 2012 13:58:53 -0300

perf probe: Detect probe target when m/x options are absent

Options -m and -x explicitly allow tracing of modules / user space
binaries. In absense of these options, check if the first argument can
be used as a target.

perf probe /bin/zsh zfree is equivalent to perf probe -x /bin/zsh zfree.

Suggested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Ananth N Mavinakayanahalli <ananth@...ibm.com>
Cc: Andi Kleen <andi@...stfloor.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Anton Arapov <anton@...hat.com>
Cc: Christoph Hellwig <hch@...radead.org>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Jim Keniston <jkenisto@...ux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Linux-mm <linux-mm@...ck.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Link: http://lkml.kernel.org/r/20120416120925.30661.40409.sendpatchset@srdronam.in.ibm.com
Signed-off-by: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/Documentation/perf-probe.txt |    8 ++++-
 tools/perf/builtin-probe.c              |   43 ++++++++++++++++++++++++++++--
 2 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index fb673be..b715cb7 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -104,6 +104,10 @@ OPTIONS
 	Specify path to the executable or shared library file for user
 	space tracing. Can also be used with --funcs option.
 
+In absence of -m/-x options, perf probe checks if the first argument after
+the options is an absolute path name. If its an absolute path, perf probe
+uses it as a target module/target user space binary to probe.
+
 PROBE SYNTAX
 ------------
 Probe points are defined by following syntax.
@@ -190,11 +194,11 @@ Delete all probes on schedule().
 
 Add probes at zfree() function on /bin/zsh
 
- ./perf probe -x /bin/zsh zfree
+ ./perf probe -x /bin/zsh zfree or ./perf probe /bin/zsh zfree
 
 Add probes at malloc() function on libc
 
- ./perf probe -x /lib/libc.so.6 malloc
+ ./perf probe -x /lib/libc.so.6 malloc or ./perf probe /lib/libc.so.6 malloc
 
 SEE ALSO
 --------
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index ee3d84a..e215ae6 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -85,21 +85,58 @@ static int parse_probe_event(const char *str)
 	return ret;
 }
 
+static int set_target(const char *ptr)
+{
+	int found = 0;
+	const char *buf;
+
+	/*
+	 * The first argument after options can be an absolute path
+	 * to an executable / library or kernel module.
+	 *
+	 * TODO: Support relative path, and $PATH, $LD_LIBRARY_PATH,
+	 * short module name.
+	 */
+	if (!params.target && ptr && *ptr == '/') {
+		params.target = ptr;
+		found = 1;
+		buf = ptr + (strlen(ptr) - 3);
+
+		if (strcmp(buf, ".ko"))
+			params.uprobes = true;
+
+	}
+
+	return found;
+}
+
 static int parse_probe_event_argv(int argc, const char **argv)
 {
-	int i, len, ret;
+	int i, len, ret, found_target;
 	char *buf;
 
+	found_target = set_target(argv[0]);
+	if (found_target && argc == 1)
+		return 0;
+
 	/* Bind up rest arguments */
 	len = 0;
-	for (i = 0; i < argc; i++)
+	for (i = 0; i < argc; i++) {
+		if (i == 0 && found_target)
+			continue;
+
 		len += strlen(argv[i]) + 1;
+	}
 	buf = zalloc(len + 1);
 	if (buf == NULL)
 		return -ENOMEM;
 	len = 0;
-	for (i = 0; i < argc; i++)
+	for (i = 0; i < argc; i++) {
+		if (i == 0 && found_target)
+			continue;
+
 		len += sprintf(&buf[len], "%s ", argv[i]);
+	}
 	params.mod_events = true;
 	ret = parse_probe_event(buf);
 	free(buf);
--
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