Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * dlfilter.h: Interface to perf script --dlfilter shared object
0004  * Copyright (c) 2021, Intel Corporation.
0005  */
0006 
0007 #ifndef PERF_UTIL_DLFILTER_H
0008 #define PERF_UTIL_DLFILTER_H
0009 
0010 struct perf_session;
0011 union  perf_event;
0012 struct perf_sample;
0013 struct evsel;
0014 struct machine;
0015 struct addr_location;
0016 struct perf_dlfilter_fns;
0017 struct perf_dlfilter_sample;
0018 struct perf_dlfilter_al;
0019 
0020 struct dlfilter {
0021     char                *file;
0022     void                *handle;
0023     void                *data;
0024     struct perf_session     *session;
0025     bool                ctx_valid;
0026     bool                in_start;
0027     bool                in_stop;
0028     int             dlargc;
0029     char                **dlargv;
0030 
0031     union perf_event        *event;
0032     struct perf_sample      *sample;
0033     struct evsel            *evsel;
0034     struct machine          *machine;
0035     struct addr_location        *al;
0036     struct addr_location        *addr_al;
0037     struct perf_dlfilter_sample *d_sample;
0038     struct perf_dlfilter_al     *d_ip_al;
0039     struct perf_dlfilter_al     *d_addr_al;
0040 
0041     int (*start)(void **data, void *ctx);
0042     int (*stop)(void *data, void *ctx);
0043 
0044     int (*filter_event)(void *data,
0045                 const struct perf_dlfilter_sample *sample,
0046                 void *ctx);
0047     int (*filter_event_early)(void *data,
0048                   const struct perf_dlfilter_sample *sample,
0049                   void *ctx);
0050 
0051     struct perf_dlfilter_fns *fns;
0052 };
0053 
0054 struct dlfilter *dlfilter__new(const char *file, int dlargc, char **dlargv);
0055 
0056 int dlfilter__start(struct dlfilter *d, struct perf_session *session);
0057 
0058 int dlfilter__do_filter_event(struct dlfilter *d,
0059                   union perf_event *event,
0060                   struct perf_sample *sample,
0061                   struct evsel *evsel,
0062                   struct machine *machine,
0063                   struct addr_location *al,
0064                   struct addr_location *addr_al,
0065                   bool early);
0066 
0067 void dlfilter__cleanup(struct dlfilter *d);
0068 
0069 static inline int dlfilter__filter_event(struct dlfilter *d,
0070                      union perf_event *event,
0071                      struct perf_sample *sample,
0072                      struct evsel *evsel,
0073                      struct machine *machine,
0074                      struct addr_location *al,
0075                      struct addr_location *addr_al)
0076 {
0077     if (!d || !d->filter_event)
0078         return 0;
0079     return dlfilter__do_filter_event(d, event, sample, evsel, machine, al, addr_al, false);
0080 }
0081 
0082 static inline int dlfilter__filter_event_early(struct dlfilter *d,
0083                            union perf_event *event,
0084                            struct perf_sample *sample,
0085                            struct evsel *evsel,
0086                            struct machine *machine,
0087                            struct addr_location *al,
0088                            struct addr_location *addr_al)
0089 {
0090     if (!d || !d->filter_event_early)
0091         return 0;
0092     return dlfilter__do_filter_event(d, event, sample, evsel, machine, al, addr_al, true);
0093 }
0094 
0095 int list_available_dlfilters(const struct option *opt, const char *s, int unset);
0096 bool get_filter_desc(const char *dirname, const char *name, char **desc,
0097              char **long_desc);
0098 
0099 #endif