Home | History | Annotate | Download | only in util
      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 
     12 static 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 */
     20 extern 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 */
     25 extern int find_perf_probe_point(unsigned long addr,
     26 				 struct perf_probe_point *ppt);
     27 
     28 /* Find a line range */
     29 extern int find_line_range(int fd, struct line_range *lr);
     30 
     31 /* Find available variables */
     32 extern 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 /* ANDROID_CHANGE_BEGIN */
     37 #if 0
     38 #include <dwarf.h>
     39 #include <elfutils/libdw.h>
     40 #include <elfutils/libdwfl.h>
     41 #include <elfutils/version.h>
     42 #else
     43 /* These headers live under the external/elfutils */
     44 #include <dwarf.h>
     45 #include <libdw.h>
     46 #include <libdwfl.h>
     47 #include <version.h>
     48 #endif
     49 /* ANDROID_CHANGE_END */
     50 
     51 struct probe_finder {
     52 	struct perf_probe_event	*pev;		/* Target probe event */
     53 
     54 	/* Callback when a probe point is found */
     55 	int (*callback)(Dwarf_Die *sp_die, struct probe_finder *pf);
     56 
     57 	/* For function searching */
     58 	int			lno;		/* Line number */
     59 	Dwarf_Addr		addr;		/* Address */
     60 	const char		*fname;		/* Real file name */
     61 	Dwarf_Die		cu_die;		/* Current CU */
     62 	Dwarf_Die		sp_die;
     63 	struct list_head	lcache;		/* Line cache for lazy match */
     64 
     65 	/* For variable searching */
     66 #if _ELFUTILS_PREREQ(0, 142)
     67 	Dwarf_CFI		*cfi;		/* Call Frame Information */
     68 #endif
     69 	Dwarf_Op		*fb_ops;	/* Frame base attribute */
     70 	struct perf_probe_arg	*pvar;		/* Current target variable */
     71 	struct probe_trace_arg	*tvar;		/* Current result variable */
     72 };
     73 
     74 struct trace_event_finder {
     75 	struct probe_finder	pf;
     76 	struct probe_trace_event *tevs;		/* Found trace events */
     77 	int			ntevs;		/* Number of trace events */
     78 	int			max_tevs;	/* Max number of trace events */
     79 };
     80 
     81 struct available_var_finder {
     82 	struct probe_finder	pf;
     83 	struct variable_list	*vls;		/* Found variable lists */
     84 	int			nvls;		/* Number of variable lists */
     85 	int			max_vls;	/* Max no. of variable lists */
     86 	bool			externs;	/* Find external vars too */
     87 	bool			child;		/* Search child scopes */
     88 };
     89 
     90 struct line_finder {
     91 	struct line_range	*lr;		/* Target line range */
     92 
     93 	const char		*fname;		/* File name */
     94 	int			lno_s;		/* Start line number */
     95 	int			lno_e;		/* End line number */
     96 	Dwarf_Die		cu_die;		/* Current CU */
     97 	Dwarf_Die		sp_die;
     98 	int			found;
     99 };
    100 
    101 #endif /* DWARF_SUPPORT */
    102 
    103 #endif /*_PROBE_FINDER_H */
    104