^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __PROBE_FILE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __PROBE_FILE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include "probe-event.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) struct strlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct strfilter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) /* Cache of probe definitions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct probe_cache_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) bool sdt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct perf_probe_event pev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) char *spev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct strlist *tevlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct probe_cache {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct list_head entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) enum probe_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) PROBE_TYPE_U = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) PROBE_TYPE_S,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) PROBE_TYPE_X,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) PROBE_TYPE_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) PROBE_TYPE_BITFIELD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) PROBE_TYPE_END,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define PF_FL_UPROBE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define PF_FL_RW 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define for_each_probe_cache_entry(entry, pcache) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) list_for_each_entry(entry, &pcache->entries, node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* probe-file.c depends on libelf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #ifdef HAVE_LIBELF_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int open_trace_file(const char *trace_file, bool readwrite);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int probe_file__open(int flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int probe_file__open_both(int *kfd, int *ufd, int flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct strlist *probe_file__get_namelist(int fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct strlist *probe_file__get_rawlist(int fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int probe_file__add_event(int fd, struct probe_trace_event *tev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) int probe_file__del_events(int fd, struct strfilter *filter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int probe_file__get_events(int fd, struct strfilter *filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct strlist *plist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int probe_file__del_strlist(int fd, struct strlist *namelist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int probe_cache_entry__get_event(struct probe_cache_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct probe_trace_event **tevs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct probe_cache *probe_cache__new(const char *target, struct nsinfo *nsi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int probe_cache__add_entry(struct probe_cache *pcache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct perf_probe_event *pev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct probe_trace_event *tevs, int ntevs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int probe_cache__commit(struct probe_cache *pcache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void probe_cache__purge(struct probe_cache *pcache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) void probe_cache__delete(struct probe_cache *pcache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int probe_cache__filter_purge(struct probe_cache *pcache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct strfilter *filter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct perf_probe_event *pev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) const char *group, const char *event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int probe_cache__show_all_caches(struct strfilter *filter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) bool probe_type_is_available(enum probe_type type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) bool kretprobe_offset_is_supported(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) bool uprobe_ref_ctr_is_supported(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) bool user_access_is_supported(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) bool multiprobe_event_is_supported(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) bool immediate_value_is_supported(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #else /* ! HAVE_LIBELF_SUPPORT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused, struct nsinfo *nsi __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define probe_cache__delete(pcache) do {} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #endif