Call for Testers: Kernel GCOV

From: Jun Su <junsu_at_delphij.net>
Date: Mon, 23 Feb 2004 21:12:06 +0800
Hi All,

I created a patch to support gcov in multi platform and kernel module.  
Please have test.
You can download the patch from:
http://www.arbornet.org/~junsu/gcov.diff

CAUTION: The patch will change ldscript.${MACHINE_ARCH}. It may caused  
your kernel can not be boot. Please backup your kernel before testing this  
patch.
I have only tested this patch in i386. For the lack of other machines, I  
can not test it in other platform. Please let me know if it works in other  
platforms.

Description
-------------
   GCOV is a test coverage program distributed as part of GCC. It helps  
discover
   where your optimization efforts will best affect your code. Using GCOV  
one can
   find out some basic performance statistics on a per source file level  
such as:

     * how often each line of code executes

     * what lines of code are actually executed


   GCOV is already available for user level applications. PHK has  
implemented the kenel
support for i386 before.

Usage
------
   1. Kernel GCOV Compile
      You need manually put -fprofile-arcs -ftest-coverage. You can specify  
it in enverienment or in /etc/make.conf.
       csh:
	  setenv COPTFLAGS "-fprofile-arcs -ftest-coverage"
	bash:
	  set COPTFLAGS="-fprofile-arcs -ftest-coverage";export COPTFLAGS
	make.conf
	  COPTFLAGS= -O -pipe -fprofile-arcs -ftest-coverage

	If you only want to gcov some file, for example, kern_proc.c. After a  
normal compiling, delete
kern_proc.o. Then set the above compile option, and run make again.

   2. Kernel Module GCOV Compile
	It is simple. Cd to modules/xxx/ folder, and Run the following command:
	   make -DCOVERAGE

   3. Compile a new kernbb
	Since I changed the symbol bbhead to _bb_head, we need change kernbb  
correspond. Change the bbhead to _bb_head.
struct nlist namelist[] = {
         { "_bb_head", 0, 0, 0, 0 },
         { NULL, 0, 0, 0, 0 }
};

4. Get the result
After the new kernel boot and load the modules you want to profile. Run  
some typical scenario. Then use kernbb to get .bb files.
The files will be written to your obj folder. If you use make buildkernel  
KERNCONF=KERNEL_NAME, then the folder is /usr/obj/usr/src/sys/KERNEL_NAME.

Use gcov command to check the result.
gcov ¨Co /usr/obj/usr/src/sys/KERNEL_NAME/ /usr/src/sys/kern/kern_proc.c

If you have any questions, please drop me an email.

Next step, I will try to implement PHK's idea to measure how much code  
runs under Gaint. :-)

Thanks,

Jun Su
Received on Mon Feb 23 2004 - 04:24:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:44 UTC