tools/perf/builtin-probe.c
Source file repositories/reference/linux-study-clean/tools/perf/builtin-probe.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/builtin-probe.c- Extension
.c- Size
- 19947 bytes
- Lines
- 771
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sys/utsname.hsys/types.hsys/stat.hfcntl.herrno.hstdio.hunistd.hstdlib.hstring.hbuiltin.hnamespaces.hutil/build-id.hutil/strlist.hutil/strfilter.hutil/symbol.hutil/symbol_conf.hutil/debug.hsubcmd/parse-options.hutil/probe-finder.hutil/probe-event.hutil/probe-file.hlinux/string.hlinux/zalloc.h
Detected Declarations
function parse_probe_eventfunction params_add_filterfunction set_targetfunction parse_probe_event_argvfunction opt_set_targetfunction opt_set_target_nsfunction opt_show_linesfunction opt_show_varsfunction opt_add_probe_eventfunction opt_set_filter_with_commandfunction opt_set_filterfunction init_paramsfunction cleanup_paramsfunction pr_err_with_codefunction perf_add_probe_eventsfunction del_perf_probe_cachesfunction strlist__for_each_entryfunction perf_del_probe_eventsfunction __cmd_probefunction cmd_probe
Annotated Snippet
if (params->uprobes || strchr(str, '/')) {
tmp = nsinfo__realpath(str, params->nsi);
if (!tmp) {
pr_warning("Failed to get the absolute path of %s: %m\n", str);
return ret;
}
} else {
tmp = strdup(str);
if (!tmp)
return -ENOMEM;
}
free(params->target);
params->target = tmp;
params->target_used = false;
ret = 0;
}
return ret;
}
static int opt_set_target_ns(const struct option *opt __maybe_unused,
const char *str, int unset __maybe_unused)
{
int ret = -ENOENT;
pid_t ns_pid;
struct nsinfo *nsip;
if (str) {
errno = 0;
ns_pid = (pid_t)strtol(str, NULL, 10);
if (errno != 0) {
ret = -errno;
pr_warning("Failed to parse %s as a pid: %m\n", str);
return ret;
}
nsip = nsinfo__new(ns_pid);
if (nsip && nsinfo__need_setns(nsip))
params->nsi = nsinfo__get(nsip);
nsinfo__put(nsip);
ret = 0;
}
return ret;
}
/* Command option callbacks */
#ifdef HAVE_LIBDW_SUPPORT
static int opt_show_lines(const struct option *opt,
const char *str, int unset __maybe_unused)
{
int ret = 0;
if (!str)
return 0;
if (params->command == 'L') {
pr_warning("Warning: more than one --line options are"
" detected. Only the first one is valid.\n");
return 0;
}
params->command = opt->short_name;
ret = parse_line_range_desc(str, ¶ms->line_range);
return ret;
}
static int opt_show_vars(const struct option *opt,
const char *str, int unset __maybe_unused)
{
struct perf_probe_event *pev = ¶ms->events[params->nevents];
int ret;
if (!str)
return 0;
ret = parse_probe_event(str);
if (!ret && pev->nargs != 0) {
pr_err(" Error: '--vars' doesn't accept arguments.\n");
return -EINVAL;
}
params->command = opt->short_name;
return ret;
}
#else
# define opt_show_lines NULL
Annotation
- Immediate include surface: `sys/utsname.h`, `sys/types.h`, `sys/stat.h`, `fcntl.h`, `errno.h`, `stdio.h`, `unistd.h`, `stdlib.h`.
- Detected declarations: `function parse_probe_event`, `function params_add_filter`, `function set_target`, `function parse_probe_event_argv`, `function opt_set_target`, `function opt_set_target_ns`, `function opt_show_lines`, `function opt_show_vars`, `function opt_add_probe_event`, `function opt_set_filter_with_command`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.