tools/perf/util/parse-events.c
Source file repositories/reference/linux-study-clean/tools/perf/util/parse-events.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/parse-events.c- Extension
.c- Size
- 80572 bytes
- Lines
- 2927
- 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
linux/hw_breakpoint.hlinux/err.hlinux/list_sort.hlinux/zalloc.hdirent.herrno.hsys/ioctl.hsys/param.hcpumap.hterm.henv.hevlist.hevsel.hsubcmd/parse-options.hparse-events.hstring2.hstrbuf.hdebug.hperf/cpumap.hutil/parse-events-bison.hutil/parse-events-flex.hpmu.hpmus.htp_pmu.hasm/bug.hui/ui.hutil/parse-branch-options.hutil/evsel_config.hutil/event.hutil/bpf-filter.hutil/stat.hutil/util.h
Detected Declarations
struct add_tracepoint_multi_argsstruct parse_events_error_entryfunction list_for_each_entryfunction fix_rawfunction list_for_each_entryfunction __add_eventfunction list_for_each_entry_continuefunction add_eventfunction parse_aliasesfunction parse_events__decode_legacy_cachefunction parse_events__filter_pmufunction tracepoint_errorfunction add_tracepointfunction add_tracepoint_multi_event_cbfunction add_tracepoint_multi_eventfunction add_tracepoint_multi_sys_cbfunction add_tracepoint_multi_sysfunction default_breakpoint_lenfunction parse_breakpoint_typefunction parse_events_add_breakpointfunction check_type_valfunction config_term_availfunction parse_events__shrink_config_termsfunction config_term_commonfunction check_pmu_is_corefunction config_term_pmufunction config_term_tracepointfunction config_attrfunction get_config_termsfunction list_for_each_entryfunction add_cfg_chgfunction list_for_each_entryfunction get_config_chgsfunction parse_events_add_tracepointfunction __parse_events_add_numericfunction parse_events_add_numericfunction config_term_percorefunction list_for_each_entryfunction parse_events_add_pmufunction config_attrfunction parse_events_multi_pmu_addfunction parse_events_multi_pmu_add_or_add_pmufunction parse_events__set_leaderfunction parse_events__modifier_listfunction __evlist__for_each_entryfunction parse_events__modifier_groupfunction parse_events__modifier_eventfunction parse_events__set_default_name
Annotated Snippet
struct add_tracepoint_multi_args {
struct parse_events_state *parse_state;
struct list_head *list;
const char *sys_glob;
const char *evt_glob;
struct parse_events_error *err;
struct parse_events_terms *head_config;
YYLTYPE *loc;
int found;
};
static int add_tracepoint_multi_event_cb(void *state, const char *sys_name, const char *evt_name)
{
struct add_tracepoint_multi_args *args = state;
int ret;
if (!strglobmatch(evt_name, args->evt_glob))
return 0;
args->found++;
ret = add_tracepoint(args->parse_state, args->list, sys_name, evt_name,
args->err, args->head_config, args->loc);
return ret;
}
static int add_tracepoint_multi_event(struct add_tracepoint_multi_args *args, const char *sys_name)
{
if (strpbrk(args->evt_glob, "*?") == NULL) {
/* Not a glob. */
args->found++;
return add_tracepoint(args->parse_state, args->list, sys_name, args->evt_glob,
args->err, args->head_config, args->loc);
}
return tp_pmu__for_each_tp_event(sys_name, args, add_tracepoint_multi_event_cb);
}
static int add_tracepoint_multi_sys_cb(void *state, const char *sys_name)
{
struct add_tracepoint_multi_args *args = state;
if (!strglobmatch(sys_name, args->sys_glob))
return 0;
return add_tracepoint_multi_event(args, sys_name);
}
static int add_tracepoint_multi_sys(struct parse_events_state *parse_state,
struct list_head *list,
const char *sys_glob, const char *evt_glob,
struct parse_events_error *err,
struct parse_events_terms *head_config, YYLTYPE *loc)
{
struct add_tracepoint_multi_args args = {
.parse_state = parse_state,
.list = list,
.sys_glob = sys_glob,
.evt_glob = evt_glob,
.err = err,
.head_config = head_config,
.loc = loc,
.found = 0,
};
int ret;
if (strpbrk(sys_glob, "*?") == NULL) {
/* Not a glob. */
ret = add_tracepoint_multi_event(&args, sys_glob);
} else {
ret = tp_pmu__for_each_tp_sys(&args, add_tracepoint_multi_sys_cb);
}
if (args.found == 0) {
tracepoint_error(err, ENOENT, sys_glob, evt_glob, loc->first_column);
return -ENOENT;
}
return ret;
}
size_t default_breakpoint_len(void)
{
#if defined(__i386__)
static int len;
if (len == 0) {
struct perf_env env = {};
perf_env__init(&env);
len = perf_env__kernel_is_64_bit(&env) ? sizeof(u64) : sizeof(long);
perf_env__exit(&env);
Annotation
- Immediate include surface: `linux/hw_breakpoint.h`, `linux/err.h`, `linux/list_sort.h`, `linux/zalloc.h`, `dirent.h`, `errno.h`, `sys/ioctl.h`, `sys/param.h`.
- Detected declarations: `struct add_tracepoint_multi_args`, `struct parse_events_error_entry`, `function list_for_each_entry`, `function fix_raw`, `function list_for_each_entry`, `function __add_event`, `function list_for_each_entry_continue`, `function add_event`, `function parse_aliases`, `function parse_events__decode_legacy_cache`.
- 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.