Re: perf and libdwarf on debian

From: Borislav Petkov
Date: Wed Dec 16 2009 - 17:13:28 EST


On Wed, Dec 16, 2009 at 08:19:15PM +0100, Peter Zijlstra wrote:
> Well, I'm not 100% sure -I/foo will actually work if foo doesn't exist,
> but I'd sure try it first since its less typing :-)

Yes, it does :) Here's a much simpler fix:

--
From: Borislav Petkov <petkovbb@xxxxxxxxx>
Date: Wed, 16 Dec 2009 23:07:10 +0100
Subject: [PATCH] perf: fix libdwarf include paths

even after installing libdwarf-dev on debian 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 libdwarf headers on debian are not placed in
/usr/include/libdwarf/ but simply in /usr/include.

Fix by adding the non-standard path to BASIC_CFLAGS and truncating the
include directives.

Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Signed-off-by: Borislav Petkov <petkovbb@xxxxxxxxx>
---
tools/perf/Makefile | 4 ++--
tools/perf/util/probe-finder.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 7814dbb..23ce10d 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -260,7 +260,7 @@ endif
# Those must not be GNU-specific; they are shared with perl/ which may
# be built by a different compiler. (Note that this is an artifact now
# but it still might be nice to keep that distinction.)
-BASIC_CFLAGS = -Iutil/include
+BASIC_CFLAGS = -Iutil/include -I/usr/include/libdwarf
BASIC_LDFLAGS =

# Guard against environment variables
@@ -487,7 +487,7 @@ else
msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
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 '\#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 -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);
BASIC_CFLAGS += -DNO_LIBDWARF
else
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 5e4050c..adf7949 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -35,8 +35,8 @@ struct probe_point {
#ifndef NO_LIBDWARF
extern int find_probepoint(int fd, struct probe_point *pp);

-#include <libdwarf/dwarf.h>
-#include <libdwarf/libdwarf.h>
+#include <dwarf.h>
+#include <libdwarf.h>

struct probe_finder {
struct probe_point *pp; /* Target probe point */
--
1.6.5


--
Regards/Gruss,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/