mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 03:06:10 +00:00
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>
This commit is contained in:
parent
718deb6b61
commit
27f3b24de0
2 changed files with 34 additions and 28 deletions
|
@ -487,10 +487,11 @@ else
|
||||||
msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
|
msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(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)
|
ifneq ($(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)
|
||||||
msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231);
|
msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231);
|
||||||
BASIC_CFLAGS += -DNO_LIBDWARF
|
BASIC_CFLAGS += -DNO_LIBDWARF
|
||||||
else
|
else
|
||||||
|
BASIC_CFLAGS += -I/usr/include/libdwarf
|
||||||
EXTLIBS += -lelf -ldwarf
|
EXTLIBS += -lelf -ldwarf
|
||||||
LIB_OBJS += util/probe-finder.o
|
LIB_OBJS += util/probe-finder.o
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef _PROBE_FINDER_H
|
#ifndef _PROBE_FINDER_H
|
||||||
#define _PROBE_FINDER_H
|
#define _PROBE_FINDER_H
|
||||||
|
|
||||||
#define MAX_PATH_LEN 256
|
#define MAX_PATH_LEN 256
|
||||||
#define MAX_PROBE_BUFFER 1024
|
#define MAX_PROBE_BUFFER 1024
|
||||||
#define MAX_PROBES 128
|
#define MAX_PROBES 128
|
||||||
|
|
||||||
static inline int is_c_varname(const char *name)
|
static inline int is_c_varname(const char *name)
|
||||||
{
|
{
|
||||||
|
@ -12,48 +12,53 @@ static inline int is_c_varname(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct probe_point {
|
struct probe_point {
|
||||||
char *event; /* Event name */
|
char *event; /* Event name */
|
||||||
char *group; /* Event group */
|
char *group; /* Event group */
|
||||||
|
|
||||||
/* Inputs */
|
/* Inputs */
|
||||||
char *file; /* File name */
|
char *file; /* File name */
|
||||||
int line; /* Line number */
|
int line; /* Line number */
|
||||||
|
|
||||||
char *function; /* Function name */
|
char *function; /* Function name */
|
||||||
int offset; /* Offset bytes */
|
int offset; /* Offset bytes */
|
||||||
|
|
||||||
int nr_args; /* Number of arguments */
|
int nr_args; /* Number of arguments */
|
||||||
char **args; /* Arguments */
|
char **args; /* Arguments */
|
||||||
|
|
||||||
int retprobe; /* Return probe */
|
int retprobe; /* Return probe */
|
||||||
|
|
||||||
/* Output */
|
/* Output */
|
||||||
int found; /* Number of found probe points */
|
int found; /* Number of found probe points */
|
||||||
char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
|
char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef NO_LIBDWARF
|
#ifndef NO_LIBDWARF
|
||||||
extern int find_probepoint(int fd, struct probe_point *pp);
|
extern int find_probepoint(int fd, struct probe_point *pp);
|
||||||
|
|
||||||
#include <libdwarf/dwarf.h>
|
/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
|
||||||
#include <libdwarf/libdwarf.h>
|
#ifndef _MIPS_SZLONG
|
||||||
|
# define _MIPS_SZLONG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <dwarf.h>
|
||||||
|
#include <libdwarf.h>
|
||||||
|
|
||||||
struct probe_finder {
|
struct probe_finder {
|
||||||
struct probe_point *pp; /* Target probe point */
|
struct probe_point *pp; /* Target probe point */
|
||||||
|
|
||||||
/* For function searching */
|
/* For function searching */
|
||||||
Dwarf_Addr addr; /* Address */
|
Dwarf_Addr addr; /* Address */
|
||||||
Dwarf_Unsigned fno; /* File number */
|
Dwarf_Unsigned fno; /* File number */
|
||||||
Dwarf_Unsigned lno; /* Line number */
|
Dwarf_Unsigned lno; /* Line number */
|
||||||
Dwarf_Off inl_offs; /* Inline offset */
|
Dwarf_Off inl_offs; /* Inline offset */
|
||||||
Dwarf_Die cu_die; /* Current CU */
|
Dwarf_Die cu_die; /* Current CU */
|
||||||
|
|
||||||
/* For variable searching */
|
/* For variable searching */
|
||||||
Dwarf_Addr cu_base; /* Current CU base address */
|
Dwarf_Addr cu_base; /* Current CU base address */
|
||||||
Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
|
Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
|
||||||
const char *var; /* Current variable name */
|
const char *var; /* Current variable name */
|
||||||
char *buf; /* Current output buffer */
|
char *buf; /* Current output buffer */
|
||||||
int len; /* Length of output buffer */
|
int len; /* Length of output buffer */
|
||||||
};
|
};
|
||||||
#endif /* NO_LIBDWARF */
|
#endif /* NO_LIBDWARF */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue