Lines Matching +full:x +full:- +full:tal

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * builtin-probe.c
21 #include "util/build-id.h"
27 #include <subcmd/parse-options.h>
28 #include "util/probe-finder.h"
29 #include "util/probe-event.h"
30 #include "util/probe-file.h"
55 struct perf_probe_event *pev = &params->events[params->nevents]; in parse_probe_event()
58 pr_debug("probe-definition(%d): %s\n", params->nevents, str); in parse_probe_event()
59 if (++params->nevents == MAX_PROBES) { in parse_probe_event()
61 return -1; in parse_probe_event()
64 pev->uprobes = params->uprobes; in parse_probe_event()
65 if (params->target) { in parse_probe_event()
66 pev->target = strdup(params->target); in parse_probe_event()
67 if (!pev->target) in parse_probe_event()
68 return -ENOMEM; in parse_probe_event()
69 params->target_used = true; in parse_probe_event()
72 pev->nsi = nsinfo__get(params->nsi); in parse_probe_event()
74 /* Parse a perf-probe command into event */ in parse_probe_event()
76 pr_debug("%d arguments\n", pev->nargs); in parse_probe_event()
87 if (!params->filter) { in params_add_filter()
88 params->filter = strfilter__new(str, &err); in params_add_filter()
89 if (!params->filter) in params_add_filter()
90 ret = err ? -EINVAL : -ENOMEM; in params_add_filter()
92 ret = strfilter__or(params->filter, str, &err); in params_add_filter()
94 if (ret == -EINVAL) { in params_add_filter()
95 pr_err("Filter parse error at %td.\n", err - str + 1); in params_add_filter()
97 pr_err(" %*c\n", (int)(err - str + 1), '^'); in params_add_filter()
115 if (!params->target && ptr && *ptr == '/') { in set_target()
116 params->target = strdup(ptr); in set_target()
117 if (!params->target) in set_target()
118 return -ENOMEM; in set_target()
119 params->target_used = false; in set_target()
122 buf = ptr + (strlen(ptr) - 3); in set_target()
125 params->uprobes = true; in set_target()
154 return -ENOMEM; in parse_probe_event_argv()
170 int ret = -ENOENT; in opt_set_target()
174 if (!strcmp(opt->long_name, "exec")) in opt_set_target()
175 params->uprobes = true; in opt_set_target()
176 else if (!strcmp(opt->long_name, "module")) in opt_set_target()
177 params->uprobes = false; in opt_set_target()
182 if (params->uprobes || strchr(str, '/')) { in opt_set_target()
183 tmp = nsinfo__realpath(str, params->nsi); in opt_set_target()
191 return -ENOMEM; in opt_set_target()
193 free(params->target); in opt_set_target()
194 params->target = tmp; in opt_set_target()
195 params->target_used = false; in opt_set_target()
205 int ret = -ENOENT; in opt_set_target_ns()
213 ret = -errno; in opt_set_target_ns()
220 params->nsi = nsinfo__get(nsip); in opt_set_target_ns()
241 if (params->command == 'L') { in opt_show_lines()
242 pr_warning("Warning: more than one --line options are" in opt_show_lines()
247 params->command = opt->short_name; in opt_show_lines()
248 ret = parse_line_range_desc(str, &params->line_range); in opt_show_lines()
256 struct perf_probe_event *pev = &params->events[params->nevents]; in opt_show_vars()
263 if (!ret && pev->nargs != 0) { in opt_show_vars()
264 pr_err(" Error: '--vars' doesn't accept arguments.\n"); in opt_show_vars()
265 return -EINVAL; in opt_show_vars()
267 params->command = opt->short_name; in opt_show_vars()
279 params->command = opt->short_name; in opt_add_probe_event()
290 params->command = opt->short_name; in opt_set_filter_with_command()
313 return -ENOMEM; in init_params()
315 ret = line_range__init(&params->line_range); in init_params()
325 for (i = 0; i < params->nevents; i++) in cleanup_params()
326 clear_perf_probe_event(params->events + i); in cleanup_params()
327 line_range__clear(&params->line_range); in cleanup_params()
328 zfree(&params->target); in cleanup_params()
329 strfilter__delete(params->filter); in cleanup_params()
330 nsinfo__put(params->nsi); in cleanup_params()
340 str_error_r(-err, sbuf, sizeof(sbuf)), err); in pr_err_with_code()
350 ret = init_probe_symbol_maps(pevs->uprobes); in perf_add_probe_events()
358 if (params->command == 'D') { /* it shows definition */ in perf_add_probe_events()
377 for (k = 0; k < pev->ntevs; k++) { in perf_add_probe_events()
378 struct probe_trace_event *tev = &pev->tevs[k]; in perf_add_probe_events()
380 if (!tev->event) in perf_add_probe_events()
384 show_perf_probe_event(tev->group, tev->event, pev, in perf_add_probe_events()
385 tev->point.module, false); in perf_add_probe_events()
388 event = tev->event; in perf_add_probe_events()
389 group = tev->group; in perf_add_probe_events()
405 pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", group, event); in perf_add_probe_events()
424 ret = -errno; in del_perf_probe_caches()
426 return ret ?: -ENOMEM; in del_perf_probe_caches()
430 cache = probe_cache__new(nd->s, NULL); in del_perf_probe_caches()
435 pr_warning("Failed to remove entries for %s\n", nd->s); in del_perf_probe_caches()
443 int ret, ret2, ufd = -1, kfd = -1; in perf_del_probe_events()
449 return -EINVAL; in perf_del_probe_events()
464 ret = -ENOMEM; in perf_del_probe_events()
471 pr_info("Removed event: %s\n", ent->s); in perf_del_probe_events()
476 } else if (ret == -ENOMEM) in perf_del_probe_events()
482 pr_info("Removed event: %s\n", ent->s); in perf_del_probe_events()
487 } else if (ret2 == -ENOMEM) in perf_del_probe_events()
490 if (ret == -ENOENT && ret2 == -ENOENT) in perf_del_probe_events()
521 "perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]", in __cmd_probe()
522 "perf probe [<options>] --del '[GROUP:]EVENT' ...", in __cmd_probe()
523 "perf probe --list [GROUP:]EVENT ...", in __cmd_probe()
525 "perf probe [<options>] --line 'LINEDESC'", in __cmd_probe()
526 "perf probe [<options>] --vars 'PROBEPOINT'", in __cmd_probe()
528 "perf probe [<options>] --funcs", in __cmd_probe()
551 "\t\tAL:\tAbsolute line number in file.\n" in __cmd_probe()
554 "\t\t\tkprobe-tracer argument format.)\n", in __cmd_probe()
556 "\t\tARG:\tProbe argument (kprobe-tracer argument format.)\n", in __cmd_probe()
565 "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]", in __cmd_probe()
571 "Show external variables too (with --vars only)"), in __cmd_probe()
573 "Show variables location range in scope (with --vars only)"), in __cmd_probe()
578 OPT_BOOLEAN('\0', "no-inlines", &probe_conf.no_inlines, in __cmd_probe()
581 OPT_INTEGER('\0', "max-probes", &probe_conf.max_probes, in __cmd_probe()
584 "Show potential probe-able functions.", in __cmd_probe()
587 "[!]FILTER", "Set a filter (with --vars/funcs only)\n" in __cmd_probe()
588 "\t\t\t(default: \"" DEFAULT_VAR_FILTER "\" for --vars,\n" in __cmd_probe()
589 "\t\t\t \"" DEFAULT_FUNC_FILTER "\" for --funcs)", in __cmd_probe()
591 OPT_CALLBACK('x', "exec", NULL, "executable|path", in __cmd_probe()
598 OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, in __cmd_probe()
603 OPT_CALLBACK(0, "target-ns", NULL, "pid", in __cmd_probe()
626 set_nobuild('\0', "no-inlines", true); in __cmd_probe()
636 pr_err(" Error: -v and -q are exclusive.\n"); in __cmd_probe()
637 return -EINVAL; in __cmd_probe()
639 verbose = -1; in __cmd_probe()
643 if (strcmp(argv[0], "-") == 0) { in __cmd_probe()
645 "'-' is not supported.\n"); in __cmd_probe()
647 if (params->command && params->command != 'a') { in __cmd_probe()
649 "another command except --add is set.\n"); in __cmd_probe()
656 params->command = 'a'; in __cmd_probe()
672 * Except for --list, --del and --add, other command doesn't depend in __cmd_probe()
676 if (!strchr("lda", params->command) && symbol_conf.vmlinux_name) in __cmd_probe()
679 switch (params->command) { in __cmd_probe()
681 if (params->uprobes) { in __cmd_probe()
682 pr_err(" Error: Don't use --list with --exec.\n"); in __cmd_probe()
684 parse_options_usage(NULL, options, "x", true); in __cmd_probe()
685 return -EINVAL; in __cmd_probe()
687 ret = show_perf_probe_events(params->filter); in __cmd_probe()
692 ret = show_available_funcs(params->target, params->nsi, in __cmd_probe()
693 params->filter, params->uprobes); in __cmd_probe()
699 ret = show_line_range(&params->line_range, params->target, in __cmd_probe()
700 params->nsi, params->uprobes); in __cmd_probe()
705 if (!params->filter) in __cmd_probe()
706 params->filter = strfilter__new(DEFAULT_VAR_FILTER, in __cmd_probe()
709 ret = show_available_vars(params->events, params->nevents, in __cmd_probe()
710 params->filter); in __cmd_probe()
716 ret = perf_del_probe_events(params->filter); in __cmd_probe()
723 if (probe_conf.bootconfig && params->uprobes) { in __cmd_probe()
724 pr_err(" Error: --bootconfig doesn't support uprobes.\n"); in __cmd_probe()
725 return -EINVAL; in __cmd_probe()
731 if (params->target && !params->target_used) { in __cmd_probe()
732 pr_err(" Error: -x/-m must follow the probe definitions.\n"); in __cmd_probe()
734 parse_options_usage(NULL, options, "x", true); in __cmd_probe()
735 return -EINVAL; in __cmd_probe()
738 ret = perf_add_probe_events(params->events, params->nevents); in __cmd_probe()
744 * cleanup_perf_probe_events(params->events, params->nevents), which in __cmd_probe()
749 params->nevents = 0; in __cmd_probe()