aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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