This is version #2 of the gcov kernel support patch set (see further
below for an in-depth explanation). Patch base is 2.6.26-rc3.Changes are mostly based on mailing list feedback:
* added more documentation
* moved gcov config menu to general setup
* renamed some structures and variables (removed _t, lowercase ctors)
* split mod versioning change into separate patch (3)
* split GCC_VERSION_LOWER into separate patch (2)
* split gcov core patch into two patches (5+6) for better readability
* absolute paths only used when CONFIG_GCOV_PROFILE is set
* fixed compile problem with CONFIG_MODULES=n
* fixed memory leak in gcov fs code
* more style changesPatch overview:
[PATCH 1/7] kernel: call constructors
[PATCH 2/7] kernel: introduce GCC_VERSION_LOWER macro
[PATCH 3/7] kbuild: delay object file renaming during module versioning
[PATCH 4/7] seq_file: add function to write binary data
[PATCH 5/7] gcov: add gcov profiling infrastructure
[PATCH 6/7] kbuild: make source and include paths absolute
[PATCH 7/7] gcov: architecture specific compile flag adjustments===
This set of patches enables the use of GCC's coverage testing tool
gcov [1] with kernel 2.6.25. Coverage data for the running kernel is
exported via debugfs in a gcov-compatible format. To get coverage
data for a specific file, simply use gcov with the -o option:# gcov -o /sys/kernel/debug/gcov/tmp/linux-2.6.25/kernel spinlock.c
This will create source code files annotated with execution counts
in the current directory. In addition, graphical gcov front-ends such
as lcov [2] can be used to automate the process of collecting data
for the entire kernel and provide coverage overviews in HTML format.Possible uses:
* debugging (has this line been executed at all?)
* test improvement (how do I change my test to cover these lines?)
* minimizing kernel configurations (do I need this option if the
associated code is never executed?)Known issues:
* some architecture specific problems: the patch...
powerpc blew up:
/opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/lib/gcc/powerpc64-unknown-linux-gnu/4.1.0/../../../../powerpc64-unknown-linux-gnu/bin/ld: skipping incompatible /opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/lib/gcc/powerpc64-unknown-linux-gnu/4.1.0/./libgcov.a when searching for -lgcov
/opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/lib/gcc/powerpc64-unknown-linux-gnu/4.1.0/../../../../powerpc64-unknown-linux-gnu/bin/ld: cannot find -lgcov
collect2: ld returned 1 exit status
make[2]: *** [arch/powerpc/kernel/vdso32/vdso32.so.dbg] Error 1
make[1]: *** [arch/powerpc/kernel/vdso32] Error 2--
This looks like a secondary linking process. It's best to exclude the
whole directory from GCOV profiling (which should ony work for C files
anyway).Below is an update for patch #7 of the gcov series that includes the
corresponding changes.---
[PATCH 7/7] gcov: architecture specific compile flag adjustments
From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Exclude code from profiling which is not linked to the main kernel or
which is running in a context not compatible with the assumptions made
by gcc's profiling code.Signed-off-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
---
arch/arm/boot/compressed/Makefile | 1 +
arch/powerpc/kernel/vdso32/Makefile | 1 +
arch/powerpc/kernel/vdso64/Makefile | 1 +
arch/ppc/boot/Makefile | 1 +
arch/ppc/boot/common/Makefile | 1 +
arch/ppc/boot/simple/Makefile | 1 +
arch/x86/boot/Makefile | 1 +
arch/x86/boot/compressed/Makefile | 1 +
arch/x86/kernel/acpi/realmode/Makefile | 1 +
9 files changed, 9 insertions(+)Index: linux-2.6.26-rc3/arch/arm/boot/compressed/Makefile
===================================================================
--- linux-2.6.26-rc3.orig/arch/arm/boot/compressed/Makefile
+++ linux-2.6.26-rc3/arch/arm/boot/compressed/Makefile
@@ -7,6 +7,7 @@
HEAD = head.o
OBJS = misc.o
FONTC = $(srctree)/drivers/video/console/font_acorn_8x8.c
+GCOV := n#
# Architecture dependencies
Index: linux-2.6.26-rc3/arch/x86/boot/compressed/Makefile
===================================================================
--- linux-2.6.26-rc3.orig/arch/x86/boot/compressed/Makefile
+++ linux-2.6.26-rc3/arch/x86/boot/compressed/Makefile
@@ -12,6 +12,7 @@ cflags-$(CONFIG_X86_64) := -mcmodel=smal
KBUILD_CFLAGS += $(cflags-y)
KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
+GCOV := nKBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__...
Sounds like your toolchain was built without biarch support, but you're
using it for the 32-bit parts of the kernel anyway. Which works as long
as you're not using any libraries, but now you need libgcov.a .What does
/opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/bin/
powerpc64-unknown-linux-gnu-gcc -vsay? (Or whatever the correct path to that compiler is, the directory
structure is a bit unusual here it seems). There shouldn't be a
--disable-biarch there.Or, what does
find
/opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/4.1.0/
-name libgcov.asay? (It should usually find three versions: 64-bit, 32-bit, 32-bit no
float).You *can* build with a non-biarch compiler, but then you need to point
the kernel build system at a 32-bit toolchain to use for the 32-bit
parts (via CROSS32_COMPILE).Segher
--
y:/home/akpm> /opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/bin/powerpc64-unknown-linux-gnu-gcc -v
Using built-in specs.
Target: powerpc64-unknown-linux-gnu
Configured with: /home/axboe/crosstool-0.43/build/powerpc64-unknown-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/configure --target=powerpc64-unknown-linux-gnu --host=x86_64-host_unknown-linux-gnu --prefix=/opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu --disable-multilib --with-sysroot=/opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/powerpc64-unknown-linux-gnu/sys-root --with-local-prefix=/opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/powerpc64-unknown-linux-gnu/sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c --enable-shared --enable-c99 --enable-long-long
Thread model: posixOnly a single hit:
/opt/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc64-unknown-linux-gnu/lib/gcc/powerpc64-unknown-linux-gnu/4.1.0/libgcov.a
and it contains
y:/home/akpm/ppc> ar x libgcov.a
y:/home/akpm/ppc> l
total 316
-rw-r--r-- 1 akpm akpm 44192 May 23 09:53 _gcov.o
-rw-r--r-- 1 akpm akpm 8448 May 23 09:53 _gcov_execl.o
-rw-r--r-- 1 akpm akpm 8584 May 23 09:53 _gcov_execle.o
-rw-r--r-- 1 akpm akpm 8456 May 23 09:53 _gcov_execlp.o
-rw-r--r-- 1 akpm akpm 7384 May 23 09:53 _gcov_execv.o
-rw-r--r-- 1 akpm akpm 7544 May 23 09:53 _gcov_execve.o
-rw-r--r-- 1 akpm akpm 7392 May 23 09:53 _gcov_execvp.o
-rw-r--r-- 1 akpm akpm 7264 May 23 09:53 _gcov_fork.o
-rw-r--r-- 1 akpm akpm 7240 May 23 09:53 _gcov_interval_profiler.o
-rw-r--r-- 1 akpm akpm 7464 May 23 09:53 _gcov_merge_add.o
-rw-r--r-- 1 akpm akpm 8544 May 23 09:53 _gcov_merge_delta.o
-rw-r--r-- 1 akpm akpm 8488 May 23 09:53 _gcov_merge_single.o
-rw-r--r-- 1 akpm akpm 6976 May 23 09:53 _gcov_one_value_profiler.o
-rw-r--r-- 1 akpm akpm 6856 May 23 09:53 _gcov_pow2_profiler.o
-rw-r--r-- 1 akpm akpm 146492 May 23 09:52 libgcov.a
y:/home/akpm/ppc...
That's the culprit. I believe 4.1.0 enables multilib by default on
PowerPC
compilers that target 64-bit by default (the patch for that is dated
almost
a full year before the 4.1.0 release). I have no idea why crosstool
disables this support; perhaps there were some problems with some olderYou were lucky, yes. If your compiler would have been just a little
bit older it wouldn't have been able to build 32-bit at all.Do you have a separate 32-bit PowerPC compiler? If so, just set
CROSS32_COMPILE to it; if not, you'll need a new toolchain. In
that case, it's probably worthwhile to upgrade to 4.1.2 at least...Segher
--
On Fri, 23 May 2008 23:52:43 +0200
Sigh. Life's too short. I'll go back to testing powerpc builds on the
powerpc box.--
I reviewed the patches and they look good to me (except for
some minor nits, probably not worth fixing)-Andi
--
| Ingo Molnar | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Roland Dreier | Re: Integration of SCST in the mainstream Linux kernel |
git: | |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Arjan van de Ven | Re: [GIT]: Networking |
| Linus Torvalds | Re: iptables very slow after commit 784544739a25c30637397ace5489eeb6e15d7d49 |
