tools/perf/util/event.c
Source file repositories/reference/linux-study-clean/tools/perf/util/event.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/event.c- Extension
.c- Size
- 27015 bytes
- Lines
- 934
- 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
errno.hfcntl.hinttypes.hlinux/compiler.hlinux/kernel.hlinux/types.hperf/cpumap.hperf/event.hstdio.hsys/types.hsys/stat.hunistd.huapi/linux/mman.hlinux/perf_event.hcpumap.hdso.hevent.hdebug.hhist.hmachine.hsort.hstring2.hstrlist.hthread.hthread_map.htime-utils.hlinux/ctype.hmap.hutil/namespaces.hsymbol.hsymbol/kallsyms.hasm/bug.h
Detected Declarations
struct process_symbol_argsfunction find_func_symbol_cbfunction find_any_symbol_cbfunction kallsyms__get_function_startfunction kallsyms__get_symbol_startfunction perf_event__read_stat_configfunction perf_event__fprintf_commfunction perf_event__fprintf_namespacesfunction perf_event__fprintf_cgroupfunction perf_event__process_commfunction perf_event__process_namespacesfunction perf_event__process_cgroupfunction perf_event__process_lostfunction perf_event__process_auxfunction perf_event__process_itrace_startfunction perf_event__process_aux_output_hw_idfunction perf_event__process_lost_samplesfunction perf_event__process_switchfunction perf_event__process_ksymbolfunction perf_event__process_bpffunction perf_event__process_text_pokefunction perf_event__fprintf_mmapfunction perf_event__fprintf_mmap2function perf_event__fprintf_thread_mapfunction perf_event__fprintf_cpu_mapfunction perf_event__process_mmapfunction perf_event__process_mmap2function perf_event__fprintf_taskfunction perf_event__process_forkfunction perf_event__process_exitfunction perf_event__exit_del_threadfunction perf_event__fprintf_auxfunction perf_event__fprintf_itrace_startfunction perf_event__fprintf_aux_output_hw_idfunction perf_event__fprintf_switchfunction perf_event__fprintf_lostfunction perf_event__fprintf_ksymbolfunction perf_event__fprintf_bpffunction perf_event__fprintf_bpf_metadatafunction text_poke_printerfunction perf_event__fprintf_text_pokefunction perf_event__fprintf_schedstat_cpufunction perf_event__fprintf_schedstat_domainfunction perf_event__fprintffunction perf_event__processfunction check_address_rangefunction intlist__for_each_entryfunction machine__findnew_thread
Annotated Snippet
event->context_switch.next_prev_pid,
event->context_switch.next_prev_tid);
}
static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp)
{
return fprintf(fp, " lost %" PRI_lu64 "\n", event->lost.lost);
}
size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp)
{
return fprintf(fp, " addr %" PRI_lx64 " len %u type %u flags 0x%x name %s\n",
event->ksymbol.addr, event->ksymbol.len,
event->ksymbol.ksym_type,
event->ksymbol.flags, event->ksymbol.name);
}
size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp)
{
return fprintf(fp, " type %u, flags %u, id %u\n",
event->bpf.type, event->bpf.flags, event->bpf.id);
}
size_t perf_event__fprintf_bpf_metadata(union perf_event *event, FILE *fp)
{
struct perf_record_bpf_metadata *metadata = &event->bpf_metadata;
size_t ret;
ret = fprintf(fp, " prog %s\n", metadata->prog_name);
for (__u32 i = 0; i < metadata->nr_entries; i++) {
ret += fprintf(fp, " entry %d: %20s = %s\n", i,
metadata->entries[i].key,
metadata->entries[i].value);
}
return ret;
}
static int text_poke_printer(enum binary_printer_ops op, unsigned int val,
void *extra, FILE *fp)
{
bool old = *(bool *)extra;
switch ((int)op) {
case BINARY_PRINT_LINE_BEGIN:
return fprintf(fp, " %s bytes:", old ? "Old" : "New");
case BINARY_PRINT_NUM_DATA:
return fprintf(fp, " %02x", val);
case BINARY_PRINT_LINE_END:
return fprintf(fp, "\n");
default:
return 0;
}
}
size_t perf_event__fprintf_text_poke(union perf_event *event, struct machine *machine, FILE *fp)
{
struct perf_record_text_poke_event *tp = &event->text_poke;
size_t ret;
bool old;
ret = fprintf(fp, " %" PRI_lx64 " ", tp->addr);
if (machine) {
struct addr_location al;
addr_location__init(&al);
al.map = maps__find(machine__kernel_maps(machine), tp->addr);
if (al.map && map__load(al.map) >= 0) {
al.addr = map__map_ip(al.map, tp->addr);
al.sym = map__find_symbol(al.map, al.addr);
if (al.sym)
ret += symbol__fprintf_symname_offs(al.sym, &al, fp);
}
addr_location__exit(&al);
}
ret += fprintf(fp, " old len %u new len %u\n", tp->old_len, tp->new_len);
old = true;
ret += binary__fprintf(tp->bytes, tp->old_len, 16, text_poke_printer,
&old, fp);
old = false;
ret += binary__fprintf(tp->bytes + tp->old_len, tp->new_len, 16,
text_poke_printer, &old, fp);
return ret;
}
size_t perf_event__fprintf_schedstat_cpu(union perf_event *event, FILE *fp)
{
struct perf_record_schedstat_cpu *cs = &event->schedstat_cpu;
size_t size = fprintf(fp, "\ncpu%u ", cs->cpu);
__u16 version = cs->version;
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `inttypes.h`, `linux/compiler.h`, `linux/kernel.h`, `linux/types.h`, `perf/cpumap.h`, `perf/event.h`.
- Detected declarations: `struct process_symbol_args`, `function find_func_symbol_cb`, `function find_any_symbol_cb`, `function kallsyms__get_function_start`, `function kallsyms__get_symbol_start`, `function perf_event__read_stat_config`, `function perf_event__fprintf_comm`, `function perf_event__fprintf_namespaces`, `function perf_event__fprintf_cgroup`, `function perf_event__process_comm`.
- 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.