Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Masami Hiramatsu | 92f6c72 | 2015-07-15 18:14:07 +0900 | [diff] [blame] | 2 | #ifndef __PROBE_FILE_H |
| 3 | #define __PROBE_FILE_H |
| 4 | |
Masami Hiramatsu | 92f6c72 | 2015-07-15 18:14:07 +0900 | [diff] [blame] | 5 | #include "probe-event.h" |
| 6 | |
Arnaldo Carvalho de Melo | 8ec20b1 | 2017-04-18 10:57:25 -0300 | [diff] [blame] | 7 | struct strlist; |
| 8 | struct strfilter; |
| 9 | |
Masami Hiramatsu | dd97549 | 2016-06-15 12:28:30 +0900 | [diff] [blame] | 10 | /* Cache of probe definitions */ |
| 11 | struct probe_cache_entry { |
| 12 | struct list_head node; |
Masami Hiramatsu | 6430a94e | 2016-07-01 17:04:10 +0900 | [diff] [blame] | 13 | bool sdt; |
Masami Hiramatsu | dd97549 | 2016-06-15 12:28:30 +0900 | [diff] [blame] | 14 | struct perf_probe_event pev; |
| 15 | char *spev; |
| 16 | struct strlist *tevlist; |
| 17 | }; |
| 18 | |
| 19 | struct probe_cache { |
| 20 | int fd; |
| 21 | struct list_head entries; |
| 22 | }; |
| 23 | |
Masami Hiramatsu | 180b206 | 2016-08-18 17:58:31 +0900 | [diff] [blame] | 24 | enum probe_type { |
| 25 | PROBE_TYPE_U = 0, |
| 26 | PROBE_TYPE_S, |
| 27 | PROBE_TYPE_X, |
| 28 | PROBE_TYPE_STRING, |
| 29 | PROBE_TYPE_BITFIELD, |
| 30 | PROBE_TYPE_END, |
| 31 | }; |
| 32 | |
Masami Hiramatsu | 92f6c72 | 2015-07-15 18:14:07 +0900 | [diff] [blame] | 33 | #define PF_FL_UPROBE 1 |
| 34 | #define PF_FL_RW 2 |
Masami Hiramatsu | 05bf2c8 | 2016-07-12 19:05:04 +0900 | [diff] [blame] | 35 | #define for_each_probe_cache_entry(entry, pcache) \ |
| 36 | list_for_each_entry(entry, &pcache->entries, node) |
Masami Hiramatsu | 92f6c72 | 2015-07-15 18:14:07 +0900 | [diff] [blame] | 37 | |
Masami Hiramatsu | 40218da | 2016-06-24 18:06:46 +0900 | [diff] [blame] | 38 | /* probe-file.c depends on libelf */ |
| 39 | #ifdef HAVE_LIBELF_SUPPORT |
Naveen N. Rao | e491bc2 | 2017-02-23 17:07:23 +0530 | [diff] [blame] | 40 | int open_trace_file(const char *trace_file, bool readwrite); |
Masami Hiramatsu | 92f6c72 | 2015-07-15 18:14:07 +0900 | [diff] [blame] | 41 | int probe_file__open(int flag); |
| 42 | int probe_file__open_both(int *kfd, int *ufd, int flag); |
| 43 | struct strlist *probe_file__get_namelist(int fd); |
| 44 | struct strlist *probe_file__get_rawlist(int fd); |
| 45 | int probe_file__add_event(int fd, struct probe_trace_event *tev); |
Arnaldo Carvalho de Melo | 8ec20b1 | 2017-04-18 10:57:25 -0300 | [diff] [blame] | 46 | |
Masami Hiramatsu | 92f6c72 | 2015-07-15 18:14:07 +0900 | [diff] [blame] | 47 | int probe_file__del_events(int fd, struct strfilter *filter); |
Namhyung Kim | e607f14 | 2015-09-04 21:16:03 +0900 | [diff] [blame] | 48 | int probe_file__get_events(int fd, struct strfilter *filter, |
| 49 | struct strlist *plist); |
| 50 | int probe_file__del_strlist(int fd, struct strlist *namelist); |
| 51 | |
Masami Hiramatsu | 42bba26 | 2016-07-12 19:05:18 +0900 | [diff] [blame] | 52 | int probe_cache_entry__get_event(struct probe_cache_entry *entry, |
| 53 | struct probe_trace_event **tevs); |
| 54 | |
Krister Johansen | f045b8c | 2017-07-05 18:48:11 -0700 | [diff] [blame] | 55 | struct probe_cache *probe_cache__new(const char *target, struct nsinfo *nsi); |
Masami Hiramatsu | dd97549 | 2016-06-15 12:28:30 +0900 | [diff] [blame] | 56 | int probe_cache__add_entry(struct probe_cache *pcache, |
| 57 | struct perf_probe_event *pev, |
| 58 | struct probe_trace_event *tevs, int ntevs); |
Masami Hiramatsu | 6430a94e | 2016-07-01 17:04:10 +0900 | [diff] [blame] | 59 | int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname); |
Masami Hiramatsu | dd97549 | 2016-06-15 12:28:30 +0900 | [diff] [blame] | 60 | int probe_cache__commit(struct probe_cache *pcache); |
| 61 | void probe_cache__purge(struct probe_cache *pcache); |
| 62 | void probe_cache__delete(struct probe_cache *pcache); |
Masami Hiramatsu | 4a0f65c | 2016-07-01 17:03:36 +0900 | [diff] [blame] | 63 | int probe_cache__filter_purge(struct probe_cache *pcache, |
| 64 | struct strfilter *filter); |
Masami Hiramatsu | bc06223 | 2016-07-01 17:03:12 +0900 | [diff] [blame] | 65 | struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache, |
| 66 | struct perf_probe_event *pev); |
| 67 | struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache, |
| 68 | const char *group, const char *event); |
Masami Hiramatsu | 1f3736c | 2016-07-01 17:03:26 +0900 | [diff] [blame] | 69 | int probe_cache__show_all_caches(struct strfilter *filter); |
Masami Hiramatsu | 180b206 | 2016-08-18 17:58:31 +0900 | [diff] [blame] | 70 | bool probe_type_is_available(enum probe_type type); |
Naveen N. Rao | 7ab31d9 | 2017-03-08 13:56:09 +0530 | [diff] [blame] | 71 | bool kretprobe_offset_is_supported(void); |
Ravi Bangoria | 5a5e3d3 | 2018-08-20 10:12:50 +0530 | [diff] [blame] | 72 | bool uprobe_ref_ctr_is_supported(void); |
Masami Hiramatsu | 1e032f7 | 2019-05-15 14:39:05 +0900 | [diff] [blame] | 73 | bool user_access_is_supported(void); |
Masami Hiramatsu | 7236354 | 2019-11-18 17:12:30 +0900 | [diff] [blame] | 74 | bool multiprobe_event_is_supported(void); |
Masami Hiramatsu | 66f69b2 | 2019-11-18 17:12:40 +0900 | [diff] [blame] | 75 | bool immediate_value_is_supported(void); |
Masami Hiramatsu | 40218da | 2016-06-24 18:06:46 +0900 | [diff] [blame] | 76 | #else /* ! HAVE_LIBELF_SUPPORT */ |
Krister Johansen | f045b8c | 2017-07-05 18:48:11 -0700 | [diff] [blame] | 77 | static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused, struct nsinfo *nsi __maybe_unused) |
Masami Hiramatsu | 40218da | 2016-06-24 18:06:46 +0900 | [diff] [blame] | 78 | { |
| 79 | return NULL; |
| 80 | } |
| 81 | #define probe_cache__delete(pcache) do {} while (0) |
| 82 | #endif |
Masami Hiramatsu | 92f6c72 | 2015-07-15 18:14:07 +0900 | [diff] [blame] | 83 | #endif |