tools/perf/builtin-report.c

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

File Facts

System
Linux kernel
Corpus path
tools/perf/builtin-report.c
Extension
.c
Size
55921 bytes
Lines
1917
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

report.tool.context_switch	 = perf_event__process_switch;
	report.tool.lost		 = perf_event__process_lost;
	report.tool.read		 = process_read_event;
	report.tool.attr		 = process_attr;
#ifdef HAVE_LIBTRACEEVENT
	report.tool.tracing_data	 = perf_event__process_tracing_data;
#endif
	report.tool.build_id		 = perf_event__process_build_id;
	report.tool.id_index		 = perf_event__process_id_index;
	report.tool.auxtrace_info	 = perf_event__process_auxtrace_info;
	report.tool.auxtrace		 = perf_event__process_auxtrace;
	report.tool.event_update	 = perf_event__process_event_update;
	report.tool.feature		 = process_feature_event;
	report.tool.ordering_requires_timestamps = true;
	report.tool.merge_deferred_callchains = !dump_trace;

	session = perf_session__new(&data, &report.tool);
	if (IS_ERR(session)) {
		ret = PTR_ERR(session);
		goto exit;
	}

	ret = evswitch__init(&report.evswitch, session->evlist, stderr);
	if (ret)
		goto exit;

	if (zstd_init(&(session->zstd_data), 0) < 0)
		pr_warning("Decompression initialization failed. Reported data may be incomplete.\n");

	if (report.queue_size) {
		ordered_events__set_alloc_size(&session->ordered_events,
					       report.queue_size);
	}

	session->itrace_synth_opts = &itrace_synth_opts;

	report.session = session;

	has_br_stack = perf_header__has_feat(&session->header,
					     HEADER_BRANCH_STACK);
	if (evlist__combined_sample_type(session->evlist) & PERF_SAMPLE_STACK_USER)
		has_br_stack = false;

	setup_forced_leader(&report, session->evlist);

	if (symbol_conf.group_sort_idx && evlist__nr_groups(session->evlist) == 0) {
		parse_options_usage(NULL, options, "group-sort-idx", 0);
		ret = -EINVAL;
		goto error;
	}

	if (itrace_synth_opts.last_branch || itrace_synth_opts.add_last_branch)
		has_br_stack = true;

	if (has_br_stack && branch_call_mode)
		symbol_conf.show_branchflag_count = true;

	memset(&report.brtype_stat, 0, sizeof(struct branch_type_stat));

	/*
	 * Branch mode is a tristate:
	 * -1 means default, so decide based on the file having branch data.
	 * 0/1 means the user chose a mode.
	 */
	if (((branch_mode == -1 && has_br_stack) || branch_mode == 1) &&
	    !branch_call_mode) {
		sort__mode = SORT_MODE__BRANCH;
		symbol_conf.cumulate_callchain = false;
	}
	if (branch_call_mode) {
		callchain_param.key = CCKEY_ADDRESS;
		callchain_param.branch_callstack = true;
		symbol_conf.use_callchain = true;
		callchain_register_param(&callchain_param);
		if (sort_order == NULL)
			sort_order = CALLCHAIN_BRANCH_SORT_ORDER;
	}

	if (report.mem_mode) {
		if (sort__mode == SORT_MODE__BRANCH) {
			pr_err("branch and mem mode incompatible\n");
			goto error;
		}
		sort__mode = SORT_MODE__MEMORY;
		symbol_conf.cumulate_callchain = false;
	}

	if (symbol_conf.report_hierarchy) {
		/*
		 * The hist entries in hierarchy are added during the collpase

Annotation

Implementation Notes