diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-probe.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index dcb406c7f82d..3370dabed15d 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -65,8 +65,8 @@ static struct { | |||
65 | 65 | ||
66 | #define semantic_error(msg ...) die("Semantic error :" msg) | 66 | #define semantic_error(msg ...) die("Semantic error :" msg) |
67 | 67 | ||
68 | static int parse_probepoint(const struct option *opt __used, | 68 | /* Parse a probe point. Note that any error must die. */ |
69 | const char *str, int unset __used) | 69 | static void parse_probepoint(const char *str) |
70 | { | 70 | { |
71 | char *argv[MAX_PROBE_ARGS + 2]; /* Event + probe + args */ | 71 | char *argv[MAX_PROBE_ARGS + 2]; /* Event + probe + args */ |
72 | int argc, i; | 72 | int argc, i; |
@@ -75,9 +75,6 @@ static int parse_probepoint(const struct option *opt __used, | |||
75 | char **event = &session.events[session.nr_probe]; | 75 | char **event = &session.events[session.nr_probe]; |
76 | int retp = 0; | 76 | int retp = 0; |
77 | 77 | ||
78 | if (!str) /* The end of probe points */ | ||
79 | return 0; | ||
80 | |||
81 | pr_debug("probe-definition(%d): %s\n", session.nr_probe, str); | 78 | pr_debug("probe-definition(%d): %s\n", session.nr_probe, str); |
82 | if (++session.nr_probe == MAX_PROBES) | 79 | if (++session.nr_probe == MAX_PROBES) |
83 | semantic_error("Too many probes"); | 80 | semantic_error("Too many probes"); |
@@ -176,6 +173,13 @@ static int parse_probepoint(const struct option *opt __used, | |||
176 | } | 173 | } |
177 | 174 | ||
178 | pr_debug("%d arguments\n", pp->nr_args); | 175 | pr_debug("%d arguments\n", pp->nr_args); |
176 | } | ||
177 | |||
178 | static int opt_add_probepoint(const struct option *opt __used, | ||
179 | const char *str, int unset __used) | ||
180 | { | ||
181 | if (str) | ||
182 | parse_probepoint(str); | ||
179 | return 0; | 183 | return 0; |
180 | } | 184 | } |
181 | 185 | ||
@@ -211,7 +215,8 @@ static int open_default_vmlinux(void) | |||
211 | #endif | 215 | #endif |
212 | 216 | ||
213 | static const char * const probe_usage[] = { | 217 | static const char * const probe_usage[] = { |
214 | "perf probe [<options>] -P 'PROBEDEF' [-P 'PROBEDEF' ...]", | 218 | "perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]", |
219 | "perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]", | ||
215 | NULL | 220 | NULL |
216 | }; | 221 | }; |
217 | 222 | ||
@@ -222,7 +227,7 @@ static const struct option options[] = { | |||
222 | OPT_STRING('k', "vmlinux", &session.vmlinux, "file", | 227 | OPT_STRING('k', "vmlinux", &session.vmlinux, "file", |
223 | "vmlinux/module pathname"), | 228 | "vmlinux/module pathname"), |
224 | #endif | 229 | #endif |
225 | OPT_CALLBACK('P', "probe", NULL, | 230 | OPT_CALLBACK('a', "add", NULL, |
226 | #ifdef NO_LIBDWARF | 231 | #ifdef NO_LIBDWARF |
227 | "p|r:[GRP/]NAME FUNC[+OFFS] [ARG ...]", | 232 | "p|r:[GRP/]NAME FUNC[+OFFS] [ARG ...]", |
228 | #else | 233 | #else |
@@ -243,7 +248,7 @@ static const struct option options[] = { | |||
243 | "\t\tARG:\tProbe argument (local variable name or\n" | 248 | "\t\tARG:\tProbe argument (local variable name or\n" |
244 | #endif | 249 | #endif |
245 | "\t\t\tkprobe-tracer argument format is supported.)\n", | 250 | "\t\t\tkprobe-tracer argument format is supported.)\n", |
246 | parse_probepoint), | 251 | opt_add_probepoint), |
247 | OPT_END() | 252 | OPT_END() |
248 | }; | 253 | }; |
249 | 254 | ||
@@ -296,8 +301,11 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) | |||
296 | char buf[MAX_CMDLEN]; | 301 | char buf[MAX_CMDLEN]; |
297 | 302 | ||
298 | argc = parse_options(argc, argv, options, probe_usage, | 303 | argc = parse_options(argc, argv, options, probe_usage, |
299 | PARSE_OPT_STOP_AT_NON_OPTION); | 304 | PARSE_OPT_STOP_AT_NON_OPTION); |
300 | if (argc || session.nr_probe == 0) | 305 | for (i = 0; i < argc; i++) |
306 | parse_probe_event(argv[i]); | ||
307 | |||
308 | if (session.nr_probe == 0) | ||
301 | usage_with_options(probe_usage, options); | 309 | usage_with_options(probe_usage, options); |
302 | 310 | ||
303 | #ifdef NO_LIBDWARF | 311 | #ifdef NO_LIBDWARF |