tools/perf/util/trace-event-info.c
Source file repositories/reference/linux-study-clean/tools/perf/util/trace-event-info.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/trace-event-info.c- Extension
.c- Size
- 13159 bytes
- Lines
- 704
- 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
dirent.hmntent.hstdio.hstdlib.hstring.hstdarg.hsys/types.hsys/stat.hsys/wait.hfcntl.hunistd.herrno.hstdbool.hlinux/list.hlinux/kernel.hlinux/zalloc.hinternal/lib.hsys/param.htrace-event.htracepoint.hapi/fs/tracing_path.hevsel.hdebug.hutil.h
Detected Declarations
struct tracepoint_pathfunction record_filefunction record_header_filesfunction name_in_tp_listfunction for_each_event_tpsfunction record_ftrace_filesfunction system_in_tp_listfunction record_event_filesfunction for_each_event_tpsfunction record_proc_kallsymsfunction record_ftrace_printkfunction record_saved_cmdlinefunction put_tracepoints_pathfunction for_each_subsystemfunction for_each_eventfunction get_tracepoints_pathfunction list_for_each_entryfunction have_tracepointsfunction tracing_data_headerfunction tracing_data_putfunction read_tracing_data
Annotated Snippet
struct tracepoint_path {
char *system;
char *name;
struct tracepoint_path *next;
};
/* unfortunately, you can not stat debugfs or proc files for size */
static int record_file(const char *file, ssize_t hdr_sz)
{
unsigned long long size = 0;
char buf[BUFSIZ], *sizep;
off_t hdr_pos = lseek(output_fd, 0, SEEK_CUR);
int r, fd;
int err = -EIO;
fd = open(file, O_RDONLY);
if (fd < 0) {
pr_debug("Can't read '%s'", file);
return -errno;
}
/* put in zeros for file size, then fill true size later */
if (hdr_sz) {
if (write(output_fd, &size, hdr_sz) != hdr_sz)
goto out;
}
do {
r = read(fd, buf, BUFSIZ);
if (r > 0) {
size += r;
if (write(output_fd, buf, r) != r)
goto out;
}
} while (r > 0);
/* ugh, handle big-endian hdr_size == 4 */
sizep = (char*)&size;
if (host_is_bigendian())
sizep += sizeof(u64) - hdr_sz;
if (hdr_sz && pwrite(output_fd, sizep, hdr_sz, hdr_pos) < 0) {
pr_debug("writing file size failed\n");
goto out;
}
err = 0;
out:
close(fd);
return err;
}
static int record_header_files(void)
{
char *path = get_events_file("header_page");
struct stat st;
int err = -EIO;
if (!path) {
pr_debug("can't get tracing/events/header_page");
return -ENOMEM;
}
if (stat(path, &st) < 0) {
pr_debug("can't read '%s'", path);
goto out;
}
if (write(output_fd, "header_page", 12) != 12) {
pr_debug("can't write header_page\n");
goto out;
}
if (record_file(path, 8) < 0) {
pr_debug("can't record header_page file\n");
goto out;
}
put_events_file(path);
path = get_events_file("header_event");
if (!path) {
pr_debug("can't get tracing/events/header_event");
err = -ENOMEM;
goto out;
}
if (stat(path, &st) < 0) {
pr_debug("can't read '%s'", path);
goto out;
Annotation
- Immediate include surface: `dirent.h`, `mntent.h`, `stdio.h`, `stdlib.h`, `string.h`, `stdarg.h`, `sys/types.h`, `sys/stat.h`.
- Detected declarations: `struct tracepoint_path`, `function record_file`, `function record_header_files`, `function name_in_tp_list`, `function for_each_event_tps`, `function record_ftrace_files`, `function system_in_tp_list`, `function record_event_files`, `function for_each_event_tps`, `function record_proc_kallsyms`.
- 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.