Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Kernel Code Coverage - GCOV

I'm trying to use some test scenarios from Linux test Project and get the Kernel source code coverage.

I'm using GCOV/LCOV to do so.

here are the things I have so far:

  • GCOV flags in the build config

GCOV-based kernel profiling

CONFIG_GCOV_KERNEL=y

CONFIG_GCOV_PROFILE_ALL=y

On Linux kernel version: 2.6.32.60+drm33.26

  • After building the kernel I have all the .gcov files in the source folder
  • GCOV/LCOV works when I use a source file as the input

Things that I should have but I don't

  • /Proc/GCOV folder
  • GCOV Kernel Module (gcov.o?)

Now what I want is to run the test scenarios and with LCOV get which portion of Linux Kernel Code has been used so far. but when I call LCOV -c this is what I get even though all the build flags are ok.

Loading required gcov kernel module.

lcov: ERROR: cannot load required gcov kernel module!

There is a kernel patch for < 2.6.30 and afterwards it is built in.

like image 693
Shayan Avatar asked Dec 04 '12 21:12

Shayan


People also ask

What is gcov in Linux?

gcov is a test coverage program. Use it in concert with GCC to analyze your programs to help create more efficient, faster running code and to discover untested parts of your program. You can use gcov as a profiling tool to help discover where your optimization efforts will best affect your code.

What are gcov files?

gcov produces files called mangledname. gcov in the current directory. These contain the coverage information of the source file they correspond to. One . gcov file is produced for each source (or header) file containing code, which was compiled to produce the data files.

What is LCOV in Linux?

LCOV is a graphical front-end for GCC's coverage testing tool gcov. It collects gcov data for multiple source files and creates HTML pages containing the source code annotated with coverage information. It also adds overview pages for easy navigation within the file structure.


1 Answers

please read this document

http://www.mjmwired.net/kernel/Documentation/gcov.txt

Here is answer to your questions:

  1. There is no proc fs for kernel coverage. After booting from the new kenrel, you had to mount the debug-fs via command: "mount -t debugfs none /sys/kernel/debug" and read coverage log of kernel from this file

  2. Kernel coverage can not be built as module. As you see, the CONFIG option is 'Y', not 'M'

like image 140
Houcheng Avatar answered Oct 13 '22 01:10

Houcheng