| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | #ifndef _PROBE_FINDER_H
 | 
					
						
							|  |  |  | #define _PROBE_FINDER_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | #include <stdbool.h>
 | 
					
						
							| 
									
										
										
										
											2009-12-27 21:37:00 -02:00
										 |  |  | #include "util.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | #define MAX_PATH_LEN		 256
 | 
					
						
							|  |  |  | #define MAX_PROBE_BUFFER	1024
 | 
					
						
							|  |  |  | #define MAX_PROBES		 128
 | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static inline int is_c_varname(const char *name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* TODO */ | 
					
						
							|  |  |  | 	return isalpha(name[0]) || name[0] == '_'; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct probe_point { | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | 	char			*event;			/* Event name */ | 
					
						
							|  |  |  | 	char			*group;			/* Event group */ | 
					
						
							| 
									
										
										
										
											2009-12-15 10:32:18 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 	/* Inputs */ | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | 	char			*file;			/* File name */ | 
					
						
							|  |  |  | 	int			line;			/* Line number */ | 
					
						
							| 
									
										
										
										
											2010-02-25 08:36:12 -05:00
										 |  |  | 	char			*lazy_line;		/* Lazy line pattern */ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | 	char			*function;		/* Function name */ | 
					
						
							|  |  |  | 	int			offset;			/* Offset bytes */ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | 	int			nr_args;		/* Number of arguments */ | 
					
						
							|  |  |  | 	char			**args;			/* Arguments */ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | 	int			retprobe;		/* Return probe */ | 
					
						
							| 
									
										
										
										
											2009-10-27 16:43:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 	/* Output */ | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | 	int			found;			/* Number of found probe points */ | 
					
						
							|  |  |  | 	char			*probes[MAX_PROBES];	/* Output buffers (will be allocated)*/ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-06 09:45:34 -05:00
										 |  |  | /* 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 */ | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | 	int			offset;			/* Start line offset */ | 
					
						
							| 
									
										
										
										
											2010-01-06 09:45:34 -05:00
										 |  |  | 	char			*path;			/* Real path name */ | 
					
						
							|  |  |  | 	struct list_head	line_list;		/* Visible lines */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | #ifndef NO_DWARF_SUPPORT
 | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:34 -05:00
										 |  |  | extern int find_probe_point(int fd, struct probe_point *pp); | 
					
						
							| 
									
										
										
										
											2010-01-06 09:45:34 -05:00
										 |  |  | extern int find_line_range(int fd, struct line_range *lr); | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | #include <dwarf.h>
 | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | #include <libdw.h>
 | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct probe_finder { | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | 	struct probe_point	*pp;		/* Target probe point */ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* For function searching */ | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | 	Dwarf_Addr		addr;		/* Address */ | 
					
						
							|  |  |  | 	const char		*fname;		/* File name */ | 
					
						
							|  |  |  | 	int			lno;		/* Line number */ | 
					
						
							|  |  |  | 	Dwarf_Die		cu_die;		/* Current CU */ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* For variable searching */ | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | 	Dwarf_Op		*fb_ops;	/* Frame base attribute */ | 
					
						
							|  |  |  | 	Dwarf_Addr		cu_base;	/* Current CU base address */ | 
					
						
							|  |  |  | 	const char		*var;		/* Current variable name */ | 
					
						
							|  |  |  | 	char			*buf;		/* Current output buffer */ | 
					
						
							|  |  |  | 	int			len;		/* Length of output buffer */ | 
					
						
							| 
									
										
										
										
											2010-02-25 08:36:12 -05:00
										 |  |  | 	struct list_head	lcache;		/* Line cache for lazy match */ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2010-01-06 09:45:34 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct line_finder { | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | 	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 */ | 
					
						
							| 
									
										
										
										
											2010-01-06 09:45:34 -05:00
										 |  |  | 	int			found; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | #endif /* NO_DWARF_SUPPORT */
 | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif /*_PROBE_FINDER_H */
 |