public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Ingo Molnar <mingo@elte.hu>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	        lkml<linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	        Jim Keniston <jkenisto@us.ibm.com>,
	        Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	        Christoph Hellwig <hch@infradead.org>,
	        "Frank Ch. Eigler" <fche@redhat.com>,
	        Frederic Weisbecker <fweisbec@gmail.com>,
	        Jason Baron <jbaron@redhat.com>,
	        "K.Prasad" <prasad@linux.vnet.ibm.com>,
	        Peter Zijlstra <peterz@infradead.org>,
	        Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	        Arnaldo Carvalho de Melo <acme@redhat.com>,
	        systemtap<systemtap@sources.redhat.com>,
	        DLE<dle-develop@lists.sourceforge.net>
Subject: [PATCH -tip 3/8] perf probe: Fix add-probe command syntax without 	--add option
Date: Tue, 08 Dec 2009 21:58:00 -0000	[thread overview]
Message-ID: <20091208220254.10142.73767.stgit@dhcp-100-2-132.bos.redhat.com> (raw)
In-Reply-To: <20091208220232.10142.2643.stgit@dhcp-100-2-132.bos.redhat.com>

Fix add-probe command syntax without --add option.
perf-probe supports add-probe command without --add
option. But it treats each argument as an event definition.
e.g.

perf probe func arg1 arg2

 is interpreted as

perf probe --add func --add arg1 --add arg2

But it may be useless in many cases.

This patch fixes this syntax to fold those arguments into
one event definition if there is no --add option. With this
change, above command is interpreted as below;

perf probe --add "func arg1 arg2"

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---

 tools/perf/builtin-probe.c |   33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 8993a1f..1347fdf 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -79,6 +79,25 @@ static void parse_probe_event(const char *str)
 	pr_debug("%d arguments\n", pp->nr_args);
 }
 
+static void parse_probe_event_argv(int argc, const char **argv)
+{
+	int i, len;
+	char *buf;
+
+	/* Bind up rest arguments */
+	len = 0;
+	for (i = 0; i < argc; i++)
+		len += strlen(argv[i]) + 1;
+	buf = zalloc(len + 1);
+	if (!buf)
+		die("Failed to allocate memory for binding arguments.");
+	len = 0;
+	for (i = 0; i < argc; i++)
+		len += sprintf(&buf[len], "%s ", argv[i]);
+	parse_probe_event(buf);
+	free(buf);
+}
+
 static int opt_add_probe_event(const struct option *opt __used,
 			      const char *str, int unset __used)
 {
@@ -160,7 +179,7 @@ static const struct option options[] = {
 
 int cmd_probe(int argc, const char **argv, const char *prefix __used)
 {
-	int i, j, ret;
+	int i, ret;
 #ifndef NO_LIBDWARF
 	int fd;
 #endif
@@ -168,8 +187,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
 
 	argc = parse_options(argc, argv, options, probe_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
-	for (i = 0; i < argc; i++)
-		parse_probe_event(argv[i]);
+	if (argc > 0)
+		parse_probe_event_argv(argc, argv);
 
 	if ((session.nr_probe == 0 && !listing) ||
 	    (session.nr_probe != 0 && listing))
@@ -200,8 +219,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
 	}
 
 	/* Searching probe points */
-	for (j = 0; j < session.nr_probe; j++) {
-		pp = &session.probes[j];
+	for (i = 0; i < session.nr_probe; i++) {
+		pp = &session.probes[i];
 		if (pp->found)
 			continue;
 
@@ -223,8 +242,8 @@ end_dwarf:
 #endif /* !NO_LIBDWARF */
 
 	/* Synthesize probes without dwarf */
-	for (j = 0; j < session.nr_probe; j++) {
-		pp = &session.probes[j];
+	for (i = 0; i < session.nr_probe; i++) {
+		pp = &session.probes[i];
 		if (pp->found)	/* This probe is already found. */
 			continue;
 


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

  parent reply	other threads:[~2009-12-08 21:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08 21:58 [PATCH -tip 0/8] perf-probe updates Masami Hiramatsu
2009-12-08 21:58 ` [PATCH -tip 2/8] perf probe: Change probe-added message more user-friendly Masami Hiramatsu
2009-12-09  7:27   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2009-12-08 21:58 ` [PATCH -tip 5/8] perf probe: Support vmlinux on cwd by default Masami Hiramatsu
2009-12-09  7:27   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2009-12-08 21:58 ` [PATCH -tip 1/8] perf probe: Change event list format Masami Hiramatsu
2009-12-09  7:28   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2009-12-08 21:58 ` [PATCH -tip 6/8] trace-kprobe: Support delete probe syntax Masami Hiramatsu
2009-12-09  7:27   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2009-12-08 21:58 ` Masami Hiramatsu [this message]
2009-12-09  7:28   ` [tip:perf/urgent] perf probe: Fix add-probe command syntax without --add option tip-bot for Masami Hiramatsu
2009-12-08 21:59 ` [PATCH -tip 8/8] perf probe: Update perf-probe document Masami Hiramatsu
2009-12-09  7:28   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2009-12-08 21:59 ` [PATCH -tip 7/8] perf probe: Support --del option Masami Hiramatsu
2009-12-09  7:27   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2009-12-08 21:59 ` [PATCH -tip 4/8] perf probe: Remove event suffix number _0 Masami Hiramatsu
2009-12-09  7:29   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2009-12-09  7:22 ` [PATCH -tip 0/8] perf-probe updates Ingo Molnar
2009-12-09  8:44   ` Ingo Molnar
2009-12-09 17:36     ` Masami Hiramatsu
2009-12-09 21:41       ` Masami Hiramatsu
2009-12-11 20:51         ` Arnaldo Carvalho de Melo
2009-12-11 21:15           ` Masami Hiramatsu
2009-12-11 21:29             ` Arnaldo Carvalho de Melo

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=20091208220254.10142.73767.stgit@dhcp-100-2-132.bos.redhat.com \
    --to=mhiramat@redhat.com \
    --cc=acme@redhat.com \
    --cc=ananth@in.ibm.com \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hch@infradead.org \
    --cc=jbaron@redhat.com \
    --cc=jkenisto@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=prasad@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=systemtap@sources.redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).