| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * dlfilter.h: Interface to perf script --dlfilter shared object |
| 4 | * Copyright (c) 2021, Intel Corporation. |
| 5 | */ |
| 6 | |
| 7 | #ifndef PERF_UTIL_DLFILTER_H |
| 8 | #define PERF_UTIL_DLFILTER_H |
| 9 | |
| 10 | struct perf_session; |
| 11 | union perf_event; |
| 12 | struct perf_sample; |
| 13 | struct evsel; |
| 14 | struct machine; |
| 15 | struct addr_location; |
| 16 | struct perf_dlfilter_fns; |
| 17 | struct perf_dlfilter_sample; |
| 18 | struct perf_dlfilter_al; |
| 19 | |
| 20 | struct dlfilter { |
| 21 | char *file; |
| 22 | void *handle; |
| 23 | void *data; |
| 24 | struct perf_session *session; |
| 25 | bool ctx_valid; |
| 26 | bool in_start; |
| 27 | bool in_stop; |
| 28 | int dlargc; |
| 29 | char **dlargv; |
| 30 | |
| 31 | union perf_event *event; |
| 32 | struct perf_sample *sample; |
| 33 | struct evsel *evsel; |
| 34 | struct machine *machine; |
| 35 | struct addr_location *al; |
| 36 | struct addr_location *addr_al; |
| 37 | struct perf_dlfilter_sample *d_sample; |
| 38 | struct perf_dlfilter_al *d_ip_al; |
| 39 | struct perf_dlfilter_al *d_addr_al; |
| 40 | |
| 41 | int (*start)(void **data, void *ctx); |
| 42 | int (*stop)(void *data, void *ctx); |
| 43 | |
| 44 | int (*filter_event)(void *data, |
| 45 | const struct perf_dlfilter_sample *sample, |
| 46 | void *ctx); |
| 47 | int (*filter_event_early)(void *data, |
| 48 | const struct perf_dlfilter_sample *sample, |
| 49 | void *ctx); |
| 50 | |
| 51 | struct perf_dlfilter_fns *fns; |
| 52 | }; |
| 53 | |
| 54 | struct dlfilter *dlfilter__new(const char *file, int dlargc, char **dlargv); |
| 55 | |
| 56 | int dlfilter__start(struct dlfilter *d, struct perf_session *session); |
| 57 | |
| 58 | int dlfilter__do_filter_event(struct dlfilter *d, |
| 59 | union perf_event *event, |
| 60 | struct perf_sample *sample, |
| 61 | struct evsel *evsel, |
| 62 | struct machine *machine, |
| 63 | struct addr_location *al, |
| 64 | struct addr_location *addr_al, |
| 65 | bool early); |
| 66 | |
| 67 | void dlfilter__cleanup(struct dlfilter *d); |
| 68 | |
| 69 | static inline int dlfilter__filter_event(struct dlfilter *d, |
| 70 | union perf_event *event, |
| 71 | struct perf_sample *sample, |
| 72 | struct evsel *evsel, |
| 73 | struct machine *machine, |
| 74 | struct addr_location *al, |
| 75 | struct addr_location *addr_al) |
| 76 | { |
| 77 | if (!d || !d->filter_event) |
| 78 | return 0; |
| 79 | return dlfilter__do_filter_event(d, event, sample, evsel, machine, al, addr_al, early: false); |
| 80 | } |
| 81 | |
| 82 | static inline int dlfilter__filter_event_early(struct dlfilter *d, |
| 83 | union perf_event *event, |
| 84 | struct perf_sample *sample, |
| 85 | struct evsel *evsel, |
| 86 | struct machine *machine, |
| 87 | struct addr_location *al, |
| 88 | struct addr_location *addr_al) |
| 89 | { |
| 90 | if (!d || !d->filter_event_early) |
| 91 | return 0; |
| 92 | return dlfilter__do_filter_event(d, event, sample, evsel, machine, al, addr_al, early: true); |
| 93 | } |
| 94 | |
| 95 | int list_available_dlfilters(const struct option *opt, const char *s, int unset); |
| 96 | bool get_filter_desc(const char *dirname, const char *name, char **desc, |
| 97 | char **long_desc); |
| 98 | |
| 99 | #endif |
| 100 | |