| 
									
										
										
										
											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"
 | 
					
						
							| 
									
										
										
										
											2010-03-16 18:06:12 -04:00
										 |  |  | #include "probe-event.h"
 | 
					
						
							| 
									
										
										
										
											2009-12-27 21:37:00 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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] == '_'; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-22 13:10:26 -03:00
										 |  |  | #ifdef DWARF_SUPPORT
 | 
					
						
							| 
									
										
										
										
											2010-07-29 19:43:51 +05:30
										 |  |  | /* 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, | 
					
						
							| 
									
										
										
										
											2010-04-21 15:56:40 -04:00
										 |  |  | 				    int max_tevs); | 
					
						
							| 
									
										
										
										
											2010-03-16 18:06:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-16 18:06:19 -04:00
										 |  |  | /* Find a perf_probe_point from debuginfo */ | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:41 +09:00
										 |  |  | extern int find_perf_probe_point(unsigned long addr, | 
					
						
							| 
									
										
										
										
											2010-03-16 18:06:19 -04:00
										 |  |  | 				 struct perf_probe_point *ppt); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:23 +09:00
										 |  |  | /* Find a line range */ | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:23 +09:00
										 |  |  | /* Find available variables */ | 
					
						
							|  |  |  | extern int find_available_vars_at(int fd, struct perf_probe_event *pev, | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:35 +09:00
										 |  |  | 				  struct variable_list **vls, int max_points, | 
					
						
							|  |  |  | 				  bool externs); | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:23 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-16 17:16:19 -05:00
										 |  |  | #include <dwarf.h>
 | 
					
						
							| 
									
										
										
										
											2010-11-16 14:16:33 -08:00
										 |  |  | #include <elfutils/libdw.h>
 | 
					
						
							|  |  |  | #include <elfutils/libdwfl.h>
 | 
					
						
							|  |  |  | #include <elfutils/version.h>
 | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct probe_finder { | 
					
						
							| 
									
										
										
										
											2010-03-16 18:06:12 -04:00
										 |  |  | 	struct perf_probe_event	*pev;		/* Target probe event */ | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:23 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Callback when a probe point is found */ | 
					
						
							|  |  |  | 	int (*callback)(Dwarf_Die *sp_die, struct probe_finder *pf); | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* For function searching */ | 
					
						
							| 
									
										
											  
											
												perf tools: Reorganize some structs to save space
Using 'pahole --packable' I found some structs that could be reorganized
to eliminate alignment holes, in some cases getting them to be cacheline
multiples.
[acme@doppio linux-2.6-tip]$ codiff perf.old ~/bin/perf
builtin-annotate.c:
  struct perf_session    |   -8
  struct perf_header     |   -8
 2 structs changed
builtin-diff.c:
  struct sample_data         |   -8
 1 struct changed
  diff__process_sample_event |   -8
 1 function changed, 8 bytes removed, diff: -8
builtin-sched.c:
  struct sched_atom      |   -8
 1 struct changed
builtin-timechart.c:
  struct per_pid         |   -8
 1 struct changed
  cmd_timechart          |  -16
 1 function changed, 16 bytes removed, diff: -16
builtin-probe.c:
  struct perf_probe_point |   -8
  struct perf_probe_event |   -8
 2 structs changed
  opt_add_probe_event     |   -3
 1 function changed, 3 bytes removed, diff: -3
util/probe-finder.c:
  struct probe_finder      |   -8
 1 struct changed
  find_kprobe_trace_events |  -16
 1 function changed, 16 bytes removed, diff: -16
/home/acme/bin/perf:
 4 functions changed, 43 bytes removed, diff: -43
[acme@doppio linux-2.6-tip]$
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
											
										 
											2010-04-05 12:53:45 -03:00
										 |  |  | 	int			lno;		/* Line number */ | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | 	Dwarf_Addr		addr;		/* Address */ | 
					
						
							| 
									
										
										
										
											2010-03-16 18:06:12 -04:00
										 |  |  | 	const char		*fname;		/* Real file name */ | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | 	Dwarf_Die		cu_die;		/* Current CU */ | 
					
						
							| 
									
										
										
										
											2010-03-16 18:06:12 -04:00
										 |  |  | 	struct list_head	lcache;		/* Line cache for lazy match */ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* For variable searching */ | 
					
						
							| 
									
										
										
										
											2010-05-10 13:12:07 -04:00
										 |  |  | #if _ELFUTILS_PREREQ(0, 142)
 | 
					
						
							| 
									
										
										
										
											2010-04-12 13:17:29 -04:00
										 |  |  | 	Dwarf_CFI		*cfi;		/* Call Frame Information */ | 
					
						
							| 
									
										
										
										
											2010-05-10 13:12:07 -04:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2010-02-25 08:35:42 -05:00
										 |  |  | 	Dwarf_Op		*fb_ops;	/* Frame base attribute */ | 
					
						
							| 
									
										
										
										
											2010-03-16 18:06:12 -04:00
										 |  |  | 	struct perf_probe_arg	*pvar;		/* Current target variable */ | 
					
						
							| 
									
										
										
										
											2010-07-29 19:43:51 +05:30
										 |  |  | 	struct probe_trace_arg	*tvar;		/* Current result variable */ | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2010-01-06 09:45:34 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:23 +09:00
										 |  |  | 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 */ | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:35 +09:00
										 |  |  | 	bool			externs;	/* Find external vars too */ | 
					
						
							|  |  |  | 	bool			child;		/* Search child scopes */ | 
					
						
							| 
									
										
										
										
											2010-10-21 19:13:23 +09: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-03-22 13:10:26 -03:00
										 |  |  | #endif /* DWARF_SUPPORT */
 | 
					
						
							| 
									
										
										
										
											2009-10-08 17:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif /*_PROBE_FINDER_H */
 |