23 #include <sys/utsname.h>
24 #include <sys/types.h>
45 #define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*"
46 #define DEFAULT_FUNC_FILTER "!_*"
68 static int parse_probe_event(
const char *
str)
88 static int set_target(
const char *
ptr)
100 if (!
params.target && ptr && *ptr ==
'/') {
103 buf = ptr + (
strlen(ptr) - 3);
113 static int parse_probe_event_argv(
int argc,
const char **argv)
118 found_target = set_target(argv[0]);
119 if (found_target && argc == 1)
124 for (i = 0; i <
argc; i++) {
125 if (i == 0 && found_target)
128 len +=
strlen(argv[i]) + 1;
134 for (i = 0; i <
argc; i++) {
135 if (i == 0 && found_target)
138 len +=
sprintf(&buf[len],
"%s ", argv[i]);
141 ret = parse_probe_event(buf);
147 const char *
str,
int unset __maybe_unused)
151 return parse_probe_event(str);
156 static int opt_del_probe_event(
const struct option *
opt __maybe_unused,
157 const char *str,
int unset __maybe_unused)
168 static int opt_set_target(
const struct option *
opt,
const char *str,
169 int unset __maybe_unused)
173 if (str && !
params.target) {
191 static int opt_show_lines(
const struct option *opt __maybe_unused,
192 const char *str,
int unset __maybe_unused)
200 pr_warning(
"Warning: more than one --line options are"
201 " detected. Only the first one is valid.\n");
207 INIT_LIST_HEAD(&
params.line_range.line_list);
212 static int opt_show_vars(
const struct option *opt __maybe_unused,
213 const char *str,
int unset __maybe_unused)
221 ret = parse_probe_event(str);
222 if (!ret && pev->
nargs != 0) {
223 pr_err(
" Error: '--vars' doesn't accept arguments.\n");
232 static int opt_set_filter(
const struct option *opt __maybe_unused,
233 const char *str,
int unset __maybe_unused)
243 pr_err(
"Filter parse error at %td.\n", err - str + 1);
244 pr_err(
"Source: \"%s\"\n", str);
245 pr_err(
" %*c\n", (
int)(err - str + 1),
'^');
255 const char *
const probe_usage[] = {
256 "perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]",
257 "perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]",
258 "perf probe [<options>] --del '[GROUP:]EVENT' ...",
261 "perf probe [<options>] --line 'LINEDESC'",
262 "perf probe [<options>] --vars 'PROBEPOINT'",
266 const struct option options[] = {
268 "be more verbose (show parsed arguments, etc)"),
270 "list up current probe events"),
272 opt_del_probe_event),
275 "[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT"
278 "[EVENT=]FUNC[+OFF|%return] [[NAME=]ARG ...]",
280 "probe point definition, where\n"
281 "\t\tGROUP:\tGroup name (optional)\n"
282 "\t\tEVENT:\tEvent name\n"
283 "\t\tFUNC:\tFunction name\n"
284 "\t\tOFF:\tOffset from function entry (in byte)\n"
285 "\t\t%return:\tPut the probe at function return\n"
287 "\t\tSRC:\tSource code path\n"
288 "\t\tRL:\tRelative line number from function entry.\n"
289 "\t\tAL:\tAbsolute line number in file.\n"
290 "\t\tPT:\tLazy expression of line code.\n"
291 "\t\tARG:\tProbe argument (local variable name or\n"
292 "\t\t\tkprobe-tracer argument format.)\n",
294 "\t\tARG:\tProbe argument (kprobe-tracer argument format.)\n",
296 opt_add_probe_event),
298 " with existing name"),
301 "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]",
302 "Show source code lines.", opt_show_lines),
304 "FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT",
305 "Show accessible variables on PROBEDEF", opt_show_vars),
307 "Show external variables too (with --vars only)"),
309 "file",
"vmlinux pathname"),
311 "directory",
"path to kernel source"),
313 "target module name (for online) or path (for offline)",
318 "Set how many probe points can be found for a probe."),
320 "Show potential probe-able functions."),
322 "[!]FILTER",
"Set a filter (with --vars/funcs only)\n"
327 "target executable name or path", opt_set_target),
335 if (
strcmp(argv[0],
"-") == 0) {
336 pr_warning(
" Error: '-' is not supported.\n");
339 ret = parse_probe_event_argv(argc, argv);
341 pr_err(
" Error: Parse Error. (%d)\n", ret);
346 if (
params.max_probe_points == 0)
360 pr_err(
" Error: Don't use --list with --add/--del.\n");
364 pr_err(
" Error: Don't use --list with --line.\n");
368 pr_err(
" Error: Don't use --list with --vars.\n");
372 pr_err(
" Error: Don't use --list with --funcs.\n");
376 pr_warning(
" Error: Don't use --list with --exec.\n");
381 pr_err(
" Error: Failed to show event list. (%d)\n",
387 pr_err(
" Error: Don't use --funcs with"
392 pr_err(
" Error: Don't use --funcs with --line.\n");
396 pr_err(
" Error: Don't use --funcs with --vars.\n");
406 pr_err(
" Error: Failed to show functions."
414 pr_err(
" Error: Don't use --line with"
419 pr_err(
" Error: Don't use --line with --vars.\n");
425 pr_err(
" Error: Failed to show lines. (%d)\n", ret);
430 pr_err(
" Error: Don't use --vars with"
445 pr_err(
" Error: Failed to show vars. (%d)\n", ret);
454 pr_err(
" Error: Failed to delete events. (%d)\n", ret);
465 pr_err(
" Error: Failed to add events. (%d)\n", ret);