tools/perf/util/probe-file.c
Source file repositories/reference/linux-study-clean/tools/perf/util/probe-file.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/probe-file.c- Extension
.c- Size
- 26000 bytes
- Lines
- 1183
- 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.hsys/stat.hsys/types.hsys/uio.hunistd.hlinux/zalloc.hnamespaces.hevent.hstrlist.hstrfilter.hdebug.hbuild-id.hdso.hcolor.hsymbol.hstrbuf.hapi/fs/tracing_path.hapi/fs/fs.hprobe-event.hprobe-file.hsession.hperf_regs.hstring2.hdwarf-regs.h
Detected Declarations
enum ftrace_readmefunction print_common_warningfunction print_configure_probe_eventfunction print_open_warningfunction print_both_open_warningfunction open_trace_filefunction open_kprobe_eventsfunction open_uprobe_eventsfunction probe_file__openfunction probe_file__open_bothfunction probe_file__add_eventfunction __del_trace_probe_eventfunction probe_file__get_eventsfunction strlist__for_each_entryfunction probe_file__del_strlistfunction strlist__for_each_entryfunction probe_cache_entry__deletefunction probe_cache_entry__newfunction probe_cache_entry__get_eventfunction probe_cache__openfunction probe_cache__loadfunction probe_cache__purgefunction list_for_each_entry_safefunction probe_cache__deletefunction streqlfunction probe_cache__findfunction for_each_probe_cache_entryfunction probe_cache__find_by_namefunction for_each_probe_cache_entryfunction probe_cache__add_entryfunction sdt_note__get_addrfunction sdt_note__get_ref_ctr_offsetfunction namefunction synthesize_sdt_probe_argfunction probe_cache__scan_sdtfunction probe_cache_entry__writefunction strlist__for_each_entryfunction probe_cache__commitfunction for_each_probe_cache_entryfunction probe_cache_entry__comparefunction probe_cache__filter_purgefunction list_for_each_entry_safefunction probe_cache__show_entriesfunction for_each_probe_cache_entryfunction probe_cache__show_all_cachesfunction scan_ftrace_readmefunction probe_type_is_availablefunction kretprobe_offset_is_supported
Annotated Snippet
if (ret < 0) {
pr_debug("strlist__add failed (%d)\n", ret);
goto out_close_fp;
}
}
fclose(fp);
return sl;
out_close_fp:
fclose(fp);
goto out_free_sl;
out_close_fddup:
close(fddup);
out_free_sl:
strlist__delete(sl);
return NULL;
}
static struct strlist *__probe_file__get_namelist(int fd, bool include_group)
{
char buf[128];
struct strlist *sl, *rawlist;
struct str_node *ent;
struct probe_trace_event tev;
int ret = 0;
memset(&tev, 0, sizeof(tev));
rawlist = probe_file__get_rawlist(fd);
if (!rawlist)
return NULL;
sl = strlist__new(NULL, NULL);
strlist__for_each_entry(ent, rawlist) {
ret = parse_probe_trace_command(ent->s, &tev);
if (ret < 0)
break;
if (include_group) {
ret = e_snprintf(buf, 128, "%s:%s", tev.group,
tev.event);
if (ret >= 0)
ret = strlist__add(sl, buf);
} else
ret = strlist__add(sl, tev.event);
clear_probe_trace_event(&tev);
/* Skip if there is same name multi-probe event in the list */
if (ret == -EEXIST)
ret = 0;
if (ret < 0)
break;
}
strlist__delete(rawlist);
if (ret < 0) {
strlist__delete(sl);
return NULL;
}
return sl;
}
/* Get current perf-probe event names */
struct strlist *probe_file__get_namelist(int fd)
{
return __probe_file__get_namelist(fd, false);
}
int probe_file__add_event(int fd, struct probe_trace_event *tev)
{
int ret = 0;
char *buf = synthesize_probe_trace_command(tev);
char sbuf[STRERR_BUFSIZE];
if (!buf) {
pr_debug("Failed to synthesize probe trace event.\n");
return -EINVAL;
}
pr_debug("Writing event: %s\n", buf);
if (!probe_event_dry_run) {
if (write(fd, buf, strlen(buf)) < (int)strlen(buf)) {
ret = -errno;
pr_warning("Failed to write event: %s\n",
str_error_r(errno, sbuf, sizeof(sbuf)));
}
}
free(buf);
return ret;
}
static int __del_trace_probe_event(int fd, struct str_node *ent)
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `sys/stat.h`, `sys/types.h`, `sys/uio.h`, `unistd.h`, `linux/zalloc.h`, `namespaces.h`.
- Detected declarations: `enum ftrace_readme`, `function print_common_warning`, `function print_configure_probe_event`, `function print_open_warning`, `function print_both_open_warning`, `function open_trace_file`, `function open_kprobe_events`, `function open_uprobe_events`, `function probe_file__open`, `function probe_file__open_both`.
- 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.