aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-12-08 17:02:54 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-09 01:26:51 -0500
commitd1bde3f755e8652faad59e264c466c4baab68fa8 (patch)
tree1aacc8a52b0095c1feb2fc32baf5a846eb11335e /tools
parenta9b495b0d35859971d6896293f6d0a0d880c7dfb (diff)
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: Masami 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: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-probe.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 8993a1f4e1c3..1347fdf5337e 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)
79 pr_debug("%d arguments\n", pp->nr_args); 79 pr_debug("%d arguments\n", pp->nr_args);
80} 80}
81 81
82static void parse_probe_event_argv(int argc, const char **argv)
83{
84 int i, len;
85 char *buf;
86
87 /* Bind up rest arguments */
88 len = 0;
89 for (i = 0; i < argc; i++)
90 len += strlen(argv[i]) + 1;
91 buf = zalloc(len + 1);
92 if (!buf)
93 die("Failed to allocate memory for binding arguments.");
94 len = 0;
95 for (i = 0; i < argc; i++)
96 len += sprintf(&buf[len], "%s ", argv[i]);
97 parse_probe_event(buf);
98 free(buf);
99}
100
82static int opt_add_probe_event(const struct option *opt __used, 101static int opt_add_probe_event(const struct option *opt __used,
83 const char *str, int unset __used) 102 const char *str, int unset __used)
84{ 103{
@@ -160,7 +179,7 @@ static const struct option options[] = {
160 179
161int cmd_probe(int argc, const char **argv, const char *prefix __used) 180int cmd_probe(int argc, const char **argv, const char *prefix __used)
162{ 181{
163 int i, j, ret; 182 int i, ret;
164#ifndef NO_LIBDWARF 183#ifndef NO_LIBDWARF
165 int fd; 184 int fd;
166#endif 185#endif
@@ -168,8 +187,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
168 187
169 argc = parse_options(argc, argv, options, probe_usage, 188 argc = parse_options(argc, argv, options, probe_usage,
170 PARSE_OPT_STOP_AT_NON_OPTION); 189 PARSE_OPT_STOP_AT_NON_OPTION);
171 for (i = 0; i < argc; i++) 190 if (argc > 0)
172 parse_probe_event(argv[i]); 191 parse_probe_event_argv(argc, argv);
173 192
174 if ((session.nr_probe == 0 && !listing) || 193 if ((session.nr_probe == 0 && !listing) ||
175 (session.nr_probe != 0 && listing)) 194 (session.nr_probe != 0 && listing))
@@ -200,8 +219,8 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
200 } 219 }
201 220
202 /* Searching probe points */ 221 /* Searching probe points */
203 for (j = 0; j < session.nr_probe; j++) { 222 for (i = 0; i < session.nr_probe; i++) {
204 pp = &session.probes[j]; 223 pp = &session.probes[i];
205 if (pp->found) 224 if (pp->found)
206 continue; 225 continue;
207 226
@@ -223,8 +242,8 @@ end_dwarf:
223#endif /* !NO_LIBDWARF */ 242#endif /* !NO_LIBDWARF */
224 243
225 /* Synthesize probes without dwarf */ 244 /* Synthesize probes without dwarf */
226 for (j = 0; j < session.nr_probe; j++) { 245 for (i = 0; i < session.nr_probe; i++) {
227 pp = &session.probes[j]; 246 pp = &session.probes[i];
228 if (pp->found) /* This probe is already found. */ 247 if (pp->found) /* This probe is already found. */
229 continue; 248 continue;
230 249