linux/tools/perf/util/probe-finder.h
<<
>>
Prefs
   1#ifndef _PROBE_FINDER_H
   2#define _PROBE_FINDER_H
   3
   4#include <stdbool.h>
   5#include "util.h"
   6#include "probe-event.h"
   7
   8#define MAX_PATH_LEN             256
   9#define MAX_PROBE_BUFFER        1024
  10#define MAX_PROBES               128
  11
  12static inline int is_c_varname(const char *name)
  13{
  14        /* TODO */
  15        return isalpha(name[0]) || name[0] == '_';
  16}
  17
  18#ifdef DWARF_SUPPORT
  19/* Find probe_trace_events specified by perf_probe_event from debuginfo */
  20extern int find_probe_trace_events(int fd, struct perf_probe_event *pev,
  21                                    struct probe_trace_event **tevs,
  22                                    int max_tevs);
  23
  24/* Find a perf_probe_point from debuginfo */
  25extern int find_perf_probe_point(unsigned long addr,
  26                                 struct perf_probe_point *ppt);
  27
  28/* Find a line range */
  29extern int find_line_range(int fd, struct line_range *lr);
  30
  31/* Find available variables */
  32extern int find_available_vars_at(int fd, struct perf_probe_event *pev,
  33                                  struct variable_list **vls, int max_points,
  34                                  bool externs);
  35
  36#include <dwarf.h>
  37#include <elfutils/libdw.h>
  38#include <elfutils/libdwfl.h>
  39#include <elfutils/version.h>
  40
  41struct probe_finder {
  42        struct perf_probe_event *pev;           /* Target probe event */
  43
  44        /* Callback when a probe point is found */
  45        int (*callback)(Dwarf_Die *sp_die, struct probe_finder *pf);
  46
  47        /* For function searching */
  48        int                     lno;            /* Line number */
  49        Dwarf_Addr              addr;           /* Address */
  50        const char              *fname;         /* Real file name */
  51        Dwarf_Die               cu_die;         /* Current CU */
  52        Dwarf_Die               sp_die;
  53        struct list_head        lcache;         /* Line cache for lazy match */
  54
  55        /* For variable searching */
  56#if _ELFUTILS_PREREQ(0, 142)
  57        Dwarf_CFI               *cfi;           /* Call Frame Information */
  58#endif
  59        Dwarf_Op                *fb_ops;        /* Frame base attribute */
  60        struct perf_probe_arg   *pvar;          /* Current target variable */
  61        struct probe_trace_arg  *tvar;          /* Current result variable */
  62};
  63
  64struct trace_event_finder {
  65        struct probe_finder     pf;
  66        struct probe_trace_event *tevs;         /* Found trace events */
  67        int                     ntevs;          /* Number of trace events */
  68        int                     max_tevs;       /* Max number of trace events */
  69};
  70
  71struct available_var_finder {
  72        struct probe_finder     pf;
  73        struct variable_list    *vls;           /* Found variable lists */
  74        int                     nvls;           /* Number of variable lists */
  75        int                     max_vls;        /* Max no. of variable lists */
  76        bool                    externs;        /* Find external vars too */
  77        bool                    child;          /* Search child scopes */
  78};
  79
  80struct line_finder {
  81        struct line_range       *lr;            /* Target line range */
  82
  83        const char              *fname;         /* File name */
  84        int                     lno_s;          /* Start line number */
  85        int                     lno_e;          /* End line number */
  86        Dwarf_Die               cu_die;         /* Current CU */
  87        Dwarf_Die               sp_die;
  88        int                     found;
  89};
  90
  91#endif /* DWARF_SUPPORT */
  92
  93#endif /*_PROBE_FINDER_H */
  94