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

4
#include <stdbool.h>
5 6
#include "util.h"

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

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

struct probe_point {
18 19
	char			*event;			/* Event name */
	char			*group;			/* Event group */
20

21
	/* Inputs */
22 23
	char			*file;			/* File name */
	int			line;			/* Line number */
24
	char			*lazy_line;		/* Lazy line pattern */
25

26 27
	char			*function;		/* Function name */
	int			offset;			/* Offset bytes */
28

29 30
	int			nr_args;		/* Number of arguments */
	char			**args;			/* Arguments */
31

32
	int			retprobe;		/* Return probe */
33

34
	/* Output */
35 36
	int			found;			/* Number of found probe points */
	char			*probes[MAX_PROBES];	/* Output buffers (will be allocated)*/
37 38
};

39 40 41 42 43 44 45 46 47 48 49 50
/* Line number container */
struct line_node {
	struct list_head	list;
	unsigned int		line;
};

/* Line range */
struct line_range {
	char			*file;			/* File name */
	char			*function;		/* Function name */
	unsigned int		start;			/* Start line number */
	unsigned int		end;			/* End line number */
51
	int			offset;			/* Start line offset */
52 53 54 55
	char			*path;			/* Real path name */
	struct list_head	line_list;		/* Visible lines */
};

56
#ifndef NO_DWARF_SUPPORT
57
extern int find_probe_point(int fd, struct probe_point *pp);
58
extern int find_line_range(int fd, struct line_range *lr);
59

60
#include <dwarf.h>
61
#include <libdw.h>
62 63

struct probe_finder {
64
	struct probe_point	*pp;		/* Target probe point */
65 66

	/* For function searching */
67 68 69 70
	Dwarf_Addr		addr;		/* Address */
	const char		*fname;		/* File name */
	int			lno;		/* Line number */
	Dwarf_Die		cu_die;		/* Current CU */
71 72

	/* For variable searching */
73 74 75 76
	Dwarf_Op		*fb_ops;	/* Frame base attribute */
	const char		*var;		/* Current variable name */
	char			*buf;		/* Current output buffer */
	int			len;		/* Length of output buffer */
77
	struct list_head	lcache;		/* Line cache for lazy match */
78
};
79 80

struct line_finder {
81 82 83 84 85 86
	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 */
87 88 89
	int			found;
};

90
#endif /* NO_DWARF_SUPPORT */
91 92

#endif /*_PROBE_FINDER_H */