blob: 0dba88c0f5f04c60d8d17a41e1f596551d5afad8 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Masami Hiramatsu92f6c722015-07-15 18:14:07 +09002#ifndef __PROBE_FILE_H
3#define __PROBE_FILE_H
4
Masami Hiramatsu92f6c722015-07-15 18:14:07 +09005#include "probe-event.h"
6
Arnaldo Carvalho de Melo8ec20b12017-04-18 10:57:25 -03007struct strlist;
8struct strfilter;
9
Masami Hiramatsudd975492016-06-15 12:28:30 +090010/* Cache of probe definitions */
11struct probe_cache_entry {
12 struct list_head node;
Masami Hiramatsu6430a94e2016-07-01 17:04:10 +090013 bool sdt;
Masami Hiramatsudd975492016-06-15 12:28:30 +090014 struct perf_probe_event pev;
15 char *spev;
16 struct strlist *tevlist;
17};
18
19struct probe_cache {
20 int fd;
21 struct list_head entries;
22};
23
Masami Hiramatsu180b2062016-08-18 17:58:31 +090024enum 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 Hiramatsu92f6c722015-07-15 18:14:07 +090033#define PF_FL_UPROBE 1
34#define PF_FL_RW 2
Masami Hiramatsu05bf2c82016-07-12 19:05:04 +090035#define for_each_probe_cache_entry(entry, pcache) \
36 list_for_each_entry(entry, &pcache->entries, node)
Masami Hiramatsu92f6c722015-07-15 18:14:07 +090037
Masami Hiramatsu40218da2016-06-24 18:06:46 +090038/* probe-file.c depends on libelf */
39#ifdef HAVE_LIBELF_SUPPORT
Naveen N. Raoe491bc22017-02-23 17:07:23 +053040int open_trace_file(const char *trace_file, bool readwrite);
Masami Hiramatsu92f6c722015-07-15 18:14:07 +090041int probe_file__open(int flag);
42int probe_file__open_both(int *kfd, int *ufd, int flag);
43struct strlist *probe_file__get_namelist(int fd);
44struct strlist *probe_file__get_rawlist(int fd);
45int probe_file__add_event(int fd, struct probe_trace_event *tev);
Arnaldo Carvalho de Melo8ec20b12017-04-18 10:57:25 -030046
Masami Hiramatsu92f6c722015-07-15 18:14:07 +090047int probe_file__del_events(int fd, struct strfilter *filter);
Namhyung Kime607f142015-09-04 21:16:03 +090048int probe_file__get_events(int fd, struct strfilter *filter,
49 struct strlist *plist);
50int probe_file__del_strlist(int fd, struct strlist *namelist);
51
Masami Hiramatsu42bba262016-07-12 19:05:18 +090052int probe_cache_entry__get_event(struct probe_cache_entry *entry,
53 struct probe_trace_event **tevs);
54
Krister Johansenf045b8c2017-07-05 18:48:11 -070055struct probe_cache *probe_cache__new(const char *target, struct nsinfo *nsi);
Masami Hiramatsudd975492016-06-15 12:28:30 +090056int probe_cache__add_entry(struct probe_cache *pcache,
57 struct perf_probe_event *pev,
58 struct probe_trace_event *tevs, int ntevs);
Masami Hiramatsu6430a94e2016-07-01 17:04:10 +090059int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname);
Masami Hiramatsudd975492016-06-15 12:28:30 +090060int probe_cache__commit(struct probe_cache *pcache);
61void probe_cache__purge(struct probe_cache *pcache);
62void probe_cache__delete(struct probe_cache *pcache);
Masami Hiramatsu4a0f65c2016-07-01 17:03:36 +090063int probe_cache__filter_purge(struct probe_cache *pcache,
64 struct strfilter *filter);
Masami Hiramatsubc062232016-07-01 17:03:12 +090065struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,
66 struct perf_probe_event *pev);
67struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache,
68 const char *group, const char *event);
Masami Hiramatsu1f3736c2016-07-01 17:03:26 +090069int probe_cache__show_all_caches(struct strfilter *filter);
Masami Hiramatsu180b2062016-08-18 17:58:31 +090070bool probe_type_is_available(enum probe_type type);
Naveen N. Rao7ab31d92017-03-08 13:56:09 +053071bool kretprobe_offset_is_supported(void);
Ravi Bangoria5a5e3d32018-08-20 10:12:50 +053072bool uprobe_ref_ctr_is_supported(void);
Masami Hiramatsu1e032f72019-05-15 14:39:05 +090073bool user_access_is_supported(void);
Masami Hiramatsu72363542019-11-18 17:12:30 +090074bool multiprobe_event_is_supported(void);
Masami Hiramatsu66f69b22019-11-18 17:12:40 +090075bool immediate_value_is_supported(void);
Masami Hiramatsu40218da2016-06-24 18:06:46 +090076#else /* ! HAVE_LIBELF_SUPPORT */
Krister Johansenf045b8c2017-07-05 18:48:11 -070077static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused, struct nsinfo *nsi __maybe_unused)
Masami Hiramatsu40218da2016-06-24 18:06:46 +090078{
79 return NULL;
80}
81#define probe_cache__delete(pcache) do {} while (0)
82#endif
Masami Hiramatsu92f6c722015-07-15 18:14:07 +090083#endif