From owner-freebsd-current@FreeBSD.ORG Mon Feb 23 05:24:06 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 021AA16A4CE for ; Mon, 23 Feb 2004 05:24:06 -0800 (PST) Received: from ftp.bjpu.edu.cn (ftp.bjpu.edu.cn [202.112.78.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6632043D1F for ; Mon, 23 Feb 2004 05:24:05 -0800 (PST) (envelope-from junsu@delphij.net) Received: from localhost (localhost [127.0.0.1]) by ftp.bjpu.edu.cn (Postfix) with ESMTP id 483D652C7 for ; Mon, 23 Feb 2004 21:24:03 +0800 (CST) Received: from ftp.bjpu.edu.cn ([127.0.0.1]) by localhost (ftp.bjpu.edu.cn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 38400-04 for ; Mon, 23 Feb 2004 21:24:02 +0800 (CST) Received: from beastie.frontfree.net (beastie.frontfree.net [218.107.145.7]) by ftp.bjpu.edu.cn (Postfix) with ESMTP id 0440E52C6 for ; Mon, 23 Feb 2004 21:24:02 +0800 (CST) Received: from localhost (localhost [127.0.0.1]) by beastie.frontfree.net (Postfix) with ESMTP id DA2A011557; Mon, 23 Feb 2004 21:23:50 +0800 (CST) Received: from beastie.frontfree.net ([127.0.0.1]) by localhost (beastie.frontfree.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00372-03; Mon, 23 Feb 2004 21:21:33 +0800 (CST) Received: from mail.frontfree.net (unknown [211.161.222.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by beastie.frontfree.net (Postfix) with ESMTP id E499511456; Mon, 23 Feb 2004 21:12:23 +0800 (CST) Date: Mon, 23 Feb 2004 21:12:06 +0800 To: "current@freebsd.org" From: "Jun Su" Content-Type: text/plain; format=flowed; delsp=yes; charset=gbk MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: User-Agent: Opera M2/7.50 (Win32, build 3613) X-Virus-Scanned: by Frontfree Secure Mail II at frontfree.net X-Virus-Scanned: by amavisd-new at frontfree.net cc: Poul-Henning Kamp Subject: Call for Testers: Kernel GCOV X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Feb 2004 13:24:06 -0000 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