aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-12-16 17:16:19 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-17 02:06:41 -0500
commit27f3b24de03fc7cec6f2406f8525ad18086c2121 (patch)
tree35d28e35a8990674920d139ab7eb4ef860f7fe70
parent718deb6b61e34c200c1f2b706176d9aac334cb2d (diff)
perf probe: Fix libdwarf include path for Debian
Fix libdwarf include path to fit debian-like systems too. Borislav Petkov reported: > even after installing libdwarf-dev on my debian box here, > make in tools/perf/ still complains that it cannot find libdwarf: > > Makefile:491: No libdwarf.h found or old libdwarf.h found, disables dwarf > support. Please install libdwarf-dev/libdwarf-devel >= 20081231 > > The problem is that the include path on debian is not > /usr/include/libdwarf/ but simply /usr/include because the debian > package libdwarf-dev puts the headers straight into > /usr/include. This patch adds -I/usr/include/libdwarf to BASIC_CFLAGS and fix probe-finder.h to include just libdwarf.h/dwarf.h. This patch also adds a workaround for the undefined _MIPS_SZLONG bug in libdwarf.h. Reported-by: Borislav Petkov <borislav.petkov@amd.com> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Gabor Gombas <gombasg@sztaki.hu> Cc: systemtap <systemtap@sources.redhat.com> Cc: DLE <dle-develop@lists.sourceforge.net> LKML-Reference: <20091216221618.13816.83296.stgit@dhcp-100-2-132.bos.redhat.com> [ v2: small stylistic fixlets to probe-finder.h ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/Makefile3
-rw-r--r--tools/perf/util/probe-finder.h59
2 files changed, 34 insertions, 28 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 7814dbbd401d..4390d225686d 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -487,10 +487,11 @@ else
487 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); 487 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
488endif 488endif
489 489
490ifneq ($(shell sh -c "(echo '\#include <libdwarf/dwarf.h>'; echo '\#include <libdwarf/libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) 490ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
491 msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231); 491 msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231);
492 BASIC_CFLAGS += -DNO_LIBDWARF 492 BASIC_CFLAGS += -DNO_LIBDWARF
493else 493else
494 BASIC_CFLAGS += -I/usr/include/libdwarf
494 EXTLIBS += -lelf -ldwarf 495 EXTLIBS += -lelf -ldwarf
495 LIB_OBJS += util/probe-finder.o 496 LIB_OBJS += util/probe-finder.o
496endif 497endif
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 5e4050ce2963..a4086aaddb73 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -1,9 +1,9 @@
1#ifndef _PROBE_FINDER_H 1#ifndef _PROBE_FINDER_H
2#define _PROBE_FINDER_H 2#define _PROBE_FINDER_H
3 3
4#define MAX_PATH_LEN 256 4#define MAX_PATH_LEN 256
5#define MAX_PROBE_BUFFER 1024 5#define MAX_PROBE_BUFFER 1024
6#define MAX_PROBES 128 6#define MAX_PROBES 128
7 7
8static inline int is_c_varname(const char *name) 8static inline int is_c_varname(const char *name)
9{ 9{
@@ -12,48 +12,53 @@ static inline int is_c_varname(const char *name)
12} 12}
13 13
14struct probe_point { 14struct probe_point {
15 char *event; /* Event name */ 15 char *event; /* Event name */
16 char *group; /* Event group */ 16 char *group; /* Event group */
17 17
18 /* Inputs */ 18 /* Inputs */
19 char *file; /* File name */ 19 char *file; /* File name */
20 int line; /* Line number */ 20 int line; /* Line number */
21 21
22 char *function; /* Function name */ 22 char *function; /* Function name */
23 int offset; /* Offset bytes */ 23 int offset; /* Offset bytes */
24 24
25 int nr_args; /* Number of arguments */ 25 int nr_args; /* Number of arguments */
26 char **args; /* Arguments */ 26 char **args; /* Arguments */
27 27
28 int retprobe; /* Return probe */ 28 int retprobe; /* Return probe */
29 29
30 /* Output */ 30 /* Output */
31 int found; /* Number of found probe points */ 31 int found; /* Number of found probe points */
32 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/ 32 char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
33}; 33};
34 34
35#ifndef NO_LIBDWARF 35#ifndef NO_LIBDWARF
36extern int find_probepoint(int fd, struct probe_point *pp); 36extern int find_probepoint(int fd, struct probe_point *pp);
37 37
38#include <libdwarf/dwarf.h> 38/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
39#include <libdwarf/libdwarf.h> 39#ifndef _MIPS_SZLONG
40# define _MIPS_SZLONG 0
41#endif
42
43#include <dwarf.h>
44#include <libdwarf.h>
40 45
41struct probe_finder { 46struct probe_finder {
42 struct probe_point *pp; /* Target probe point */ 47 struct probe_point *pp; /* Target probe point */
43 48
44 /* For function searching */ 49 /* For function searching */
45 Dwarf_Addr addr; /* Address */ 50 Dwarf_Addr addr; /* Address */
46 Dwarf_Unsigned fno; /* File number */ 51 Dwarf_Unsigned fno; /* File number */
47 Dwarf_Unsigned lno; /* Line number */ 52 Dwarf_Unsigned lno; /* Line number */
48 Dwarf_Off inl_offs; /* Inline offset */ 53 Dwarf_Off inl_offs; /* Inline offset */
49 Dwarf_Die cu_die; /* Current CU */ 54 Dwarf_Die cu_die; /* Current CU */
50 55
51 /* For variable searching */ 56 /* For variable searching */
52 Dwarf_Addr cu_base; /* Current CU base address */ 57 Dwarf_Addr cu_base; /* Current CU base address */
53 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */ 58 Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
54 const char *var; /* Current variable name */ 59 const char *var; /* Current variable name */
55 char *buf; /* Current output buffer */ 60 char *buf; /* Current output buffer */
56 int len; /* Length of output buffer */ 61 int len; /* Length of output buffer */
57}; 62};
58#endif /* NO_LIBDWARF */ 63#endif /* NO_LIBDWARF */
59 64