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