LTP Kernel Coverage

From openSUSE

Messure LTP's Kernel Coverage


References: LTP .. Linux Test Project Linux Test Project
Kernel Coverage .. Original instructions available from LTP here

Instructions:

  • You need a installed SLES or OpenSUSE Product, with rpm-packages needed for kernel compilation installed (gcc,make etc.)
  • get the coverage Patch from sourceforge.net, for vanilla-kernel (in this case 2.6.16) you found the patch here, alternatively you can find prepared patches for OpenSUSE Kernels 10.1, 10.2, 10.3 here
  • Apply the patches (copy the patch to /usr/src) and change into /usr/src/linux and do "patch -p1 < ../<patch>" look for rejections, if there are some, resolve them :). At least you will have one rejection, the main Makefile does not contain the gcov-mentioned kernel version.
  • Now do a "make menuconfig" and select all GCOV options (it is in menu 'Kernel Hacking')
  • Hint for openSUSE 10.3 and kernel 2.6.22 you cannot use CONFIG_GCOV_ALL=y (should be n), because init-process will segfault.
  • Build the kernel ('make;make modules_install') and probably build the initrd ('mkinitrd -k bzImage -i bzImage.initrd') and edit your bootloader file (for grub: /boot/grub/menu.lst)
  • reboot and boot the gcov kernel
  • If you selected the gcov as kernel-module then you should do a 'modprobe gcov-proc', if you selected it to be compiled directly in the kernel then everything is fine.
  • Now there is '/proc/gcov/' available, the subdirectories aim the kernel source file.
  • Hint: If you see in /proc/gcov directory a lot of .tmp* files, then edit '.config' file (this file is located in the top directory of your Linux sources) and disable CONFIG_MODVERSIONS, afterwards it should be fine. The same error is also: ".tmp_signal.gcno:cannot open graph file".

Create the Galaxy Poster


  • Extract the free code graphing project tools in a <directory> of your choice,
  • For this you need the lcov installed. A typical step for getting the coverage data (kernel space) is:
  a) Resetting counters
    lcov --zerocounters
  b) Capturing the current coverage state to a file
    lcov --capture --output-file kernel.info
  • Now you can follow the instructions from <directory>/README file or this ones:
    run from the copy of your Kernel source files the indent tool (it changes the appearance of C program):
   for i in `find $KERNEL_DIR -type d`; do
     indent $i/*.c
   done 

Here you will get a lot of warnings, but they did not influence the poster.

./genflat.pl kernel.info > coverage.dat
  • run:
make KERNEL_DIR=/path/to/kernel/src/copy 

Hint: if you get make error 141, eg. make: *** [image/ring3] Error 141 then you ran into a Broken Pipe. The cause is to small default buffer size in the files analyze_function.c and rmclutter.c. To correct this:

*Search for the line "#define YY_BUF_SIZE 16384" (guess line 134) in the file analyze_function.c and replace the 16384 with  536870912. Then compile the function with "make function2ps".
*Search for the line "#define YY_BUF_SIZE 16384" (guess line 133) in the file rmclutter.c and replace the 16384  also with  536870912. Then compile the funtion with "make rmclutter". Well if this also does not work, you should edit the Makefile, where the RING4= is mentioned. Background is, that there are too many source-code files at once (see at drivers directory in kernel source code), the parser is currently not able to handle this amount.
*Search for the Buffer varibales in function2ps.c  and resize them by factor 10, then it should compile, eg. "InitBuffer (&CFileName,    20000);". Be warned scaling this too high really make the build process slow.
With these two replacements the make KERNEL_DIR=... command can be rerun.

If this did not help, have a look at the image directory and search for missing directorys. The needed directorys can you get from the main Makefile. In this special case, the directory "image/arch/i386" was not created. So after the directory creation, you can manually run "./setup_dirtree.pl 3 /usr/src/linux/ arch/i386" (means Ring 3 with this linux source and the offset from the linux source). Afterwards run "./extract_funcs.pl 15 3" (means 15 lines must the file have to be in Ring 3).

  • At last run in <directory>/posterize (e.g. with "./posterize a1 1"), this will create the Galaxy poster with the format of one A1 sheet.
  • After that is finished you can have a look with gimp to the poster ("gimp poster.ps").
  • Some useful hint for printing:

- direct printing ends in some strange way, always in a 90° way - I use a the "ps2pdf" (package ghostscript-library) to convert the poster.ps to a pdf and print it with "kpdf" (package kdegraphics3-pdf, I know it is a workaround :-) )

Questions or unsatisfied?