Commit d1bde3f7 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Ingo Molnar

perf probe: Fix add-probe command syntax without --add option

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: default avatarMasami Hiramatsu <mhiramat@redhat.com>
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>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
LKML-Reference: <20091208220254.10142.73767.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent a9b495b0
...@@ -79,6 +79,25 @@ static void parse_probe_event(const char *str) ...@@ -79,6 +79,25 @@ static void parse_probe_event(const char *str)
pr_debug("%d arguments\n", pp->nr_args); 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, static int opt_add_probe_event(const struct option *opt __used,
const char *str, int unset __used) const char *str, int unset __used)
{ {
...@@ -160,7 +179,7 @@ static const struct option options[] = { ...@@ -160,7 +179,7 @@ static const struct option options[] = {
int cmd_probe(int argc, const char **argv, const char *prefix __used) int cmd_probe(int argc, const char **argv, const char *prefix __used)
{ {
int i, j, ret; int i, ret;
#ifndef NO_LIBDWARF #ifndef NO_LIBDWARF
int fd; int fd;
#endif #endif
...@@ -168,8 +187,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) ...@@ -168,8 +187,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
argc = parse_options(argc, argv, options, probe_usage, argc = parse_options(argc, argv, options, probe_usage,
PARSE_OPT_STOP_AT_NON_OPTION); PARSE_OPT_STOP_AT_NON_OPTION);
for (i = 0; i < argc; i++) if (argc > 0)
parse_probe_event(argv[i]); parse_probe_event_argv(argc, argv);
if ((session.nr_probe == 0 && !listing) || if ((session.nr_probe == 0 && !listing) ||
(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) ...@@ -200,8 +219,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
} }
/* Searching probe points */ /* Searching probe points */
for (j = 0; j < session.nr_probe; j++) { for (i = 0; i < session.nr_probe; i++) {
pp = &session.probes[j]; pp = &session.probes[i];
if (pp->found) if (pp->found)
continue; continue;
...@@ -223,8 +242,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) ...@@ -223,8 +242,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
#endif /* !NO_LIBDWARF */ #endif /* !NO_LIBDWARF */
/* Synthesize probes without dwarf */ /* Synthesize probes without dwarf */
for (j = 0; j < session.nr_probe; j++) { for (i = 0; i < session.nr_probe; i++) {
pp = &session.probes[j]; pp = &session.probes[i];
if (pp->found) /* This probe is already found. */ if (pp->found) /* This probe is already found. */
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment