probe-finder.h 1.8 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
extern int find_line_range(int fd, struct line_range *lr);
29

30
#include <dwarf.h>
31
#include <libdw.h>
32
#include <version.h>
33 34

struct probe_finder {
35
	struct perf_probe_event	*pev;		/* Target probe event */
36
	struct probe_trace_event *tevs;		/* Result trace events */
37 38
	int			ntevs;		/* Number of trace events */
	int			max_tevs;	/* Max number of trace events */
39 40

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

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

struct line_finder {
57 58 59 60 61 62
	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 */
63 64 65
	int			found;
};

66
#endif /* DWARF_SUPPORT */
67 68

#endif /*_PROBE_FINDER_H */