probe-finder.h 2.4 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 25 26 27
/* Find a perf_probe_point from debuginfo */
extern int find_perf_probe_point(int fd, unsigned long addr,
				 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 33 34
/* Find available variables */
extern int find_available_vars_at(int fd, struct perf_probe_event *pev,
				  struct variable_list **vls, int max_points);

35
#include <dwarf.h>
36
#include <libdw.h>
37
#include <version.h>
38 39

struct probe_finder {
40
	struct perf_probe_event	*pev;		/* Target probe event */
41 42 43

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

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

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

61 62 63 64 65 66 67 68 69 70 71 72 73 74
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 */
};

75
struct line_finder {
76 77 78 79 80 81
	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 */
82 83 84
	int			found;
};

85
#endif /* DWARF_SUPPORT */
86 87

#endif /*_PROBE_FINDER_H */