tools/perf/util/trace-event-read.c
Source file repositories/reference/linux-study-clean/tools/perf/util/trace-event-read.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/trace-event-read.c- Extension
.c- Size
- 8338 bytes
- Lines
- 481
- 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.hstdio.hstdlib.hstring.hstdarg.hsys/types.hsys/stat.hsys/wait.hsys/mman.hevent-parse.hfcntl.hunistd.herrno.htrace-event.hdebug.hutil.h
Detected Declarations
function __do_readfunction do_readfunction skipfunction read4function read8function read_proc_kallsymsfunction read_ftrace_printkfunction read_header_filesfunction read_ftrace_filefunction read_event_filefunction read_ftrace_filesfunction read_event_filesfunction read_saved_cmdlinefunction trace_report
Annotated Snippet
if (repipe) {
int retw = write(STDOUT_FILENO, buf, ret);
if (retw <= 0 || retw != ret) {
pr_debug("repiping input file");
return -1;
}
}
size -= ret;
buf += ret;
}
return rsize;
}
static int do_read(void *data, int size)
{
int r;
r = __do_read(input_fd, data, size);
if (r <= 0) {
pr_debug("reading input file (size expected=%d received=%d)",
size, r);
return -1;
}
trace_data_size += r;
return r;
}
/* If it fails, the next read will report it */
static void skip(int size)
{
char buf[BUFSIZ];
int r;
while (size) {
r = size > BUFSIZ ? BUFSIZ : size;
do_read(buf, r);
size -= r;
}
}
static unsigned int read4(struct tep_handle *pevent)
{
unsigned int data;
if (do_read(&data, 4) < 0)
return 0;
return tep_read_number(pevent, &data, 4);
}
static unsigned long long read8(struct tep_handle *pevent)
{
unsigned long long data;
if (do_read(&data, 8) < 0)
return 0;
return tep_read_number(pevent, &data, 8);
}
static char *read_string(void)
{
char buf[BUFSIZ];
char *str = NULL;
int size = 0;
off_t r;
char c;
for (;;) {
r = read(input_fd, &c, 1);
if (r < 0) {
pr_debug("reading input file");
goto out;
}
if (!r) {
pr_debug("no data");
goto out;
}
if (repipe) {
int retw = write(STDOUT_FILENO, &c, 1);
if (retw <= 0 || retw != r) {
pr_debug("repiping input file string");
goto out;
}
Annotation
- Immediate include surface: `dirent.h`, `stdio.h`, `stdlib.h`, `string.h`, `stdarg.h`, `sys/types.h`, `sys/stat.h`, `sys/wait.h`.
- Detected declarations: `function __do_read`, `function do_read`, `function skip`, `function read4`, `function read8`, `function read_proc_kallsyms`, `function read_ftrace_printk`, `function read_header_files`, `function read_ftrace_file`, `function read_event_file`.
- 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.