tools/perf/builtin-trace.c

Source file repositories/reference/linux-study-clean/tools/perf/builtin-trace.c

File Facts

System
Linux kernel
Corpus path
tools/perf/builtin-trace.c
Extension
.c
Size
167890 bytes
Lines
5794
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

struct syscall_arg_fmt {
	size_t	   (*scnprintf)(char *bf, size_t size, struct syscall_arg *arg);
	bool	   (*strtoul)(char *bf, size_t size, struct syscall_arg *arg, u64 *val);
	unsigned long (*mask_val)(struct syscall_arg *arg, unsigned long val);
	void	   *parm;
	const char *name;
	u16	   nr_entries; // for arrays
	bool	   from_user;
	bool	   show_zero;
#ifdef HAVE_LIBBPF_SUPPORT
	const struct btf_type *type;
	int	   type_id; /* used in btf_dump */
#endif
};

struct syscall_fmt {
	const char *name;
	const char *alias;
	struct {
		const char *sys_enter,
			   *sys_exit;
	}	   bpf_prog_name;
	struct syscall_arg_fmt arg[RAW_SYSCALL_ARGS_NUM];
	u8	   nr_args;
	bool	   errpid;
	bool	   timeout;
	bool	   hexret;
};

struct trace {
	struct perf_env		host_env;
	struct perf_tool	tool;
	struct {
		/** Sorted sycall numbers used by the trace. */
		struct syscall  **table;
		/** Size of table. */
		size_t		table_size;
		struct {
			struct evsel *sys_enter,
				*sys_exit,
				*bpf_output;
		}		events;
	} syscalls;
#ifdef HAVE_LIBBPF_SUPPORT
	struct btf		*btf;
#endif
	struct record_opts	opts;
	struct evlist	*evlist;
	struct machine		*host;
	struct thread		*current;
	struct cgroup		*cgroup;
	u64			base_time;
	FILE			*output;
	unsigned long		nr_events;
	unsigned long		nr_events_printed;
	unsigned long		max_events;
	struct evswitch		evswitch;
	struct strlist		*ev_qualifier;
	struct {
		size_t		nr;
		int		*entries;
	}			ev_qualifier_ids;
	struct {
		size_t		nr;
		pid_t		*entries;
		struct bpf_map  *map;
	}			filter_pids;
	/*
	 * TODO: The map is from an ID (aka system call number) to struct
	 * syscall_stats. If there is >1 e_machine, such as i386 and x86-64
	 * processes, then the stats here will gather wrong the statistics for
	 * the non EM_HOST system calls. A fix would be to add the e_machine
	 * into the key, but this would make the code inconsistent with the
	 * per-thread version.
	 */
	struct hashmap		*syscall_stats;
	double			duration_filter;
	double			runtime_ms;
	unsigned long		pfmaj, pfmin;
	struct {
		u64		vfs_getname,
				proc_getname;
	} stats;
	unsigned int		max_stack;
	unsigned int		min_stack;
	enum trace_summary_mode	summary_mode;
	int			max_summary;
	int			raw_augmented_syscalls_args_size;
	bool			raw_augmented_syscalls;
	bool			fd_path_disabled;

Annotation

Implementation Notes