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.
- 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
builtin.hutil/config.hutil/annotate.hutil/color.hutil/dso.hlinux/list.hlinux/rbtree.hlinux/err.hlinux/zalloc.hutil/map.hutil/symbol.hutil/map_symbol.hutil/mem-events.hutil/branch.hutil/callchain.hutil/values.hperf.hutil/debug.hutil/evlist.hutil/evsel.hutil/evswitch.hutil/header.hutil/mem-info.hutil/session.hutil/srcline.hutil/tool.hsubcmd/parse-options.hsubcmd/exec-cmd.hutil/parse-events.hutil/thread.hutil/sort.hutil/hist.h
Detected Declarations
struct reportstruct maps__fprintf_task_argsfunction report__configfunction hist_iter__report_callbackfunction hist_iter__branch_callbackfunction setup_forced_leaderfunction process_feature_eventfunction process_sample_eventfunction process_read_eventfunction report__setup_sample_typefunction sig_handlerfunction hists__fprintf_nr_sample_eventsfunction for_each_group_memberfunction evlist__tui_block_hists_browsefunction evlist__for_each_entryfunction evlist__tty_browse_histsfunction evlist__for_each_entryfunction report__warn_kptr_restrictfunction report__gtk_browse_histsfunction report__browse_histsfunction report__collapse_histsfunction eventfunction evlist__for_each_entryfunction hists__resort_cbfunction report__output_resortfunction evlist__for_each_entryfunction count_sample_eventfunction count_lost_samples_eventfunction stats_setupfunction stats_printfunction tasks_setupfunction maps__fprintf_task_cbfunction maps__fprintf_taskfunction thread_levelfunction task__print_levelfunction task_list_cmpfunction tasks_printfunction __cmd_reportfunction report_parse_callchain_optfunction parse_time_quantumfunction report_parse_ignore_callees_optfunction parse_branch_modefunction parse_percent_limitfunction report_parse_addr2line_configfunction process_attrfunction cmd_reportfunction tep_set_function_resolver
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
- Immediate include surface: `builtin.h`, `util/config.h`, `util/annotate.h`, `util/color.h`, `util/dso.h`, `linux/list.h`, `linux/rbtree.h`, `linux/err.h`.
- Detected declarations: `struct report`, `struct maps__fprintf_task_args`, `function report__config`, `function hist_iter__report_callback`, `function hist_iter__branch_callback`, `function setup_forced_leader`, `function process_feature_event`, `function process_sample_event`, `function process_read_event`, `function report__setup_sample_type`.
- 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.