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.

Dependency Surface

Detected Declarations

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, &params->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 = &params->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

Implementation Notes