* perf and libdwarf on debian
@ 2009-12-16 13:54 Borislav Petkov
2009-12-16 18:20 ` Masami Hiramatsu
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Borislav Petkov @ 2009-12-16 13:54 UTC (permalink / raw)
To: Ingo Molnar, Masami Hiramatsu; +Cc: linux-kernel
Hi,
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.
Now, fixing this in the build system could get ugly and too much (see
below), IMHO, so how about adding a README file in <tools/perf/>
which explains that on Debian-like systems, one should mkdir
/usr/include/libdwarf/ and symlink libdwarf.h and dwarf.h into it?
There could be a better solution though...?
---
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 4069996..5b48ce2 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -161,6 +161,7 @@ uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
+uname_D := $(shell sh -c "lsb_release -a 2>/dev/null | awk '/ID/ { print \$$3 }'")
# CFLAGS and LDFLAGS are for the users to override from the command line.
@@ -475,6 +476,14 @@ ifeq ($(uname_S),Darwin)
PTHREAD_LIBS =
endif
+ifeq ($(uname_D),Debian)
+ LIBDWARF_PREFIX =
+ BASIC_CFLAGS += -DDEBIAN
+else
+ LIBDWARF_PREFIX = libdwarf/
+endif
+
+
ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
@@ -487,7 +496,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 <$(LIBDWARF_PREFIX)dwarf.h>'; echo '\#include <$(LIBDWARF_PREFIX)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 bdebca6..3be22f1 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -32,8 +32,13 @@ struct probe_point {
#ifndef NO_LIBDWARF
extern int find_probepoint(int fd, struct probe_point *pp);
+#ifndef DEBIAN
#include <libdwarf/dwarf.h>
#include <libdwarf/libdwarf.h>
+#else
+#include <dwarf.h>
+#include <libdwarf.h>
+#endif
struct probe_finder {
struct probe_point *pp; /* Target probe point */
--
Regards/Gruss,
Boris.
Operating | Advanced Micro Devices GmbH
System | Karl-Hammerschmidt-Str. 34, 85609 Dornach b. München, Germany
Research | Geschäftsführer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Center | Sitz: Dornach, Gemeinde Aschheim, Landkreis München
(OSRC) | Registergericht München, HRB Nr. 43632
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: perf and libdwarf on debian
2009-12-16 13:54 perf and libdwarf on debian Borislav Petkov
@ 2009-12-16 18:20 ` Masami Hiramatsu
2009-12-16 18:32 ` Peter Zijlstra
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Masami Hiramatsu @ 2009-12-16 18:20 UTC (permalink / raw)
To: Borislav Petkov; +Cc: Ingo Molnar, linux-kernel
Hi Borislav,
Borislav Petkov wrote:
> Hi,
>
> 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.
Thank you for reporting that :-)
>
> Now, fixing this in the build system could get ugly and too much (see
> below), IMHO, so how about adding a README file in <tools/perf/>
> which explains that on Debian-like systems, one should mkdir
> /usr/include/libdwarf/ and symlink libdwarf.h and dwarf.h into it?
>
> There could be a better solution though...?
Yeah, I'd like to update Makefile rather than updating document...
>
> ---
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index 4069996..5b48ce2 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -161,6 +161,7 @@ uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
> uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
> uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
> uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
> +uname_D := $(shell sh -c "lsb_release -a 2>/dev/null | awk '/ID/ { print \$$3 }'")
>
> # CFLAGS and LDFLAGS are for the users to override from the command line.
>
> @@ -475,6 +476,14 @@ ifeq ($(uname_S),Darwin)
> PTHREAD_LIBS =
> endif
>
> +ifeq ($(uname_D),Debian)
> + LIBDWARF_PREFIX =
> + BASIC_CFLAGS += -DDEBIAN
> +else
> + LIBDWARF_PREFIX = libdwarf/
> +endif
Hmm, I think such Distro-checking code is ugly and very specific.
Instead of that, it would be better to use -I option to search
libdwarf.
e.g.
ifeq ($(shell sh -c "(test -d /usr/include/libdwarf/ && echo y)", y)
BASIC_CFLAGS += -I /usr/include/libdwarf
endif
And including just libdwarf.h and dwarf.h.
Thank you again,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: perf and libdwarf on debian
2009-12-16 13:54 perf and libdwarf on debian Borislav Petkov
2009-12-16 18:20 ` Masami Hiramatsu
@ 2009-12-16 18:32 ` Peter Zijlstra
2009-12-16 18:38 ` Gabor Gombas
2009-12-16 19:05 ` Masami Hiramatsu
2009-12-16 18:49 ` Gabor Gombas
2009-12-16 22:16 ` [PATCH -tip] perf probe: Fix libdwarf include path Masami Hiramatsu
3 siblings, 2 replies; 13+ messages in thread
From: Peter Zijlstra @ 2009-12-16 18:32 UTC (permalink / raw)
To: Borislav Petkov; +Cc: Ingo Molnar, Masami Hiramatsu, linux-kernel
On Wed, 2009-12-16 at 14:54 +0100, Borislav Petkov wrote:
> Hi,
>
> 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.
>
> Now, fixing this in the build system could get ugly and too much (see
> below), IMHO, so how about adding a README file in <tools/perf/>
> which explains that on Debian-like systems, one should mkdir
> /usr/include/libdwarf/ and symlink libdwarf.h and dwarf.h into it?
>
> There could be a better solution though...?
Yeah, like file a bug with RH for placing them in such an utterly stupid
location.
Also, I'd not bother with testing debian, just do
#include <dwarf.h>
and simply add -I/usr/include/libdwarf to CPPFLAGS or something like
that.
Then again, its not like debian would ever ship something recent enough
to actually build perf with, even my karmic machine comes with
libdwarf-20080409 which to me reads like ancient and not befitting a
distro released a month or so ago.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: perf and libdwarf on debian
2009-12-16 18:32 ` Peter Zijlstra
@ 2009-12-16 18:38 ` Gabor Gombas
2009-12-16 18:58 ` Peter Zijlstra
2009-12-16 19:05 ` Masami Hiramatsu
1 sibling, 1 reply; 13+ messages in thread
From: Gabor Gombas @ 2009-12-16 18:38 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Borislav Petkov, Ingo Molnar, Masami Hiramatsu, linux-kernel
On Wed, Dec 16, 2009 at 07:32:20PM +0100, Peter Zijlstra wrote:
> Then again, its not like debian would ever ship something recent enough
> to actually build perf with, even my karmic machine comes with
> libdwarf-20080409 which to me reads like ancient and not befitting a
> distro released a month or so ago.
"karmic" sounds Ubuntu, not Debian. In Debian:
$ apt-cache policy libdwarf-dev
libdwarf-dev:
Installed: (none)
Candidate: 20091012-1
Version table:
20091012-1 0
990 http://ftp.hu.debian.org sid/main Packages
500 http://ftp.hu.debian.org squeeze/main Packages
20080409-2 0
500 http://ftp.hu.debian.org lenny/main Packages
Gabor
--
---------------------------------------------------------
MTA SZTAKI Computer and Automation Research Institute
Hungarian Academy of Sciences
---------------------------------------------------------
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: perf and libdwarf on debian
2009-12-16 18:38 ` Gabor Gombas
@ 2009-12-16 18:58 ` Peter Zijlstra
2009-12-16 22:31 ` Thomas Fjellstrom
0 siblings, 1 reply; 13+ messages in thread
From: Peter Zijlstra @ 2009-12-16 18:58 UTC (permalink / raw)
To: Gabor Gombas; +Cc: Borislav Petkov, Ingo Molnar, Masami Hiramatsu, linux-kernel
On Wed, 2009-12-16 at 19:38 +0100, Gabor Gombas wrote:
> On Wed, Dec 16, 2009 at 07:32:20PM +0100, Peter Zijlstra wrote:
>
> > Then again, its not like debian would ever ship something recent enough
> > to actually build perf with, even my karmic machine comes with
> > libdwarf-20080409 which to me reads like ancient and not befitting a
> > distro released a month or so ago.
>
> "karmic" sounds Ubuntu, not Debian. In Debian:
And here I thought ubuntu was generally a less ancient debian..
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: perf and libdwarf on debian
2009-12-16 18:58 ` Peter Zijlstra
@ 2009-12-16 22:31 ` Thomas Fjellstrom
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Fjellstrom @ 2009-12-16 22:31 UTC (permalink / raw)
To: linux-kernel
Cc: Peter Zijlstra, Gabor Gombas, Borislav Petkov, Ingo Molnar,
Masami Hiramatsu
On Wed December 16 2009, Peter Zijlstra wrote:
> On Wed, 2009-12-16 at 19:38 +0100, Gabor Gombas wrote:
> > On Wed, Dec 16, 2009 at 07:32:20PM +0100, Peter Zijlstra wrote:
> > > Then again, its not like debian would ever ship something recent
> > > enough to actually build perf with, even my karmic machine comes with
> > > libdwarf-20080409 which to me reads like ancient and not befitting a
> > > distro released a month or so ago.
> >
> > "karmic" sounds Ubuntu, not Debian. In Debian:
>
> And here I thought ubuntu was generally a less ancient debian..
>
Only at the moment they mirrored the Sid repo for the new release. After
that things freeze.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Thomas Fjellstrom
tfjellstrom@shaw.ca
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: perf and libdwarf on debian
2009-12-16 18:32 ` Peter Zijlstra
2009-12-16 18:38 ` Gabor Gombas
@ 2009-12-16 19:05 ` Masami Hiramatsu
2009-12-16 19:19 ` Peter Zijlstra
1 sibling, 1 reply; 13+ messages in thread
From: Masami Hiramatsu @ 2009-12-16 19:05 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Borislav Petkov, Ingo Molnar, linux-kernel
Peter Zijlstra wrote:
> On Wed, 2009-12-16 at 14:54 +0100, Borislav Petkov wrote:
>> Hi,
>>
>> 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.
>>
>> Now, fixing this in the build system could get ugly and too much (see
>> below), IMHO, so how about adding a README file in <tools/perf/>
>> which explains that on Debian-like systems, one should mkdir
>> /usr/include/libdwarf/ and symlink libdwarf.h and dwarf.h into it?
>>
>> There could be a better solution though...?
>
> Yeah, like file a bug with RH for placing them in such an utterly stupid
> location.
>
> Also, I'd not bother with testing debian, just do
>
> #include <dwarf.h>
>
> and simply add -I/usr/include/libdwarf to CPPFLAGS or something like
> that.
Ah, right, I was stupid!
Masami Hiramatsu wrote:
> e.g.
>
> ifeq ($(shell sh -c "(test -d /usr/include/libdwarf/ && echo y)", y)
> BASIC_CFLAGS += -I /usr/include/libdwarf
> endif
So, it just need;
BASIC_CFLAGS += -I/usr/include/libdwarf
And including just libdwarf.h and dwarf.h.
Thank you,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: perf and libdwarf on debian
2009-12-16 19:05 ` Masami Hiramatsu
@ 2009-12-16 19:19 ` Peter Zijlstra
2009-12-16 22:13 ` Borislav Petkov
0 siblings, 1 reply; 13+ messages in thread
From: Peter Zijlstra @ 2009-12-16 19:19 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: Borislav Petkov, Ingo Molnar, linux-kernel
On Wed, 2009-12-16 at 14:05 -0500, Masami Hiramatsu wrote:
> > and simply add -I/usr/include/libdwarf to CPPFLAGS or something like
> > that.
>
> Ah, right, I was stupid!
>
> Masami Hiramatsu wrote:
> > e.g.
> >
> > ifeq ($(shell sh -c "(test -d /usr/include/libdwarf/ && echo y)", y)
> > BASIC_CFLAGS += -I /usr/include/libdwarf
> > endif
>
> So, it just need;
>
> BASIC_CFLAGS += -I/usr/include/libdwarf
>
> And including just libdwarf.h and dwarf.h.
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 :-)
If it doesn't your suggestion is a good alternative.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: perf and libdwarf on debian
2009-12-16 19:19 ` Peter Zijlstra
@ 2009-12-16 22:13 ` Borislav Petkov
2009-12-16 22:29 ` Masami Hiramatsu
0 siblings, 1 reply; 13+ messages in thread
From: Borislav Petkov @ 2009-12-16 22:13 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Masami Hiramatsu, Borislav Petkov, Ingo Molnar, linux-kernel
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@gmail.com>
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@infradead.org>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
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.
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: perf and libdwarf on debian
2009-12-16 22:13 ` Borislav Petkov
@ 2009-12-16 22:29 ` Masami Hiramatsu
0 siblings, 0 replies; 13+ messages in thread
From: Masami Hiramatsu @ 2009-12-16 22:29 UTC (permalink / raw)
To: Borislav Petkov, Peter Zijlstra, Borislav Petkov, Ingo Molnar,
linux-kernel
Borislav Petkov wrote:
> 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:
Oops, I also posted another version X(
Actually, from unknown reason, #include <libdwarf.h>
causes "_MIPS_SZLONG is not defined" error on my
Fedora11 (curiously, even #include <libdwarf/libdwarf.h>
didn't cause the bug!).
So I added a workaround for the bug on my patch.
Anyway, Thank you very much for reporting the bug and making a fix!!
>
> --
> From: Borislav Petkov <petkovbb@gmail.com>
> 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@infradead.org>
> Cc: Masami Hiramatsu <mhiramat@redhat.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
> ---
> 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 */
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: perf and libdwarf on debian
2009-12-16 13:54 perf and libdwarf on debian Borislav Petkov
2009-12-16 18:20 ` Masami Hiramatsu
2009-12-16 18:32 ` Peter Zijlstra
@ 2009-12-16 18:49 ` Gabor Gombas
2009-12-16 22:16 ` [PATCH -tip] perf probe: Fix libdwarf include path Masami Hiramatsu
3 siblings, 0 replies; 13+ messages in thread
From: Gabor Gombas @ 2009-12-16 18:49 UTC (permalink / raw)
To: Borislav Petkov; +Cc: Ingo Molnar, Masami Hiramatsu, linux-kernel
On Wed, Dec 16, 2009 at 02:54:48PM +0100, Borislav Petkov wrote:
> Now, fixing this in the build system could get ugly and too much (see
> below), IMHO, so how about adding a README file in <tools/perf/>
> which explains that on Debian-like systems, one should mkdir
> /usr/include/libdwarf/ and symlink libdwarf.h and dwarf.h into it?
>
> There could be a better solution though...?
Bug the libdwarf developers to ship a .pc file for pkg-config that
distros can customize as needed.
Gabor
--
---------------------------------------------------------
MTA SZTAKI Computer and Automation Research Institute
Hungarian Academy of Sciences
---------------------------------------------------------
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH -tip] perf probe: Fix libdwarf include path
2009-12-16 13:54 perf and libdwarf on debian Borislav Petkov
` (2 preceding siblings ...)
2009-12-16 18:49 ` Gabor Gombas
@ 2009-12-16 22:16 ` Masami Hiramatsu
2009-12-17 7:54 ` [tip:perf/urgent] perf probe: Fix libdwarf include path for Debian tip-bot for Masami Hiramatsu
3 siblings, 1 reply; 13+ messages in thread
From: Masami Hiramatsu @ 2009-12-16 22:16 UTC (permalink / raw)
To: Ingo Molnar, Frederic Weisbecker, lkml
Cc: systemtap, DLE, Masami Hiramatsu, Ingo Molnar,
Frederic Weisbecker, Paul Mackerras, Arnaldo Carvalho de Melo,
Peter Zijlstra, Srikar Dronamraju, Gabor Gombas, Borislav Petkov
Fix libdwarf include path to fit debian-like systems too.
Borislav Petkov said:
> 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 add a workaround for undefined _MIPS_SZLONG bug
in libdwarf.h.
Reported-by: Borislav Petkov <borislav.petkov@amd.com>
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
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: Borislav Petkov <borislav.petkov@amd.com>
---
tools/perf/Makefile | 3 ++-
tools/perf/util/probe-finder.h | 9 +++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 7814dbb..4390d22 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -487,10 +487,11 @@ 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 '\#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);
BASIC_CFLAGS += -DNO_LIBDWARF
else
+ BASIC_CFLAGS += -I/usr/include/libdwarf
EXTLIBS += -lelf -ldwarf
LIB_OBJS += util/probe-finder.o
endif
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 5e4050c..b6858f4 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -35,8 +35,13 @@ struct probe_point {
#ifndef NO_LIBDWARF
extern int find_probepoint(int fd, struct probe_point *pp);
-#include <libdwarf/dwarf.h>
-#include <libdwarf/libdwarf.h>
+/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h */
+#ifndef _MIPS_SZLONG
+#define _MIPS_SZLONG 0
+#endif
+
+#include <dwarf.h>
+#include <libdwarf.h>
struct probe_finder {
struct probe_point *pp; /* Target probe point */
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
^ permalink raw reply related [flat|nested] 13+ messages in thread* [tip:perf/urgent] perf probe: Fix libdwarf include path for Debian
2009-12-16 22:16 ` [PATCH -tip] perf probe: Fix libdwarf include path Masami Hiramatsu
@ 2009-12-17 7:54 ` tip-bot for Masami Hiramatsu
0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2009-12-17 7:54 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, acme, paulus, hpa, mingo, peterz, gombasg,
dle-develop, fweisbec, srikar, tglx, mhiramat, mingo, systemtap,
borislav.petkov
Commit-ID: 27f3b24de03fc7cec6f2406f8525ad18086c2121
Gitweb: http://git.kernel.org/tip/27f3b24de03fc7cec6f2406f8525ad18086c2121
Author: Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Wed, 16 Dec 2009 17:16:19 -0500
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 08:06:41 +0100
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>
---
tools/perf/Makefile | 3 +-
tools/perf/util/probe-finder.h | 59 +++++++++++++++++++++------------------
2 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 7814dbb..4390d22 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -487,10 +487,11 @@ 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 '\#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);
BASIC_CFLAGS += -DNO_LIBDWARF
else
+ BASIC_CFLAGS += -I/usr/include/libdwarf
EXTLIBS += -lelf -ldwarf
LIB_OBJS += util/probe-finder.o
endif
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 5e4050c..a4086aa 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -1,9 +1,9 @@
#ifndef _PROBE_FINDER_H
#define _PROBE_FINDER_H
-#define MAX_PATH_LEN 256
-#define MAX_PROBE_BUFFER 1024
-#define MAX_PROBES 128
+#define MAX_PATH_LEN 256
+#define MAX_PROBE_BUFFER 1024
+#define MAX_PROBES 128
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 {
- char *event; /* Event name */
- char *group; /* Event group */
+ char *event; /* Event name */
+ char *group; /* Event group */
/* Inputs */
- char *file; /* File name */
- int line; /* Line number */
+ char *file; /* File name */
+ int line; /* Line number */
- char *function; /* Function name */
- int offset; /* Offset bytes */
+ char *function; /* Function name */
+ int offset; /* Offset bytes */
- int nr_args; /* Number of arguments */
- char **args; /* Arguments */
+ int nr_args; /* Number of arguments */
+ char **args; /* Arguments */
- int retprobe; /* Return probe */
+ int retprobe; /* Return probe */
/* Output */
- int found; /* Number of found probe points */
- char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
+ int found; /* Number of found probe points */
+ char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
};
#ifndef NO_LIBDWARF
extern int find_probepoint(int fd, struct probe_point *pp);
-#include <libdwarf/dwarf.h>
-#include <libdwarf/libdwarf.h>
+/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
+#ifndef _MIPS_SZLONG
+# define _MIPS_SZLONG 0
+#endif
+
+#include <dwarf.h>
+#include <libdwarf.h>
struct probe_finder {
- struct probe_point *pp; /* Target probe point */
+ struct probe_point *pp; /* Target probe point */
/* For function searching */
- Dwarf_Addr addr; /* Address */
- Dwarf_Unsigned fno; /* File number */
- Dwarf_Unsigned lno; /* Line number */
- Dwarf_Off inl_offs; /* Inline offset */
- Dwarf_Die cu_die; /* Current CU */
+ Dwarf_Addr addr; /* Address */
+ Dwarf_Unsigned fno; /* File number */
+ Dwarf_Unsigned lno; /* Line number */
+ Dwarf_Off inl_offs; /* Inline offset */
+ Dwarf_Die cu_die; /* Current CU */
/* For variable searching */
- Dwarf_Addr cu_base; /* Current CU base address */
- Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
- const char *var; /* Current variable name */
- char *buf; /* Current output buffer */
- int len; /* Length of output buffer */
+ Dwarf_Addr cu_base; /* Current CU base address */
+ Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
+ const char *var; /* Current variable name */
+ char *buf; /* Current output buffer */
+ int len; /* Length of output buffer */
};
#endif /* NO_LIBDWARF */
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2009-12-17 7:57 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-16 13:54 perf and libdwarf on debian Borislav Petkov
2009-12-16 18:20 ` Masami Hiramatsu
2009-12-16 18:32 ` Peter Zijlstra
2009-12-16 18:38 ` Gabor Gombas
2009-12-16 18:58 ` Peter Zijlstra
2009-12-16 22:31 ` Thomas Fjellstrom
2009-12-16 19:05 ` Masami Hiramatsu
2009-12-16 19:19 ` Peter Zijlstra
2009-12-16 22:13 ` Borislav Petkov
2009-12-16 22:29 ` Masami Hiramatsu
2009-12-16 18:49 ` Gabor Gombas
2009-12-16 22:16 ` [PATCH -tip] perf probe: Fix libdwarf include path Masami Hiramatsu
2009-12-17 7:54 ` [tip:perf/urgent] perf probe: Fix libdwarf include path for Debian tip-bot for Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox