Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _PROBE_EVENT_H
0003 #define _PROBE_EVENT_H
0004 
0005 #include <linux/compiler.h>
0006 #include <stdbool.h>
0007 
0008 struct intlist;
0009 struct nsinfo;
0010 
0011 /* Probe related configurations */
0012 struct probe_conf {
0013     bool    show_ext_vars;
0014     bool    show_location_range;
0015     bool    force_add;
0016     bool    no_inlines;
0017     bool    cache;
0018     bool    bootconfig;
0019     int max_probes;
0020     unsigned long   magic_num;
0021 };
0022 extern struct probe_conf probe_conf;
0023 extern bool probe_event_dry_run;
0024 
0025 #define DEFAULT_PROBE_MAGIC_NUM 0xdeade12d  /* u32: 3735937325 */
0026 
0027 struct symbol;
0028 
0029 /* kprobe-tracer and uprobe-tracer tracing point */
0030 struct probe_trace_point {
0031     char        *realname;  /* function real name (if needed) */
0032     char        *symbol;    /* Base symbol */
0033     char        *module;    /* Module name */
0034     unsigned long   offset;     /* Offset from symbol */
0035     unsigned long   ref_ctr_offset; /* SDT reference counter offset */
0036     u64     address;    /* Actual address of the trace point */
0037     bool        retprobe;   /* Return probe flag */
0038 };
0039 
0040 /* probe-tracer tracing argument referencing offset */
0041 struct probe_trace_arg_ref {
0042     struct probe_trace_arg_ref  *next;  /* Next reference */
0043     long                offset; /* Offset value */
0044     bool                user_access;    /* User-memory access */
0045 };
0046 
0047 /* kprobe-tracer and uprobe-tracer tracing argument */
0048 struct probe_trace_arg {
0049     char                *name;  /* Argument name */
0050     char                *value; /* Base value */
0051     char                *type;  /* Type name */
0052     struct probe_trace_arg_ref  *ref;   /* Referencing offset */
0053 };
0054 
0055 /* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
0056 struct probe_trace_event {
0057     char                *event; /* Event name */
0058     char                *group; /* Group name */
0059     struct probe_trace_point    point;  /* Trace point */
0060     int             nargs;  /* Number of args */
0061     bool                uprobes;    /* uprobes only */
0062     struct probe_trace_arg      *args;  /* Arguments */
0063 };
0064 
0065 /* Perf probe probing point */
0066 struct perf_probe_point {
0067     char        *file;      /* File path */
0068     char        *function;  /* Function name */
0069     int     line;       /* Line number */
0070     bool        retprobe;   /* Return probe flag */
0071     char        *lazy_line; /* Lazy matching pattern */
0072     unsigned long   offset;     /* Offset from function entry */
0073     u64     abs_address;    /* Absolute address of the point */
0074 };
0075 
0076 /* Perf probe probing argument field chain */
0077 struct perf_probe_arg_field {
0078     struct perf_probe_arg_field *next;  /* Next field */
0079     char                *name;  /* Name of the field */
0080     long                index;  /* Array index number */
0081     bool                ref;    /* Referencing flag */
0082 };
0083 
0084 /* Perf probe probing argument */
0085 struct perf_probe_arg {
0086     char                *name;  /* Argument name */
0087     char                *var;   /* Variable name */
0088     char                *type;  /* Type name */
0089     struct perf_probe_arg_field *field; /* Structure fields */
0090     bool                user_access;    /* User-memory access */
0091 };
0092 
0093 /* Perf probe probing event (point + arg) */
0094 struct perf_probe_event {
0095     char            *event; /* Event name */
0096     char            *group; /* Group name */
0097     struct perf_probe_point point;  /* Probe point */
0098     int         nargs;  /* Number of arguments */
0099     bool            sdt;    /* SDT/cached event flag */
0100     bool            uprobes;    /* Uprobe event flag */
0101     char            *target;    /* Target binary */
0102     struct perf_probe_arg   *args;  /* Arguments */
0103     struct probe_trace_event *tevs;
0104     int         ntevs;
0105     struct nsinfo       *nsi;   /* Target namespace */
0106 };
0107 
0108 /* Line range */
0109 struct line_range {
0110     char            *file;      /* File name */
0111     char            *function;  /* Function name */
0112     int         start;      /* Start line number */
0113     int         end;        /* End line number */
0114     int         offset;     /* Start line offset */
0115     char            *path;      /* Real path name */
0116     char            *comp_dir;  /* Compile directory */
0117     struct intlist      *line_list; /* Visible lines */
0118 };
0119 
0120 struct strlist;
0121 
0122 /* List of variables */
0123 struct variable_list {
0124     struct probe_trace_point    point;  /* Actual probepoint */
0125     struct strlist          *vars;  /* Available variables */
0126 };
0127 
0128 struct map;
0129 int init_probe_symbol_maps(bool user_only);
0130 void exit_probe_symbol_maps(void);
0131 
0132 /* Command string to events */
0133 int parse_perf_probe_command(const char *cmd, struct perf_probe_event *pev);
0134 int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev);
0135 
0136 /* Events to command string */
0137 char *synthesize_perf_probe_command(struct perf_probe_event *pev);
0138 char *synthesize_probe_trace_command(struct probe_trace_event *tev);
0139 char *synthesize_perf_probe_arg(struct perf_probe_arg *pa);
0140 char *synthesize_perf_probe_point(struct perf_probe_point *pp);
0141 
0142 int perf_probe_event__copy(struct perf_probe_event *dst,
0143                struct perf_probe_event *src);
0144 
0145 bool perf_probe_with_var(struct perf_probe_event *pev);
0146 
0147 /* Check the perf_probe_event needs debuginfo */
0148 bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
0149 
0150 /* Release event contents */
0151 void clear_perf_probe_event(struct perf_probe_event *pev);
0152 void clear_probe_trace_event(struct probe_trace_event *tev);
0153 
0154 /* Command string to line-range */
0155 int parse_line_range_desc(const char *cmd, struct line_range *lr);
0156 
0157 /* Release line range members */
0158 void line_range__clear(struct line_range *lr);
0159 
0160 /* Initialize line range */
0161 int line_range__init(struct line_range *lr);
0162 
0163 int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
0164 int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
0165 int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
0166 int show_probe_trace_events(struct perf_probe_event *pevs, int npevs);
0167 int show_bootconfig_events(struct perf_probe_event *pevs, int npevs);
0168 void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
0169 
0170 struct strfilter;
0171 
0172 int del_perf_probe_events(struct strfilter *filter);
0173 
0174 int show_perf_probe_event(const char *group, const char *event,
0175               struct perf_probe_event *pev,
0176               const char *module, bool use_stdout);
0177 int show_perf_probe_events(struct strfilter *filter);
0178 int show_line_range(struct line_range *lr, const char *module,
0179             struct nsinfo *nsi, bool user);
0180 int show_available_vars(struct perf_probe_event *pevs, int npevs,
0181             struct strfilter *filter);
0182 int show_available_funcs(const char *module, struct nsinfo *nsi,
0183              struct strfilter *filter, bool user);
0184 void arch__fix_tev_from_maps(struct perf_probe_event *pev,
0185                  struct probe_trace_event *tev, struct map *map,
0186                  struct symbol *sym);
0187 
0188 /* If there is no space to write, returns -E2BIG. */
0189 int e_snprintf(char *str, size_t size, const char *format, ...) __printf(3, 4);
0190 
0191 /* Maximum index number of event-name postfix */
0192 #define MAX_EVENT_INDEX 1024
0193 
0194 int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
0195                 struct perf_probe_arg *pvar);
0196 
0197 struct map *get_target_map(const char *target, struct nsinfo *nsi, bool user);
0198 
0199 void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
0200                        int ntevs);
0201 
0202 #endif /*_PROBE_EVENT_H */