gcov-kernel enables code coverage measurements for the Linux kernel and kernel modules. It is based on GCC's gcov tool. gcov-kernel is available as a set of patches for Linux kernels 2.6.4 to 2.6.30. Starting with Linux kernel 2.6.31, gcov-kernel is part of the Linux kernel and can be used without extra patches.
Example: (assumes that Linux source code is installed in directory /tmp/linux)
CONFIG_GCOV_KERNEL=y CONFIG_GCOV_PROFILE_ALL=y
[root@host]# mount -t debugfs none /sys/kernel/debug
[root@host]# cd /tmp/linux
[root@host]# gcov kernel/gcov/base.c -o /sys/kernel/debug/gcov/tmp/linux/kernel/gcov/ File 'kernel/gcov/base.c' Lines executed:52.17% of 46 kernel/gcov/base.c:creating 'base.c.gcov'
Example: (assumes that Linux source code is installed in directory /tmp/linux)
CONFIG_GCOV_PROFILE=y CONFIG_GCOV_ALL=y CONFIG_GCOV_PROC=y
[root@host]# cd /tmp/linux
[root@host]# gcov lib/sort.c -o /proc/gcov/module/tmp/linux/lib/ File '/tmp/linux/lib/sort.c' Lines executed:84.85% of 33 /tmp/linux/lib/sort.c:creating 'sort.c.gcov'
Code coverage information for the specified source file can be found in the files created by gcov. Alternatively, use LCOV to obtain the information automatically.
Source code: gcov-kernel is released under the GPL license. The latest patch versions can be found in the LTP CVS repository.
For comments and questions contact: ltp-coverage@lists.sourceforge.net