probe-finder.h 2.5 KB
Newer Older
1 2 3
#ifndef _PROBE_FINDER_H
#define _PROBE_FINDER_H

4
#include <stdbool.h>
5
#include "util.h"
6
#include "probe-event.h"
7

8 9 10
#define MAX_PATH_LEN		 256
#define MAX_PROBE_BUFFER	1024
#define MAX_PROBES		 128
11 12 13 14 15 16 17

static inline int is_c_varname(const char *name)
{
	/* TODO */
	return isalpha(name[0]) || name[0] == '_';
}

18
#ifdef DWARF_SUPPORT
19 20 21
/* Find probe_trace_events specified by perf_probe_event from debuginfo */
extern int find_probe_trace_events(int fd, struct perf_probe_event *pev,
				    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 27
				 struct perf_probe_point *ppt);

28
/* Find a line range */
29
extern int find_line_range(int fd, struct line_range *lr);
30

31 32
/* Find available variables */
extern int find_available_vars_at(int fd, struct perf_probe_event *pev,
33 34
				  struct variable_list **vls, int max_points,
				  bool externs);
35
#include "dwarf-aux.h"
36 37

struct probe_finder {
38
	struct perf_probe_event	*pev;		/* Target probe event */
39 40 41

	/* Callback when a probe point is found */
	int (*callback)(Dwarf_Die *sp_die, struct probe_finder *pf);
42 43

	/* For function searching */
44
	int			lno;		/* Line number */
45
	Dwarf_Addr		addr;		/* Address */
46
	const char		*fname;		/* Real file name */
47
	Dwarf_Die		cu_die;		/* Current CU */
48
	Dwarf_Die		sp_die;
49
	struct list_head	lcache;		/* Line cache for lazy match */
50 51

	/* For variable searching */
52
#if _ELFUTILS_PREREQ(0, 142)
53
	Dwarf_CFI		*cfi;		/* Call Frame Information */
54
#endif
55
	Dwarf_Op		*fb_ops;	/* Frame base attribute */
56
	struct perf_probe_arg	*pvar;		/* Current target variable */
57
	struct probe_trace_arg	*tvar;		/* Current result variable */
58
};
59

60 61 62 63 64 65 66 67 68 69 70 71
struct trace_event_finder {
	struct probe_finder	pf;
	struct probe_trace_event *tevs;		/* Found trace events */
	int			ntevs;		/* Number of trace events */
	int			max_tevs;	/* Max number of trace events */
};

struct available_var_finder {
	struct probe_finder	pf;
	struct variable_list	*vls;		/* Found variable lists */
	int			nvls;		/* Number of variable lists */
	int			max_vls;	/* Max no. of variable lists */
72 73
	bool			externs;	/* Find external vars too */
	bool			child;		/* Search child scopes */
74 75
};

76
struct line_finder {
77 78 79 80 81 82
	struct line_range	*lr;		/* Target line range */

	const char		*fname;		/* File name */
	int			lno_s;		/* Start line number */
	int			lno_e;		/* End line number */
	Dwarf_Die		cu_die;		/* Current CU */
83
	Dwarf_Die		sp_die;
84 85 86
	int			found;
};

87
#endif /* DWARF_SUPPORT */
88 89

#endif /*_PROBE_FINDER_H */