tools/perf/util/callchain.c
Source file repositories/reference/linux-study-clean/tools/perf/util/callchain.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/callchain.c- Extension
.c- Size
- 46454 bytes
- Lines
- 1929
- 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
inttypes.hstdlib.hstdio.hstdbool.herrno.hmath.hlinux/string.hlinux/zalloc.hasm/bug.hdebug.hdso.hevent.hhist.hsort.hmachine.hmap.hcallchain.hbranch.hrecord.hsymbol.hthread.hutil.h../perf.h
Detected Declarations
enum match_resultfunction parse_callchain_record_optfunction parse_callchain_modefunction parse_callchain_orderfunction parse_callchain_sort_keyfunction parse_callchain_valuefunction get_stack_sizefunction __parse_callchain_report_optfunction parse_callchain_report_optfunction parse_callchain_top_optfunction parse_callchain_recordfunction callchain_debugfunction record_opts__parse_callchainfunction perf_callchain_configfunction rb_insert_callchainfunction __sort_chain_flatfunction sort_chain_flatfunction __sort_chain_graph_absfunction sort_chain_graph_absfunction __sort_chain_graph_relfunction sort_chain_graph_relfunction callchain_register_paramfunction create_childfunction fill_nodefunction add_childfunction list_for_each_entry_safefunction match_chain_stringsfunction match_chain_dso_addressesfunction match_chainfunction partsfunction append_chain_childrenfunction append_chainfunction callchain_appendfunction merge_chain_branchfunction list_for_each_entry_safefunction callchain_mergefunction callchain_cursor_appendfunction sample__resolve_callchainfunction hist_entry__append_callchainfunction fill_callchain_infofunction callchain_node__fprintf_valuefunction callchain_counts_valuefunction list_for_each_entryfunction callchain_node_branch_counts_cumulfunction callchain_branch_countsfunction count_pri64_printffunction count_float_printffunction branch_to_str
Annotated Snippet
if (!strncmp(tok, "none", strlen(tok))) {
callchain_param.mode = CHAIN_NONE;
callchain_param.enabled = false;
symbol_conf.use_callchain = false;
goto out;
}
if (!parse_callchain_mode(tok) ||
!parse_callchain_order(tok) ||
!parse_callchain_sort_key(tok) ||
!parse_callchain_value(tok)) {
/* parsing ok - move on to the next */
try_stack_size = false;
goto next;
} else if (allow_record_opt && !record_opt_set) {
if (parse_callchain_record(tok, &callchain_param))
goto try_numbers;
/* assume that number followed by 'dwarf' is stack size */
if (callchain_param.record_mode == CALLCHAIN_DWARF)
try_stack_size = true;
record_opt_set = true;
goto next;
}
try_numbers:
if (try_stack_size) {
unsigned long size = 0;
if (get_stack_size(tok, &size) < 0)
goto err_out;
callchain_param.dump_size = size;
try_stack_size = false;
} else if (!minpcnt_set) {
/* try to get the min percent */
callchain_param.min_percent = strtod(tok, &endptr);
if (tok == endptr)
goto err_out;
minpcnt_set = true;
} else {
/* try print limit at last */
callchain_param.print_limit = strtoul(tok, &endptr, 0);
if (tok == endptr)
goto err_out;
}
next:
tok = strtok_r(NULL, ",", &saveptr);
}
if (callchain_register_param(&callchain_param) < 0) {
pr_err("Can't register callchain params\n");
goto err_out;
}
out:
free(arg_copy);
return 0;
err_out:
free(arg_copy);
return -1;
}
int parse_callchain_report_opt(const char *arg)
{
return __parse_callchain_report_opt(arg, false);
}
int parse_callchain_top_opt(const char *arg)
{
return __parse_callchain_report_opt(arg, true);
}
int parse_callchain_record(const char *arg, struct callchain_param *param)
{
char *tok, *name, *saveptr = NULL;
char *buf;
int ret = -1;
/* We need buffer that we know we can write to. */
buf = strdup(arg);
if (!buf)
return -ENOMEM;
tok = strtok_r(buf, ",", &saveptr);
name = tok ? : buf;
do {
/* Framepointer style */
if (!strncmp(name, "fp", sizeof("fp"))) {
ret = 0;
Annotation
- Immediate include surface: `inttypes.h`, `stdlib.h`, `stdio.h`, `stdbool.h`, `errno.h`, `math.h`, `linux/string.h`, `linux/zalloc.h`.
- Detected declarations: `enum match_result`, `function parse_callchain_record_opt`, `function parse_callchain_mode`, `function parse_callchain_order`, `function parse_callchain_sort_key`, `function parse_callchain_value`, `function get_stack_size`, `function __parse_callchain_report_opt`, `function parse_callchain_report_opt`, `function parse_callchain_top_opt`.
- 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.