kernel/trace/trace_probe.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_probe.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_probe.c- Extension
.c- Size
- 57425 bytes
- Lines
- 2396
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hlinux/fs.htrace_btf.htrace_probe.h
Detected Declarations
function PRINT_TYPE_FUNC_NAMEfunction PRINT_TYPE_FUNC_NAMEfunction trace_probe_log_clearfunction trace_probe_log_set_indexfunction __trace_probe_log_errfunction traceprobe_split_symbol_offsetfunction traceprobe_parse_event_namefunction parse_trace_event_argfunction parse_trace_eventfunction btf_type_intfunction btf_type_is_char_ptrfunction btf_type_is_char_arrayfunction check_prepare_btf_string_fetchfunction query_btf_contextfunction clear_struct_btffunction clear_btf_contextfunction split_next_fieldfunction parse_btf_fieldfunction parse_btf_argfunction parse_btf_bitfieldfunction query_btf_structfunction handle_typecastfunction clear_struct_btffunction clear_btf_contextfunction query_btf_contextfunction parse_btf_argfunction parse_btf_bitfieldfunction check_prepare_btf_string_fetchfunction handle_typecastfunction store_entry_arg_atfunction get_entry_arg_max_offsetfunction __store_entry_argfunction traceprobe_get_entry_data_sizefunction store_trace_entry_datafunction parse_probe_varsfunction str_to_immediatefunction __parse_imm_stringfunction parse_probe_argfunction __parse_bitfield_probe_argfunction strncmpfunction finalize_fetch_insnfunction traceprobe_parse_probe_arg_bodyfunction traceprobe_conflict_field_namefunction traceprobe_parse_probe_argfunction traceprobe_free_probe_argfunction argv_has_var_argfunction sprint_nth_btf_argfunction traceprobe_expand_dentry_args
Annotated Snippet
switch (bs) {
case 8:
return find_fetch_type("u8", flags);
case 16:
return find_fetch_type("u16", flags);
case 32:
return find_fetch_type("u32", flags);
case 64:
return find_fetch_type("u64", flags);
default:
goto fail;
}
}
for (i = 0; probe_fetch_types[i].name; i++) {
if (strcmp(type, probe_fetch_types[i].name) == 0)
return &probe_fetch_types[i];
}
fail:
return NULL;
}
static struct trace_probe_log trace_probe_log;
extern struct mutex dyn_event_ops_mutex;
const char *trace_probe_log_init(const char *subsystem, int argc, const char **argv)
{
lockdep_assert_held(&dyn_event_ops_mutex);
trace_probe_log.subsystem = subsystem;
trace_probe_log.argc = argc;
trace_probe_log.argv = argv;
trace_probe_log.index = 0;
return subsystem;
}
void trace_probe_log_clear(void)
{
lockdep_assert_held(&dyn_event_ops_mutex);
memset(&trace_probe_log, 0, sizeof(trace_probe_log));
}
void trace_probe_log_set_index(int index)
{
lockdep_assert_held(&dyn_event_ops_mutex);
trace_probe_log.index = index;
}
void __trace_probe_log_err(int offset, int err_type)
{
char *command, *p;
int i, len = 0, pos = 0;
lockdep_assert_held(&dyn_event_ops_mutex);
if (!trace_probe_log.argv)
return;
/* Recalculate the length and allocate buffer */
for (i = 0; i < trace_probe_log.argc; i++) {
if (i == trace_probe_log.index)
pos = len;
len += strlen(trace_probe_log.argv[i]) + 1;
}
command = kzalloc(len, GFP_KERNEL);
if (!command)
return;
if (trace_probe_log.index >= trace_probe_log.argc) {
/**
* Set the error position is next to the last arg + space.
* Note that len includes the terminal null and the cursor
* appears at pos + 1.
*/
pos = len;
offset = 0;
}
/* And make a command string from argv array */
p = command;
for (i = 0; i < trace_probe_log.argc; i++) {
len = strlen(trace_probe_log.argv[i]);
memcpy(p, trace_probe_log.argv[i], len);
p[len] = ' ';
p += len + 1;
}
*(p - 1) = '\0';
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/fs.h`, `trace_btf.h`, `trace_probe.h`.
- Detected declarations: `function PRINT_TYPE_FUNC_NAME`, `function PRINT_TYPE_FUNC_NAME`, `function trace_probe_log_clear`, `function trace_probe_log_set_index`, `function __trace_probe_log_err`, `function traceprobe_split_symbol_offset`, `function traceprobe_parse_event_name`, `function parse_trace_event_arg`, `function parse_trace_event`, `function btf_type_int`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.